henlol
This commit is contained in:
parent
3d6757fcce
commit
11f3cd9277
@ -9,10 +9,6 @@ const auth = async (req, res, next) => {
|
||||
export default (router, tpl) => {
|
||||
router.group(/^\/settings/, group => {
|
||||
group.get(/$/, auth, async (req, res) => {
|
||||
/*const sessions = await sql("user_sessions")
|
||||
.where("user_id", req.session.id)
|
||||
.orderBy("last_used", "desc");*/
|
||||
|
||||
const sessions = await db`
|
||||
select *
|
||||
from user_sessions
|
||||
|
@ -2,10 +2,4 @@
|
||||
import postgres from "postgres";
|
||||
import cfg from "./config.mjs";
|
||||
|
||||
/*export default knex({
|
||||
client: 'pg',
|
||||
connection: cfg.sql
|
||||
});*/
|
||||
|
||||
//export const db = postgres(cfg.sql);
|
||||
export default postgres(cfg.sql);
|
||||
|
@ -20,31 +20,31 @@ import flummpress from "flummpress";
|
||||
bot: await new cuffeo(cfg.clients)
|
||||
};
|
||||
|
||||
//console.time("loading");
|
||||
console.time("loading");
|
||||
const modules = {
|
||||
events: (await fs.readdir("./src/inc/events")).filter(f => f.endsWith(".mjs")),
|
||||
trigger: (await fs.readdir("./src/inc/trigger")).filter(f => f.endsWith(".mjs"))
|
||||
};
|
||||
|
||||
//console.timeLog("loading", "directories");
|
||||
console.timeLog("loading", "directories");
|
||||
const blah = (await Promise.all(Object.entries(modules).map(async ([dir, mods]) => ({
|
||||
[dir]: (await Promise.all(mods.map(async mod => {
|
||||
const res = await Promise.race([
|
||||
(await import(`./inc/${dir}/${mod}`)).default(self),
|
||||
new Promise((_, rej) => setTimeout(() => rej(false), timeout))
|
||||
]);
|
||||
//console.timeLog("loading", `${dir}/${mod}`);
|
||||
console.timeLog("loading", `${dir}/${mod}`);
|
||||
return res;
|
||||
}))).flat(2)
|
||||
})))).reduce((a, b) => ({...a, ...b}));
|
||||
|
||||
blah.events.forEach(event => {
|
||||
//console.timeLog("loading", `registering event > ${event.name}`);
|
||||
console.timeLog("loading", `registering event > ${event.name}`);
|
||||
self.bot.on(event.listener, event.f);
|
||||
});
|
||||
|
||||
blah.trigger.forEach(trigger => {
|
||||
//console.timeLog("loading", `registering trigger > ${trigger.name}`);
|
||||
console.timeLog("loading", `registering trigger > ${trigger.name}`);
|
||||
self._trigger.set(trigger.name, new self.trigger(trigger));
|
||||
});
|
||||
|
||||
@ -125,4 +125,8 @@ import flummpress from "flummpress";
|
||||
await router.importRoutesFromPath("src/inc/routes", tpl);
|
||||
|
||||
app.listen(cfg.websrv.port);
|
||||
|
||||
db.subscribe('*:items', (row, { command, old }) => {
|
||||
console.log(command, row, old);
|
||||
});
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user