25 lines
517 B
JavaScript
25 lines
517 B
JavaScript
|
import Route from "../route.js";
|
||
|
import auth from "../form/auth.js";
|
||
|
import initDb from "../db.js";
|
||
|
|
||
|
let db = await initDb();
|
||
|
|
||
|
let main = new Route([auth], async function (req, res, input) {
|
||
|
let {route} = req.params;
|
||
|
let {id} = req.query;
|
||
|
let { username } = input;
|
||
|
|
||
|
let comments = await db.all('SELECT * FROM comment WHERE targetType = ? AND targetId = ?', [
|
||
|
route,
|
||
|
id
|
||
|
]);
|
||
|
|
||
|
return {
|
||
|
...input,
|
||
|
route,
|
||
|
id,
|
||
|
comments
|
||
|
};
|
||
|
});
|
||
|
|
||
|
export default main;
|