- Remove Bunserver and just use buns type
All checks were successful
Code quality checks / biome (push) Successful in 10s

- Stop logging every start aswell as available routes
This commit is contained in:
creations 2025-06-03 21:03:28 -04:00
parent 69f0c3d8e9
commit 2eebc3126a
Signed by: creations
GPG key ID: 8F553AA4320FC711
5 changed files with 18 additions and 21 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
/node_modules
bun.lock
robots.txt
logs
public/custom
.env

View file

@ -1,5 +1,5 @@
import { resolve } from "node:path";
import { echo } from "@atums/echo";
import { Echo, echo } from "@atums/echo";
import { environment } from "@config";
import {
type BunFile,
@ -37,12 +37,15 @@ class ServerHandler {
},
});
echo.info(`Server running at http://${server.hostname}:${server.port}`);
const echoChild = new Echo({ disableFile: true });
this.logRoutes();
echoChild.info(
`Server running at http://${server.hostname}:${server.port}`,
);
this.logRoutes(echoChild);
}
private logRoutes(): void {
private logRoutes(echo: Echo): void {
echo.info("Available routes:");
const sortedRoutes: [string, string][] = Object.entries(
@ -122,7 +125,7 @@ class ServerHandler {
private async handleRequest(
request: Request,
server: BunServer,
server: Server,
): Promise<Response> {
const extendedRequest: ExtendedRequest = request as ExtendedRequest;
extendedRequest.startPerf = performance.now();

14
types/bun.d.ts vendored
View file

@ -1,14 +0,0 @@
import type { Server } from "bun";
type Query = Record<string, string>;
type Params = Record<string, string>;
declare global {
type BunServer = Server;
interface ExtendedRequest extends Request {
startPerf: number;
query: Query;
params: Params;
}
}

2
types/routes.d.ts vendored
View file

@ -9,7 +9,7 @@ type RouteModule = {
handler: (
request: Request | ExtendedRequest,
requestBody: unknown,
server: BunServer,
server: Server,
) => Promise<Response> | Response;
routeDef: RouteDef;
};

8
types/server.d.ts vendored Normal file
View file

@ -0,0 +1,8 @@
type Query = Record<string, string>;
type Params = Record<string, string>;
interface ExtendedRequest extends Request {
startPerf: number;
query: Query;
params: Params;
}