mirror of
				https://github.com/karl0ss/homepage.git
				synced 2025-11-04 08:20:58 +00:00 
			
		
		
		
	refactor widget.js, return http 200 when server is offline
This commit is contained in:
		
							parent
							
								
									ad66637ff1
								
							
						
					
					
						commit
						b36ef0234e
					
				@ -18,7 +18,7 @@ export default async function minecraftProxyHandler(req, res) {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
    } catch (e) {
 | 
					    } catch (e) {
 | 
				
			||||||
        logger.warn(e)
 | 
					        logger.warn(e)
 | 
				
			||||||
        res.status(500).send({
 | 
					        res.status(200).send({
 | 
				
			||||||
            version: undefined,
 | 
					            version: undefined,
 | 
				
			||||||
            online: false,
 | 
					            online: false,
 | 
				
			||||||
            players: undefined
 | 
					            players: undefined
 | 
				
			||||||
 | 
				
			|||||||
@ -1,21 +1,7 @@
 | 
				
			|||||||
import minecraftProxyHandler from "utils/proxy/handlers/minecraft";
 | 
					import minecraftProxyHandler from "utils/proxy/handlers/minecraft";
 | 
				
			||||||
import { asJson } from "utils/proxy/api-helpers";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const widget = {
 | 
					const widget = {
 | 
				
			||||||
  proxyHandler: minecraftProxyHandler,
 | 
					  proxyHandler: minecraftProxyHandler
 | 
				
			||||||
  mappings: {
 | 
					 | 
				
			||||||
    status: {
 | 
					 | 
				
			||||||
      endpoint: "_",
 | 
					 | 
				
			||||||
      map: (data) => {
 | 
					 | 
				
			||||||
        const jsonData = asJson(data);
 | 
					 | 
				
			||||||
        return {
 | 
					 | 
				
			||||||
          players: jsonData.players,
 | 
					 | 
				
			||||||
          version: jsonData.version,
 | 
					 | 
				
			||||||
          online: jsonData.online
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default widget;
 | 
					export default widget;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user