Skip to content

Commit

Permalink
feat: Add name to Route
Browse files Browse the repository at this point in the history
  • Loading branch information
drewdecarme committed Nov 4, 2023
1 parent 13af28b commit b8081ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-beers-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@flare-city/core": minor
---

Adds required route constructor param `name` to better identify logs
5 changes: 5 additions & 0 deletions packages/core/src/route/Route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -32,6 +34,7 @@ export class Route implements RouteConstructorParams {

constructor(params: RouteConstructorParams) {
this.root = params.root;
this.name = params.name;
this.requests = {
GET: [],
POST: [],
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b8081ce

Please sign in to comment.