diff --git a/public/css/f0ck.css b/public/css/f0ck.css
index 6ea1764..8e1b370 100644
--- a/public/css/f0ck.css
+++ b/public/css/f0ck.css
@@ -24,8 +24,9 @@
/* Body */
body {
- background-color: var(--bg-color);
+ background-color: var(--bg-color);
color: var(--font-color);
+ /*overflow: hidden;*/
}
/* End of Body */
diff --git a/public/js/f0ck.js b/public/js/f0ck.js
new file mode 100644
index 0000000..e69de29
diff --git a/src/inc/routes/api.mjs b/src/inc/routes/api.mjs
index 5251cfe..7ce072a 100644
--- a/src/inc/routes/api.mjs
+++ b/src/inc/routes/api.mjs
@@ -8,7 +8,7 @@ router.get(/^\/api$/, (req, res) => {
res.end("api lol");
});
-router.get(/^\/api\/random(\/user\/.+|\/image|\/video|\/audio|\/)?$/, async (req, res) => {
+router.get(/^\/api\/random(\/user\/.+|\/image|\/video|\/audio)?$/, async (req, res) => {
const db = await sql;
let q = queries.random.main;
let args = [];
@@ -28,10 +28,11 @@ router.get(/^\/api\/random(\/user\/.+|\/image|\/video|\/audio|\/)?$/, async (req
}).catch(err => res.end(JSON.stringify( err ), 'utf-8'));
});
-router.get(/^\/api\/p(\/[0-9]+|\/)?(\/[0-9]+)?\/?$/, async (req, res) => {
+//router.get(/^\/api\/p(\/[0-9]+|\/)?(\/[0-9]+)?$/, async (req, res) => {
+router.get(/^\/api\/p$/, async (req, res) => {
const db = await sql;
- const id = parseInt(req.url.split[2]) || 99999999;
- const eps = Math.min(parseInt(req.url.split[3]) || 100, 200);
+ const id = parseInt(req.url.qs.id) || 99999999;
+ const eps = Math.min(parseInt(req.url.qs.eps) || 100, 200);
db.query("select * from f0ck.items where id < ? order by id desc limit ?", [id, eps])
.then(rows => {
let items = {
diff --git a/src/inc/routes/index.mjs b/src/inc/routes/index.mjs
index 3914ae3..cf820b2 100644
--- a/src/inc/routes/index.mjs
+++ b/src/inc/routes/index.mjs
@@ -14,7 +14,7 @@ router.get(/^\/$/, async (req, res) => {
db.query(queries.items)
.then(items => {
const tpl = handlebars.compile(template);
- res.end(tpl({ items: items }));
+ res.end(tpl({ items: items, debug: JSON.stringify(req.url, null, 2) }));
}).catch(err => res.end(JSON.stringify( err ), 'utf-8'));
/*const tpl = handlebars.compile(template);
diff --git a/src/websrv.mjs b/src/websrv.mjs
index b0e63bf..d7282eb 100644
--- a/src/websrv.mjs
+++ b/src/websrv.mjs
@@ -1,14 +1,20 @@
import http from "http";
import url from "url";
+import querystring from "querystring";
+import cfg from "../config.json";
+// routes
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);
+http.createServer((req, res, r) => {
+ req.url = url.parse(req.url.replace(/(?!^.)(\/+)?$/, ''));
+ req.url.split = req.url.pathname.split("/").slice(1);
+ req.url.qs = querystring.parse(req.url.query);
+
+ console.log(`[${(new Date()).toLocaleTimeString()}] ${req.method} ${req.url.pathname}`);
+
+ !(r = routes.getRegex(req.url.pathname, req.method)) ? res.end(`404 - ${req.url.pathname}`) : r(req, res);
+}).listen(cfg.websrv.port, () => console.log(`f0ck is listening on port ${cfg.websrv.port}.`));
diff --git a/views/index.html.tpl b/views/index.html.tpl
index 70818b4..87b4adc 100644
--- a/views/index.html.tpl
+++ b/views/index.html.tpl
@@ -17,13 +17,14 @@