34 lines
No EOL
846 B
JavaScript
34 lines
No EOL
846 B
JavaScript
import Route from "../route.js";
|
|
import initDb from "../db.js";
|
|
|
|
let db = await initDb();
|
|
|
|
let main = new Route([], async function (req, res, input) {
|
|
let {route} = req.params;
|
|
let {id} = req.query;
|
|
|
|
let body = { ...req.cookies, ...req.body };
|
|
|
|
let { token } = body;
|
|
|
|
let match = await db.all('SELECT * FROM token WHERE token = ?', [
|
|
token || 'blah'
|
|
]);
|
|
|
|
let username = match[0] ? match[0].username : '!nobody';
|
|
|
|
let valid = await db.all('SELECT * FROM auth WHERE username = ?', [
|
|
username
|
|
]);
|
|
|
|
return {
|
|
username,
|
|
valid: valid[0] ? valid[0].valid : 'noexist',
|
|
url: `${process.env.URL}/client/${route}?id=${id || ''}`,
|
|
icon: `${process.env.URL}/static/img/logo.png`,
|
|
rootUrl: process.env.URL,
|
|
ogType: 'website'
|
|
};
|
|
});
|
|
|
|
export default main; |