From b8081ce046f7fd16eb5b9878d48ed3f351136a30 Mon Sep 17 00:00:00 2001 From: Drew DeCarme Date: Sat, 4 Nov 2023 15:59:24 -0400 Subject: [PATCH] feat: Add `name` to Route --- .changeset/six-beers-know.md | 5 +++++ packages/core/src/route/Route.ts | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/six-beers-know.md diff --git a/.changeset/six-beers-know.md b/.changeset/six-beers-know.md new file mode 100644 index 0000000..9395a29 --- /dev/null +++ b/.changeset/six-beers-know.md @@ -0,0 +1,5 @@ +--- +"@flare-city/core": minor +--- + +Adds required route constructor param `name` to better identify logs diff --git a/packages/core/src/route/Route.ts b/packages/core/src/route/Route.ts index a27d346..61211b9 100644 --- a/packages/core/src/route/Route.ts +++ b/packages/core/src/route/Route.ts @@ -18,10 +18,12 @@ import type { interface RouteConstructorParams { root: string; + name: string; } export class Route implements RouteConstructorParams { root: string; + name: string; private requests: { GET: RouteGET[]; POST: RoutePOST[]; @@ -32,6 +34,7 @@ export class Route implements RouteConstructorParams { constructor(params: RouteConstructorParams) { this.root = params.root; + this.name = params.name; this.requests = { GET: [], POST: [], @@ -299,6 +302,8 @@ export class Route implements RouteConstructorParams { // this should never happen... this is just to appease TS if (!this.matchedRoute) return; + log.setName(`FlareCity - Route:${this.name}`); + // Return instantiated route.handler return this.matchedRoute.route.handler( request,