|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import { logger } from "@bogeychan/elysia-logger";
|
|
|
|
|
import { Elysia } from "elysia";
|
|
|
|
|
// import { logger } from "@bogeychan/elysia-logger";
|
|
|
|
|
// import pretty from "pino-pretty";
|
|
|
|
|
import pretty from "pino-pretty";
|
|
|
|
|
import { config } from "../config";
|
|
|
|
|
import { client, db } from "../db";
|
|
|
|
|
import "beth-stack/jsx/register";
|
|
|
|
@ -9,43 +9,43 @@ import { auth } from "../auth";
|
|
|
|
|
|
|
|
|
|
// import { cron } from "@elysiajs/cron";
|
|
|
|
|
|
|
|
|
|
// const stream = pretty({
|
|
|
|
|
// colorize: true,
|
|
|
|
|
// });
|
|
|
|
|
const stream = pretty({
|
|
|
|
|
colorize: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const ctx = new Elysia({
|
|
|
|
|
name: "@app/ctx",
|
|
|
|
|
})
|
|
|
|
|
.use(
|
|
|
|
|
bethStack({
|
|
|
|
|
log: true,
|
|
|
|
|
// log: false,
|
|
|
|
|
returnStaleWhileRevalidate: false,
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
// .use(
|
|
|
|
|
// logger({
|
|
|
|
|
// level: config.env.LOG_LEVEL,
|
|
|
|
|
// stream,
|
|
|
|
|
// })
|
|
|
|
|
// )
|
|
|
|
|
// .use(
|
|
|
|
|
// cron({
|
|
|
|
|
// name: "heartbeat",
|
|
|
|
|
// pattern: "*/1 * * * * *",
|
|
|
|
|
// run() {
|
|
|
|
|
// if (config.env.SYNC_URL) {
|
|
|
|
|
// const now = performance.now();
|
|
|
|
|
// console.log("Syncing database...");
|
|
|
|
|
// void client.sync().then(() => {
|
|
|
|
|
// console.log(`Database synced in ${performance.now() - now}ms`);
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// })
|
|
|
|
|
// )
|
|
|
|
|
.decorate("db", db)
|
|
|
|
|
.decorate("config", config)
|
|
|
|
|
.decorate("auth", auth);
|
|
|
|
|
.use(
|
|
|
|
|
logger({
|
|
|
|
|
level: config.env.LOG_LEVEL,
|
|
|
|
|
stream,
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
// .use(
|
|
|
|
|
// cron({
|
|
|
|
|
// name: "heartbeat",
|
|
|
|
|
// pattern: "*/1 * * * * *",
|
|
|
|
|
// run() {
|
|
|
|
|
// if (config.env.SYNC_URL) {
|
|
|
|
|
// const now = performance.now();
|
|
|
|
|
// console.log("Syncing database...");
|
|
|
|
|
// void client.sync().then(() => {
|
|
|
|
|
// console.log(`Database synced in ${performance.now() - now}ms`);
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// })
|
|
|
|
|
// )
|
|
|
|
|
// .decorate("db", db)
|
|
|
|
|
// .decorate("config", config)
|
|
|
|
|
// .decorate("auth", auth)
|
|
|
|
|
// .onStart(({ log }) => log.info("Server starting"))
|
|
|
|
|
// .onStop(({ log }) => log.info("Server stopping"))
|
|
|
|
|
// .onRequest(({ log, request }) => {
|
|
|
|
|