@devmoods/express-extras 0.65.0 → 0.66.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/dist/auth/emailAndPassword.js +4 -4
- package/dist/auth/errors.d.ts +2 -2
- package/dist/auth/errors.js +4 -4
- package/dist/auth/google.js +2 -2
- package/dist/auth/passwordless.js +1 -1
- package/dist/auth/token.js +3 -1
- package/dist/auth/tokenStorage.d.ts +16 -0
- package/dist/auth/tokenStorage.js +44 -0
- package/dist/auth/types.d.ts +1 -3
- package/dist/auth.d.ts +7 -15
- package/dist/auth.js +29 -41
- package/dist/channels.d.ts +19 -1
- package/dist/channels.js +23 -34
- package/dist/composeMiddleware.d.ts +15 -0
- package/dist/composeMiddleware.js +63 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.js +3 -0
- package/dist/context.d.ts +4 -0
- package/dist/context.js +8 -0
- package/dist/csrf.d.ts +1 -0
- package/dist/csrf.js +6 -2
- package/dist/errors.d.ts +7 -7
- package/dist/errors.js +11 -11
- package/dist/faktory.d.ts +13 -11
- package/dist/faktory.js +6 -6
- package/dist/listen.d.ts +18 -9
- package/dist/listen.js +64 -38
- package/dist/logger.d.ts +23 -4
- package/dist/logger.js +65 -45
- package/dist/manage.d.ts +2 -2
- package/dist/manage.js +12 -12
- package/dist/middleware.d.ts +4 -2
- package/dist/middleware.js +10 -3
- package/dist/rate-limit.d.ts +14 -4
- package/dist/rate-limit.js +10 -5
- package/dist/redis.d.ts +0 -3
- package/dist/redis.js +0 -23
- package/dist/router.js +1 -1
- package/dist/routes.d.ts +5 -4
- package/dist/routes.js +34 -23
- package/dist/sentry.js +5 -3
- package/dist/streams.d.ts +7 -0
- package/dist/streams.js +29 -0
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +0 -8
- package/dist/validate.d.ts +33 -12
- package/dist/validate.js +6 -1
- package/dist/vite/defineViteConfig.js +1 -0
- package/dist/vite/ssr.d.ts +20 -1
- package/dist/vite/ssr.js +6 -1
- package/dist/vitest/matchers.d.ts +4 -0
- package/dist/vitest/matchers.js +17 -2
- package/dist/vitest/testClient.d.ts +1 -0
- package/package.json +18 -20
package/dist/vite/ssr.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { config } from '@devmoods/config';
|
|
4
|
-
import {} from 'compose-middleware';
|
|
5
4
|
import express, {} from 'express';
|
|
6
5
|
import { createServer as createViteServer } from 'vite';
|
|
6
|
+
import {} from '../composeMiddleware.js';
|
|
7
7
|
import {} from './types.js';
|
|
8
8
|
import { generateCsrfToken } from '../csrf.js';
|
|
9
9
|
import { composeMiddleware, route, useCspNonce } from '../middleware.js';
|
|
10
10
|
import { createFetchRequest } from '../webapi.js';
|
|
11
|
+
/**
|
|
12
|
+
* Returns a middleware for setting up SSR using Vite middleware mode.
|
|
13
|
+
*
|
|
14
|
+
* See more: https://vite.dev/guide/ssr
|
|
15
|
+
*/
|
|
11
16
|
export async function createSsrMiddleware({ root = process.cwd(), getInitialData, useDevServer = config.VITE_USE_DEV_SERVER, } = {}) {
|
|
12
17
|
const resolve = (p) => path.resolve(root, p);
|
|
13
18
|
let vite;
|
|
@@ -6,6 +6,10 @@ interface CustomMatchers<R = unknown> {
|
|
|
6
6
|
declare module 'vitest' {
|
|
7
7
|
interface Matchers<T = any> extends CustomMatchers<T> {
|
|
8
8
|
}
|
|
9
|
+
interface Assertion<T = any> extends CustomMatchers<Promise<void>> {
|
|
10
|
+
}
|
|
11
|
+
interface AsymmetricMatchersContaining extends CustomMatchers {
|
|
12
|
+
}
|
|
9
13
|
}
|
|
10
14
|
export { failOnConsole };
|
|
11
15
|
export declare function extendMatchers(expect: ExpectStatic): void;
|
package/dist/vitest/matchers.js
CHANGED
|
@@ -4,7 +4,7 @@ export { failOnConsole };
|
|
|
4
4
|
/* c8 ignore start */
|
|
5
5
|
export function extendMatchers(expect) {
|
|
6
6
|
expect.extend({
|
|
7
|
-
toMatchResponse(received, expectedStatusCode, expectedBody) {
|
|
7
|
+
async toMatchResponse(received, expectedStatusCode, expectedBody) {
|
|
8
8
|
const { isNot } = this;
|
|
9
9
|
// Check if received is a proper response object
|
|
10
10
|
if (!received ||
|
|
@@ -17,7 +17,21 @@ export function extendMatchers(expect) {
|
|
|
17
17
|
}
|
|
18
18
|
const response = 'response' in received ? received.response : received;
|
|
19
19
|
const status = response.status;
|
|
20
|
-
const
|
|
20
|
+
const getBody = () => {
|
|
21
|
+
if (response.headers &&
|
|
22
|
+
response.headers.get('content-type')?.includes('application/json')) {
|
|
23
|
+
if ('jsonData' in response && response.jsonData !== undefined) {
|
|
24
|
+
return response.jsonData;
|
|
25
|
+
}
|
|
26
|
+
return response.clone().json();
|
|
27
|
+
}
|
|
28
|
+
if (response.headers &&
|
|
29
|
+
response.headers.get('content-type')?.startsWith('text/')) {
|
|
30
|
+
return response.clone().text();
|
|
31
|
+
}
|
|
32
|
+
return response.body;
|
|
33
|
+
};
|
|
34
|
+
const body = await getBody();
|
|
21
35
|
// Check status code
|
|
22
36
|
const statusMatches = status === expectedStatusCode;
|
|
23
37
|
// Check body (if provided)
|
|
@@ -48,6 +62,7 @@ export function extendMatchers(expect) {
|
|
|
48
62
|
message += bodyMessage;
|
|
49
63
|
}
|
|
50
64
|
return {
|
|
65
|
+
actual: response,
|
|
51
66
|
pass,
|
|
52
67
|
message: () => {
|
|
53
68
|
if (pass && isNot) {
|
|
@@ -2,6 +2,7 @@ import { type Server } from 'node:http';
|
|
|
2
2
|
import { type FetchClientOptions } from '@devmoods/fetch';
|
|
3
3
|
import { type Application } from 'express';
|
|
4
4
|
import * as tough from 'tough-cookie';
|
|
5
|
+
export type TestClient = Awaited<ReturnType<typeof createTestClient>>;
|
|
5
6
|
export declare function createTestClient(server: Server | Application, options?: FetchClientOptions): Promise<{
|
|
6
7
|
duplicate(): Promise</*elided*/ any>;
|
|
7
8
|
cookieJar: tough.CookieJar;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devmoods/express-extras",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.66.0",
|
|
4
4
|
"description": "Kubernetes-ready utilities for rapid Node.js application development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -60,45 +60,43 @@
|
|
|
60
60
|
],
|
|
61
61
|
"license": "ISC",
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@
|
|
64
|
-
"@vitejs/plugin-react": "^5.0.3",
|
|
63
|
+
"@vitejs/plugin-react": "^5.0.4",
|
|
65
64
|
"arktype": "^2.1.22",
|
|
66
65
|
"faktory-worker": "^4.7.1",
|
|
67
|
-
"react": "^19.
|
|
68
|
-
"react-dom": "^19.
|
|
69
|
-
"vite": "^7.1.
|
|
66
|
+
"react": "^19.2.0",
|
|
67
|
+
"react-dom": "^19.2.0",
|
|
68
|
+
"vite": "^7.1.9"
|
|
70
69
|
},
|
|
71
70
|
"dependencies": {
|
|
72
|
-
"@devmoods/config": "0.
|
|
71
|
+
"@devmoods/config": "0.2.0",
|
|
73
72
|
"@devmoods/fetch": "^4.2.0",
|
|
74
73
|
"@devmoods/observability": "0.1.1",
|
|
75
|
-
"@devmoods/postgres": "0.
|
|
76
|
-
"@hey-api/openapi-ts": "^0.
|
|
77
|
-
"@sentry/node": "^10.
|
|
78
|
-
"@sentry/node-native": "^10.
|
|
79
|
-
"@sentry/profiling-node": "^10.
|
|
74
|
+
"@devmoods/postgres": "0.2.0",
|
|
75
|
+
"@hey-api/openapi-ts": "^0.85.1",
|
|
76
|
+
"@sentry/node": "^10.19.0",
|
|
77
|
+
"@sentry/node-native": "^10.19.0",
|
|
78
|
+
"@sentry/profiling-node": "^10.19.0",
|
|
80
79
|
"@standard-schema/spec": "^1.0.0",
|
|
81
80
|
"@types/bcrypt": "^6.0.0",
|
|
82
81
|
"@types/cookie-parser": "^1.4.9",
|
|
83
82
|
"@types/express": "^5.0.3",
|
|
84
83
|
"@types/jsonwebtoken": "^9.0.10",
|
|
85
|
-
"@types/
|
|
84
|
+
"@types/koa-compose": "^3.2.8",
|
|
85
|
+
"@types/nodemailer": "^7.0.2",
|
|
86
86
|
"@types/qs": "^6.14.0",
|
|
87
|
-
"@types/superagent": "^8.1.9",
|
|
88
87
|
"ajv": "^8.17.1",
|
|
89
88
|
"argon2": "^0.44.0",
|
|
90
89
|
"bcrypt": "^6.0.0",
|
|
91
90
|
"chalk": "^5.6.2",
|
|
92
91
|
"commander": "^14.0.1",
|
|
93
|
-
"compose-middleware": "^5.0.1",
|
|
94
92
|
"cookie-parser": "^1.4.7",
|
|
95
|
-
"dotenv": "^17.2.
|
|
93
|
+
"dotenv": "^17.2.3",
|
|
96
94
|
"express": "^4.21.2",
|
|
97
|
-
"google-auth-library": "^10.
|
|
95
|
+
"google-auth-library": "^10.4.0",
|
|
98
96
|
"helmet": "^8.1.0",
|
|
99
97
|
"jsonwebtoken": "^9.0.2",
|
|
100
|
-
"nodemailer": "^7.0.
|
|
101
|
-
"redis": "^5.8.
|
|
98
|
+
"nodemailer": "^7.0.9",
|
|
99
|
+
"redis": "^5.8.3",
|
|
102
100
|
"sonda": "^0.9.0",
|
|
103
101
|
"tough-cookie": "^6.0.0",
|
|
104
102
|
"uuid": "^13.0.0",
|
|
@@ -114,5 +112,5 @@
|
|
|
114
112
|
"engines": {
|
|
115
113
|
"node": ">=20 <25"
|
|
116
114
|
},
|
|
117
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "b5f134aecebb1937c1aba9403d0e35c9504aeaa3"
|
|
118
116
|
}
|