Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #94 Type support for http-logger added #178

Merged
merged 12 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"prettier": "3.2.5"
},
"engines": {
"node": ">=14.0.0"
},
"packageManager": "[email protected]"
"node": ">=14.0.0",
"pnpm": ">=7.5.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I searched a bit since I haven't seen pnpm being used here before, I found a few issues saying that this isn't supported, is it possible for you to see if it works right now, maybe try installing an older version of pnpm in a codespace and try pnpm i

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will try.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be working fine.

image

}
}
68 changes: 36 additions & 32 deletions packages/http-logger/package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
{
"name": "@sliit-foss/http-logger",
"version": "1.3.1",
"description": "Http logging middleware for Express.js",
"main": "dist/index.js",
"scripts": {
"build": "node ../../scripts/esbuild.config.js",
"build:watch": "bash ../../scripts/esbuild.watch.sh",
"bump-version": "bash ../../scripts/bump-version.sh --name=@sliit-foss/http-logger",
"lint": "bash ../../scripts/lint.sh",
"release": "bash ../../scripts/release.sh",
"test": "bash ../../scripts/test/test.sh"
},
"dependencies": {
"@sliit-foss/module-logger": "1.3.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sliit-foss/npm-catalogue.git"
},
"homepage": "https://github.com/sliit-foss/npm-catalogue/blob/main/packages/http-logger/readme.md",
"keywords": [
"logging",
"http-logging",
"middleware"
],
"author": "SLIIT FOSS",
"license": "MIT",
"bugs": {
"url": "https://github.com/sliit-foss/npm-catalogue/issues"
}
}
{
"name": "@sliit-foss/http-logger",
"version": "1.3.1",
"description": "Http logging middleware for Express.js",
"main": "dist/index.js",
"types": "types/index.d.ts",
"scripts": {
"build": "node ../../scripts/esbuild.config.js",
"build:watch": "bash ../../scripts/esbuild.watch.sh",
"bump-version": "bash ../../scripts/bump-version.sh --name=@sliit-foss/http-logger",
"lint": "bash ../../scripts/lint.sh",
"release": "bash ../../scripts/release.sh",
"test": "bash ../../scripts/test/test.sh"
},
"dependencies": {
"@sliit-foss/module-logger": "1.3.1"
},
"peerDependencies": {
"express": "*"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sliit-foss/npm-catalogue.git"
},
"homepage": "https://github.com/sliit-foss/npm-catalogue/blob/main/packages/http-logger/readme.md",
"keywords": [
"logging",
"http-logging",
"middleware"
],
"author": "SLIIT FOSS",
"license": "MIT",
"bugs": {
"url": "https://github.com/sliit-foss/npm-catalogue/issues"
}
}
7 changes: 4 additions & 3 deletions packages/http-logger/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ app.use(httpLogger({
}));

// or
import { pick, omit} from 'loadash';

app.use(httpLogger({
whitelists: ["/public/*"],
loggable: ({headers, body} => {
loggable: ( (req) => {
// Pick the properties you want to log
return {
headers,
body
headers: pick(req.headers, ['x-user-email', 'user-agent']),
payload: omit(req.body, ['password', 'new_password', 'old_password'])
}
}),
}));
Expand Down
2 changes: 1 addition & 1 deletion packages/http-logger/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const httpLogger =
if (Array.isArray(loggable)) {
additionalInfo = generateInfoObject(req, loggable);
} else {
additionalInfo = loggable({ headers: req.headers, body: req.body });
additionalInfo = loggable(req);
}
}

Expand Down
18 changes: 18 additions & 0 deletions packages/http-logger/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { RequestHandler, Request } from "express";

/**
* @description Options for logging middleware function
*/
type HttpLoggerOptions = {
whitelists?: string[];
loggable?: string[] | ((req: Request) => object);
};

/**
* @description Creates a HTTP logging middleware for Express.js
* @param {HttpLoggerOptions} options Add options to customize logging
* @returns {RequestHandler} A middleware function which will log http requests
*/
declare const httpLogger: (options: HttpLoggerOptions) => RequestHandler;

export default httpLogger;
2 changes: 1 addition & 1 deletion packages/mongoose-filter-query/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const mongooseFilterQuery = (req, res, next) => {
}
req.query.include = req.query.include?.split(",");
req.query.select = req.query.select?.split(",")?.join(" ");
req.query.prepaginate = req.query.prepaginate === "true"
req.query.prepaginate = req.query.prepaginate === "true";
} catch (e) {
console.error("[ FilterQuery ] - Failed to parse query", e);
}
Expand Down
96 changes: 48 additions & 48 deletions plugins/mongoose-aggregate-paginate-v2/package.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
{
"name": "@sliit-foss/mongoose-aggregate-paginate-v2",
"version": "1.0.0",
"description": "A cursor based custom aggregate pagination library for Mongoose with customizable labels.",
"main": "dist/index.js",
"types": "types/index.d.ts",
"scripts": {
"build": "node ../../scripts/esbuild.config.js",
"build:watch": "bash ../../scripts/esbuild.watch.sh",
"bump-version": "bash ../../scripts/bump-version.sh --name=@sliit-foss/express-http-context",
"lint": "bash ../../scripts/lint.sh",
"release": "bash ../../scripts/release.sh",
"test": "if [ \"$CI\" = \"true\" ]; then \n bash ../../scripts/test/test.sh; else \n echo \"Skipping as it is not a CI environemnt\"; fi"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sliit-foss/npm-catalogue.git"
},
"keywords": [
"aggregate",
"aggregate-paginate",
"aggregate-pagination",
"mongoose-aggregate",
"mongoose",
"pagination",
"plugin",
"mongodb",
"paginate",
"paging",
"next",
"prev",
"nextpage",
"prevpage",
"total",
"paginator",
"plugin"
],
"author": "SLIIT FOSS",
"license": "MIT",
"bugs": {
"url": "https://github.com/sliit-foss/npm-catalogue/issues"
},
"homepage": "https://github.com/sliit-foss/npm-catalogue/blob/main/plugins/mongoose-aggregate-paginate-v2#readme",
"peerDependencies": {
"mongoose": ">=7.0.0"
},
"engines": {
"node": ">=4.0.0"
}
"name": "@sliit-foss/mongoose-aggregate-paginate-v2",
"version": "1.0.0",
"description": "A cursor based custom aggregate pagination library for Mongoose with customizable labels.",
"main": "dist/index.js",
"types": "types/index.d.ts",
"scripts": {
"build": "node ../../scripts/esbuild.config.js",
"build:watch": "bash ../../scripts/esbuild.watch.sh",
"bump-version": "bash ../../scripts/bump-version.sh --name=@sliit-foss/express-http-context",
"lint": "bash ../../scripts/lint.sh",
"release": "bash ../../scripts/release.sh",
"test": "if [ \"$CI\" = \"true\" ]; then \n bash ../../scripts/test/test.sh; else \n echo \"Skipping as it is not a CI environemnt\"; fi"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sliit-foss/npm-catalogue.git"
},
"keywords": [
"aggregate",
"aggregate-paginate",
"aggregate-pagination",
"mongoose-aggregate",
"mongoose",
"pagination",
"plugin",
"mongodb",
"paginate",
"paging",
"next",
"prev",
"nextpage",
"prevpage",
"total",
"paginator",
"plugin"
],
"author": "SLIIT FOSS",
"license": "MIT",
"bugs": {
"url": "https://github.com/sliit-foss/npm-catalogue/issues"
},
"homepage": "https://github.com/sliit-foss/npm-catalogue/blob/main/plugins/mongoose-aggregate-paginate-v2#readme",
"peerDependencies": {
"mongoose": ">=7.0.0"
},
"engines": {
"node": ">=4.0.0"
}
}
Loading
Loading