28 lines
No EOL
781 B
JavaScript
28 lines
No EOL
781 B
JavaScript
import { Router } from "express";
|
|
import { replyIterator } from "../lib.js";
|
|
import { initDb } from "../db.js";
|
|
let db = await initDb();
|
|
|
|
const router = Router();
|
|
|
|
//todo: fix jank
|
|
|
|
router.get('/:username', async (req, res, next) => {
|
|
let topComment = await db.all('SELECT * FROM feeder WHERE parentType = ? AND parentId = ? ORDER BY sortId ASC LIMIT ? OFFSET ?', [
|
|
'users',
|
|
req.params.username,
|
|
1,
|
|
0
|
|
]);
|
|
topComment = await replyIterator(topComment,db);
|
|
|
|
res.ctx.mainPage = 'user'
|
|
res.ctx.mainCtx = {
|
|
username: req.params.username,
|
|
isYou: res.auth && req.params.username == res.auth.username,
|
|
desc: topComment[0] ? topComment[0].comment.content : false
|
|
}
|
|
next();
|
|
})
|
|
|
|
export default router; |