@saasquatch/express-boilerplate 2.0.1-6 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<h1 align="center">@saasquatch/express-boilerplate</h1>
|
|
2
2
|
|
|
3
|
-
The SaaSquatch
|
|
3
|
+
The SaaSquatch express boilerplate package provides a number of middleware and utility
|
|
4
4
|
functions that are useful in Express apps, particularly those running in Kubernetes
|
|
5
5
|
environments.
|
|
6
6
|
|
|
@@ -44,7 +44,7 @@ server.listen(3000, () => baseLogger.notice("App listening on port 3000"));
|
|
|
44
44
|
## Graceful Shutdown Manager
|
|
45
45
|
|
|
46
46
|
The `installShutdownManager` function installs the OS signal handlers for `SIGINT` and
|
|
47
|
-
`SIGTERM` to
|
|
47
|
+
`SIGTERM` to shut down the server in a graceful way that is compatible with Kubernetes
|
|
48
48
|
best practices. It is also used to configure the TCP Keep-Alive timeouts for the server,
|
|
49
49
|
which may be necessary for certain cloud load balancers.
|
|
50
50
|
|
|
@@ -85,11 +85,11 @@ const server = installShutdownManager(app, logger, {
|
|
|
85
85
|
server.listen(3000, () => logger.notice("App listening on port 3000"));
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
##
|
|
88
|
+
## Request ID and Logger Middleware
|
|
89
89
|
|
|
90
90
|
The `requestIdAndLogger` middleware function generates a random request ID using `nanoid`
|
|
91
91
|
and sets the `res.locals.requestId` and `res.locals.logger` variables. These can be used
|
|
92
|
-
in the subsequent request handlers to generate log events with the
|
|
92
|
+
in the subsequent request handlers to generate log events with the request ID
|
|
93
93
|
automatically attached.
|
|
94
94
|
|
|
95
95
|
```typescript
|
|
@@ -111,7 +111,7 @@ app.get("/testing", (req, res) => {
|
|
|
111
111
|
|
|
112
112
|
The `asyncHandlerWrapper` function wraps an async request handler to automatically catch
|
|
113
113
|
any rejected promises, log the error, and return an appropriate response. Without this
|
|
114
|
-
function the default behavior is for unhandled promise rejections to crash the
|
|
114
|
+
function, the default behavior is for unhandled promise rejections to crash the
|
|
115
115
|
application, which is obviously unwanted.
|
|
116
116
|
|
|
117
117
|
This function requires that the `requestIdAndLogger` middleware function is installed.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saasquatch/express-boilerplate",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Boilerplate middleware and functions for building Express apps on Kubernetes",
|
|
6
6
|
"homepage": "https://github.com/saasquatch/program-tools/packages/express-boilerplate#readme",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"nanoid": "^6.0.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@saasquatch/logger": "^
|
|
38
|
+
"@saasquatch/logger": "^4.0.0",
|
|
39
39
|
"@types/express": "4",
|
|
40
40
|
"@types/node": "^24.12.4",
|
|
41
41
|
"@types/supertest": "^7.2.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typescript": "^7.0.2"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@saasquatch/logger": "^
|
|
49
|
+
"@saasquatch/logger": "^4.0.0",
|
|
50
50
|
"express": "^4.0.0"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|