stuff lol
This commit is contained in:
@ -38,7 +38,7 @@ router.get(/^\/api\/p(\/[0-9]+|\/)?(\/[0-9]+)?\/?$/, async (req, res) => {
|
||||
"items": [],
|
||||
"last": id
|
||||
};
|
||||
rows.forEach((e,i,a) => {
|
||||
rows.forEach(e => {
|
||||
items.items.push({
|
||||
"id": e.id,
|
||||
"mime": e.mime
|
||||
|
3
src/inc/routes/inc/index.mjs
Normal file
3
src/inc/routes/inc/index.mjs
Normal file
@ -0,0 +1,3 @@
|
||||
export const queries = {
|
||||
items: "select id, mime from f0ck.items order by id desc limit 72"
|
||||
};
|
@ -1,5 +1,22 @@
|
||||
import router from "../router";
|
||||
import fs from "fs";
|
||||
import sql from "../sql";
|
||||
import handlebars from "handlebars";
|
||||
|
||||
router.get(/^\/$/, (req, res) => {
|
||||
res.end("index lol");
|
||||
import { queries } from "./inc/index";
|
||||
|
||||
const template = fs.readFileSync("./views/index.html.tpl", "utf-8");
|
||||
|
||||
router.get(/^\/$/, async (req, res) => {
|
||||
const db = await sql;
|
||||
res.writeHead(200, { 'Content-Type': 'text/html' });
|
||||
|
||||
db.query(queries.items)
|
||||
.then(items => {
|
||||
const tpl = handlebars.compile(template);
|
||||
res.end(tpl({ items: items }));
|
||||
}).catch(err => res.end(JSON.stringify( err ), 'utf-8'));
|
||||
|
||||
/*const tpl = handlebars.compile(template);
|
||||
res.end(tpl());*/
|
||||
});
|
||||
|
Reference in New Issue
Block a user