f0ckv2/src/websrv.mjs

15 lines
421 B
JavaScript
Raw Normal View History

2019-04-25 18:00:47 +00:00
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);