Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
denwilliams committed Sep 10, 2024
1 parent a94d02d commit a01600a
Show file tree
Hide file tree
Showing 6 changed files with 966 additions and 352 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@ on:
- master

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run lint

build:
strategy:
matrix:
prom-client-version: [11, 12, 13, 14]
prom-client-version: [11, 12, 13, 14, 15]
runs-on: ubuntu-latest
name: Build with Prom Client ${{matrix.prom-client-version}}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
- run: npm ci
- run: npm i -D prom-client@${{matrix.prom-client-version}}
- run: npm run build
9 changes: 4 additions & 5 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
- run: npm ci
# - run: npm test
- uses: JS-DevTools/npm-publish@v1
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
15 changes: 7 additions & 8 deletions middleware/router.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join as joinPath } from "path";
import pathToRegexp from "path-to-regexp";
import { pathToRegexp, Key } from "path-to-regexp";
import { parse as parseUrl } from "url";

import { IncomingMessage, ServerResponse } from "http";
Expand All @@ -25,11 +25,11 @@ interface Route<Req, Res> {

interface PopulatedRoute<Req, Res> extends Route<Req, Res> {
regexp: RegExp;
keys: pathToRegexp.Key[];
keys: Key[];
}

export class Router<Req extends IncomingMessage, Res extends ServerResponse> {
routes: Array<Route<Req, Res>>;
routes: Route<Req, Res>[];

constructor() {
this.routes = [];
Expand Down Expand Up @@ -86,9 +86,8 @@ export class Router<Req extends IncomingMessage, Res extends ServerResponse> {

createHandler() {
// TODO: time routing, it's pretty dumb.
const parsedRoutes: Array<PopulatedRoute<Req, Res>> = this.routes.map(r => {
const keys: pathToRegexp.Key[] = [];
const regexp = pathToRegexp(r.routePath, keys);
const parsedRoutes: PopulatedRoute<Req, Res>[] = this.routes.map((r) => {
const { keys, regexp } = pathToRegexp(r.routePath);

return Object.assign({}, r, { regexp, keys });
});
Expand Down Expand Up @@ -148,10 +147,10 @@ function handleMatch<Req extends IncomingMessage, Res extends ServerResponse>(
return route.handler({
req: reqPlusPath as Req & { routePath: string },
res,
params
params,
});
})
.catch(err => next(err));
.catch((err) => next(err));
}

function decodeParam(value?: string): string | undefined {
Expand Down
Loading

0 comments on commit a01600a

Please sign in to comment.