router, api and stuff

This commit is contained in:
Flummi
2019-04-25 18:00:47 +00:00
parent 54ea970a3e
commit fb633ba64f
8 changed files with 145 additions and 67 deletions

14
src/websrv.mjs Normal file
View 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);