websrv: time measurement
This commit is contained in:
		| @@ -10,6 +10,8 @@ import "./inc/routes/api.mjs"; | ||||
| import "./inc/routes/static.mjs"; | ||||
|  | ||||
| http.createServer(async (req, res, r) => { | ||||
|   const t_start = process.hrtime(); | ||||
|  | ||||
|   req.url = url.parse(req.url.replace(/(?!^.)(\/+)?$/, '')); | ||||
|   req.url.split = req.url.pathname.split("/").slice(1); | ||||
|   req.url.qs = querystring.parse(req.url.query); | ||||
| @@ -30,7 +32,7 @@ http.createServer(async (req, res, r) => { | ||||
|   }).end(); | ||||
|  | ||||
|   !(r = router.routes.getRoute(req.url.pathname, req.method)) ? res.writeHead(404).end(`404 - ${req.url.pathname}`) : await r(req, res); | ||||
|   console.log(`[${(new Date()).toLocaleTimeString()}] ${res.statusCode} ${req.method}\t${req.url.pathname}`); | ||||
|   console.log(`[${(new Date()).toLocaleTimeString()}] ${(process.hrtime(t_start)[1] / 1e5).toFixed(2)}ms\t${res.statusCode} ${req.method}\t${req.url.pathname}`); | ||||
| }).listen(cfg.websrv.port, () => setTimeout(() => { | ||||
|   console.log(`f0ck is listening on port ${cfg.websrv.port}.`); | ||||
| }, 500)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user