modified: public/css/f0ck.css
new file: public/js/f0ck.js modified: src/inc/routes/api.mjs modified: src/inc/routes/index.mjs modified: src/websrv.mjs modified: views/index.html.tpl
This commit is contained in:
@ -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 = {
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user