router, api and stuff
This commit is contained in:
14
src/websrv.mjs
Normal file
14
src/websrv.mjs
Normal file
@@ -0,0 +1,14 @@
|
||||
import http from "http";
|
||||
import url from "url";
|
||||
|
||||
import "./inc/routes/index";
|
||||
import "./inc/routes/api";
|
||||
|
||||
import { routes } from "./inc/router";
|
||||
|
||||
http.createServer((req, res, r, uri = url.parse(req.url)) => {
|
||||
req.url = uri;
|
||||
req.url.split = uri.pathname.split("/");
|
||||
req.url.split.shift();
|
||||
(!(r = routes.getRegex(req.url.pathname, req.method)) ? res.end(`404 - ${req.url.pathname}`) : r(req, res))
|
||||
}).listen(1499);
|
Reference in New Issue
Block a user