Skip to content

Commit

Permalink
Fix npm audit warnings (#175)
Browse files Browse the repository at this point in the history
* bump node

* bump pug

* fix test

* remove forwarded

* bump express deps

* link to kong fork

* lint fix

* use @idio/dicer

* formatter

* bump biome

* add audit

* level
  • Loading branch information
jackkav authored Jun 28, 2024
1 parent 9d25b99 commit a92b3b3
Show file tree
Hide file tree
Showing 17 changed files with 411 additions and 1,152 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ jobs:
- run: npm ci
- uses: biomejs/setup-biome@v2
- run: biome ci .
- run: npm test
- run: npm test
- run: npm audit --audit-level=moderate
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["biomejs.biome"]
}
9 changes: 7 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true
"editor.formatOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
}
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:21.6.2-bullseye-slim
FROM node:22-bullseye-slim

RUN apt-get update && apt-get install -y --no-install-recommends dumb-init
ENV NODE_ENV production
Expand Down
6 changes: 1 addition & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ const express = require("express");
const mw = require("./middleware");
const routes = require("./routes");

module.exports = function router(options) {
module.exports = function (options) {
const router = express.Router();

const defaults = [
mw.forwarded,
mw.errorHandler,
mw.bodyParser,
null,
mw.cors,
mw.poweredBy,
mw.negotiateContent,
Expand All @@ -19,14 +17,12 @@ module.exports = function router(options) {
const endpoints = [
{ action: "get", path: "/", route: routes.hello },
{ action: "all", path: "/ip", route: routes.ips.one },
{ action: "all", path: "/ips", route: routes.ips.all },
{ action: "all", path: "/agent", route: routes.headers.agent },
{ action: "all", path: "/status/:code/:reason?", route: routes.status },
{ action: "all", path: "/headers", route: routes.headers.all },
{ action: "all", path: "/header/:name", route: routes.headers.one },
{ action: "all", path: "/header/:name/:value", route: routes.headers.set },
{ action: "all", path: "/cookies", route: routes.cookies.all },
{ action: "all", path: "/forwarded", route: routes.forwarded },
{ action: "all", path: "/cookie/:name", route: routes.cookies.one },
{ action: "all", path: "/cookie/:name/:value", route: routes.cookies.set },
{
Expand Down
2 changes: 1 addition & 1 deletion lib/middleware/body-parser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Dicer = require("dicer");
const Dicer = require("@idio/dicer");
const querystring = require("node:querystring");
const contentTypeParser = require("content-type");
const util = require("../utils");
Expand Down
3 changes: 0 additions & 3 deletions lib/middleware/forwarded.js

This file was deleted.

1 change: 0 additions & 1 deletion lib/routes/bins.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ module.exports = function bins(dsnStr) {
const router = express.Router();

const defaults = [
mw.forwarded,
mw.errorHandler,
mw.bodyParser,
null,
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/delay.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function delay(req, res, next) {
module.exports = function (req, res, next) {
let delay = req.params.ms ? Number.parseInt(req.params.ms, 10) : 200;

if (delay > 60000) {
Expand Down
5 changes: 0 additions & 5 deletions lib/routes/forwarded.js

This file was deleted.

6 changes: 0 additions & 6 deletions lib/routes/ips.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,4 @@ module.exports = {

next();
},

all: function allIPs(req, res, next) {
res.body = req.forwarded.for;

next();
},
};
4 changes: 2 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const utils = {
clientIPAddress: req.ip,
request: {
method: req.method,
url: `${req.forwarded.proto}://${req.hostname}${req.originalUrl}`,
url: `${req.protocol}://${req.hostname}${req.originalUrl}`,
httpVersion: "HTTP/1.1",
// TODO, add cookie details
cookies: utils.objectToArray(req.cookies),
Expand All @@ -76,7 +76,7 @@ const utils = {
startedDateTime: new Date().toISOString(),
clientIPAddress: req.ip,
method: req.method,
url: `${req.forwarded.proto}://${req.hostname}${req.originalUrl}`,
url: `${req.protocol}://${req.hostname}${req.originalUrl}`,
httpVersion: "HTTP/1.1",
// TODO, add cookie details
cookies: req.cookies,
Expand Down
Loading

0 comments on commit a92b3b3

Please sign in to comment.