mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
Add server hooks for pre and post serve
This commit is contained in:
parent
795fcd3694
commit
c66e1ac146
9
index.ts
9
index.ts
|
|
@ -10,6 +10,9 @@ import { APIRouteMeta } from "~types/api";
|
||||||
import { mkdir } from "fs/promises";
|
import { mkdir } from "fs/promises";
|
||||||
import { client } from "~database/datasource";
|
import { client } from "~database/datasource";
|
||||||
import { PrismaClientInitializationError } from "@prisma/client/runtime/library";
|
import { PrismaClientInitializationError } from "@prisma/client/runtime/library";
|
||||||
|
import { HookTypes, Server } from "~plugins/types";
|
||||||
|
|
||||||
|
const server = new Server();
|
||||||
|
|
||||||
const router = new Bun.FileSystemRouter({
|
const router = new Bun.FileSystemRouter({
|
||||||
style: "nextjs",
|
style: "nextjs",
|
||||||
|
|
@ -18,6 +21,8 @@ const router = new Bun.FileSystemRouter({
|
||||||
|
|
||||||
console.log(`${chalk.green(`>`)} ${chalk.bold("Starting Lysand...")}`);
|
console.log(`${chalk.green(`>`)} ${chalk.bold("Starting Lysand...")}`);
|
||||||
|
|
||||||
|
server.emit(HookTypes.PreServe);
|
||||||
|
|
||||||
const config = getConfig();
|
const config = getConfig();
|
||||||
const requests_log = Bun.file(process.cwd() + "/logs/requests.log");
|
const requests_log = Bun.file(process.cwd() + "/logs/requests.log");
|
||||||
|
|
||||||
|
|
@ -180,3 +185,7 @@ console.log(
|
||||||
`Serving ${chalk.blue(postCount)} posts`
|
`Serving ${chalk.blue(postCount)} posts`
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
server.emit(HookTypes.PostServe, {
|
||||||
|
postCount,
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue