hey log works at least

main
Ethan Niser 2023-09-18 11:27:09 -05:00
parent 5bada378be
commit a758749ca9
2 changed files with 32 additions and 31 deletions

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

@ -30,7 +30,8 @@ export const index = new Elysia()
}); });
} }
}) })
.get("/test", async ({ html }) => { .get("/test", async ({ html, log }) => {
log.info("test");
const time = await cachedGetTime(); const time = await cachedGetTime();
return html(() => <p>{time}</p>); return html(() => <p>{time}</p>);
}) })