@devmoods/express-extras 0.46.0 → 0.47.1
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 → src/auth}/passwordless.d.ts +1 -3
- package/dist/src/config.d.ts +38 -0
- package/dist/{config.js → src/config.js} +9 -2
- package/dist/{index.d.ts → src/index.d.ts} +2 -0
- package/dist/{index.js → src/index.js} +2 -0
- package/dist/{middleware.d.ts → src/middleware.d.ts} +2 -0
- package/dist/{middleware.js → src/middleware.js} +1 -0
- package/dist/src/vite/defineViteConfig.d.ts +6 -0
- package/dist/src/vite/defineViteConfig.js +53 -0
- package/dist/src/vite/ssr.d.ts +7 -0
- package/dist/src/vite/ssr.js +120 -0
- package/dist/src/vite/types.d.ts +12 -0
- package/dist/src/vite/types.js +1 -0
- package/dist/src/vite.d.ts +1 -0
- package/dist/src/vite.js +1 -0
- package/dist/src/webapi.d.ts +3 -0
- package/dist/src/webapi.js +44 -0
- package/package.json +12 -3
- package/dist/config.d.ts +0 -19
- /package/dist/{__tests__ → src/__tests__}/__migrations__/1_a.d.ts +0 -0
- /package/dist/{__tests__ → src/__tests__}/__migrations__/1_a.js +0 -0
- /package/dist/{auth → src/auth}/emailAndPassword.d.ts +0 -0
- /package/dist/{auth → src/auth}/emailAndPassword.js +0 -0
- /package/dist/{auth → src/auth}/errors.d.ts +0 -0
- /package/dist/{auth → src/auth}/errors.js +0 -0
- /package/dist/{auth → src/auth}/passwordless.js +0 -0
- /package/dist/{auth → src/auth}/token.d.ts +0 -0
- /package/dist/{auth → src/auth}/token.js +0 -0
- /package/dist/{auth → src/auth}/types.d.ts +0 -0
- /package/dist/{auth → src/auth}/types.js +0 -0
- /package/dist/{auth.d.ts → src/auth.d.ts} +0 -0
- /package/dist/{auth.js → src/auth.js} +0 -0
- /package/dist/{cache.d.ts → src/cache.d.ts} +0 -0
- /package/dist/{cache.js → src/cache.js} +0 -0
- /package/dist/{cli.d.ts → src/cli.d.ts} +0 -0
- /package/dist/{cli.js → src/cli.js} +0 -0
- /package/dist/{context.d.ts → src/context.d.ts} +0 -0
- /package/dist/{context.js → src/context.js} +0 -0
- /package/dist/{csrf.d.ts → src/csrf.d.ts} +0 -0
- /package/dist/{csrf.js → src/csrf.js} +0 -0
- /package/dist/{email.d.ts → src/email.d.ts} +0 -0
- /package/dist/{email.js → src/email.js} +0 -0
- /package/dist/{errors.d.ts → src/errors.d.ts} +0 -0
- /package/dist/{errors.js → src/errors.js} +0 -0
- /package/dist/{faktory.d.ts → src/faktory.d.ts} +0 -0
- /package/dist/{faktory.js → src/faktory.js} +0 -0
- /package/dist/{listen.d.ts → src/listen.d.ts} +0 -0
- /package/dist/{listen.js → src/listen.js} +0 -0
- /package/dist/{logger.d.ts → src/logger.d.ts} +0 -0
- /package/dist/{logger.js → src/logger.js} +0 -0
- /package/dist/{manage.d.ts → src/manage.d.ts} +0 -0
- /package/dist/{manage.js → src/manage.js} +0 -0
- /package/dist/{migrate.d.ts → src/migrate.d.ts} +0 -0
- /package/dist/{migrate.js → src/migrate.js} +0 -0
- /package/dist/{postgres.d.ts → src/postgres.d.ts} +0 -0
- /package/dist/{postgres.js → src/postgres.js} +0 -0
- /package/dist/{redis.d.ts → src/redis.d.ts} +0 -0
- /package/dist/{redis.js → src/redis.js} +0 -0
- /package/dist/{routes.d.ts → src/routes.d.ts} +0 -0
- /package/dist/{routes.js → src/routes.js} +0 -0
- /package/dist/{sentry.d.ts → src/sentry.d.ts} +0 -0
- /package/dist/{sentry.js → src/sentry.js} +0 -0
- /package/dist/{setupTests.d.ts → src/setupTests.d.ts} +0 -0
- /package/dist/{setupTests.js → src/setupTests.js} +0 -0
- /package/dist/{slack.d.ts → src/slack.d.ts} +0 -0
- /package/dist/{slack.js → src/slack.js} +0 -0
- /package/dist/{utils.d.ts → src/utils.d.ts} +0 -0
- /package/dist/{utils.js → src/utils.js} +0 -0
- /package/dist/{validate.d.ts → src/validate.d.ts} +0 -0
- /package/dist/{validate.js → src/validate.js} +0 -0
|
@@ -3,6 +3,4 @@ export interface PasswordlessAuthProviderOptions<UserModel = AnyUser> {
|
|
|
3
3
|
getUserByEmail(email: string): Promise<UserModel>;
|
|
4
4
|
onLoginRequest(user: UserModel, temporaryToken: string): Promise<void>;
|
|
5
5
|
}
|
|
6
|
-
export declare function PasswordlessAuthProvider<UserModel extends AnyUser
|
|
7
|
-
email: string;
|
|
8
|
-
}>(options: PasswordlessAuthProviderOptions<UserModel>): AuthProvider<UserModel>;
|
|
6
|
+
export declare function PasswordlessAuthProvider<UserModel extends AnyUser>(options: PasswordlessAuthProviderOptions<UserModel>): AuthProvider<UserModel>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const config: {
|
|
2
|
+
extend: <T extends Record<string, unknown>>(appConfig: T) => {
|
|
3
|
+
value: {
|
|
4
|
+
CI: boolean;
|
|
5
|
+
PORT: number;
|
|
6
|
+
AUTH_TOKEN_EXPIRES_IN: number;
|
|
7
|
+
AUTH_TEMP_TOKEN_EXPIRES_IN: number;
|
|
8
|
+
AUTH_SECRET: string;
|
|
9
|
+
REDIS_URL: string;
|
|
10
|
+
POSTGRES_URL: string;
|
|
11
|
+
SENTRY_DSN: string;
|
|
12
|
+
LOG_LEVEL: string;
|
|
13
|
+
LOG_SQL: boolean;
|
|
14
|
+
NODE_ENV: string;
|
|
15
|
+
CSRF_SECRET: string;
|
|
16
|
+
READINESS_PERIOD_MS: number;
|
|
17
|
+
GRACE_PERIOD_MS: number;
|
|
18
|
+
SLACK_WEBHOOK_URL: string;
|
|
19
|
+
} & T;
|
|
20
|
+
};
|
|
21
|
+
value: {
|
|
22
|
+
CI: boolean;
|
|
23
|
+
PORT: number;
|
|
24
|
+
AUTH_TOKEN_EXPIRES_IN: number;
|
|
25
|
+
AUTH_TEMP_TOKEN_EXPIRES_IN: number;
|
|
26
|
+
AUTH_SECRET: string;
|
|
27
|
+
REDIS_URL: string;
|
|
28
|
+
POSTGRES_URL: string;
|
|
29
|
+
SENTRY_DSN: string;
|
|
30
|
+
LOG_LEVEL: string;
|
|
31
|
+
LOG_SQL: boolean;
|
|
32
|
+
NODE_ENV: string;
|
|
33
|
+
CSRF_SECRET: string;
|
|
34
|
+
READINESS_PERIOD_MS: number;
|
|
35
|
+
GRACE_PERIOD_MS: number;
|
|
36
|
+
SLACK_WEBHOOK_URL: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -9,7 +9,7 @@ function lazy(fn) {
|
|
|
9
9
|
// },
|
|
10
10
|
// };
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
const baseConfig = () => ({
|
|
13
13
|
CI: readEnv.boolean('CI', false),
|
|
14
14
|
PORT: readEnv.number('PORT', 0),
|
|
15
15
|
AUTH_TOKEN_EXPIRES_IN: readEnv.number('AUTH_TOKEN_EXPIRES', 3600 * 24 * 30), // 30 days
|
|
@@ -25,4 +25,11 @@ export const config = lazy(() => ({
|
|
|
25
25
|
READINESS_PERIOD_MS: readEnv.number('READINESS_PERIOD_MS', 0),
|
|
26
26
|
GRACE_PERIOD_MS: readEnv.number('GRACE_PERIOD_MS', 20000),
|
|
27
27
|
SLACK_WEBHOOK_URL: readEnv('SLACK_WEBHOOK_URL', ''),
|
|
28
|
-
})
|
|
28
|
+
});
|
|
29
|
+
export const config = {
|
|
30
|
+
...lazy(baseConfig),
|
|
31
|
+
extend: (appConfig) => {
|
|
32
|
+
const base = config.value;
|
|
33
|
+
return lazy(() => ({ ...base, ...appConfig }));
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './auth.js';
|
|
2
2
|
export * from './cache.js';
|
|
3
3
|
export * from './cli.js';
|
|
4
|
+
export * from './config.js';
|
|
4
5
|
export * from './context.js';
|
|
5
6
|
export * from './csrf.js';
|
|
6
7
|
export * from './email.js';
|
|
@@ -17,3 +18,4 @@ export * from './sentry.js';
|
|
|
17
18
|
export * from './slack.js';
|
|
18
19
|
export * from './utils.js';
|
|
19
20
|
export * from './validate.js';
|
|
21
|
+
export * from './webapi.js';
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export * from './auth.js';
|
|
3
3
|
export * from './cache.js';
|
|
4
4
|
export * from './cli.js';
|
|
5
|
+
export * from './config.js';
|
|
5
6
|
export * from './context.js';
|
|
6
7
|
export * from './csrf.js';
|
|
7
8
|
export * from './email.js';
|
|
@@ -18,3 +19,4 @@ export * from './sentry.js';
|
|
|
18
19
|
export * from './slack.js';
|
|
19
20
|
export * from './utils.js';
|
|
20
21
|
export * from './validate.js';
|
|
22
|
+
export * from './webapi.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ServerResponse, type IncomingMessage } from 'node:http';
|
|
2
2
|
import bodyParser from 'body-parser';
|
|
3
|
+
import { compose } from 'compose-middleware';
|
|
3
4
|
import { type NextFunction, type RequestHandler, type Request, type Response } from 'express';
|
|
4
5
|
import { type CsrfMiddlewareOptions } from './csrf.js';
|
|
5
6
|
type UrlencodedParser = typeof bodyParser.urlencoded;
|
|
@@ -7,6 +8,7 @@ type JsonParser = typeof bodyParser.json;
|
|
|
7
8
|
export declare const urlencodedParser: UrlencodedParser;
|
|
8
9
|
export declare const jsonParser: JsonParser;
|
|
9
10
|
export { asyncMiddleware as route };
|
|
11
|
+
export { compose as composeMiddleware };
|
|
10
12
|
type ContentSecurityPolicyDirectiveValue = string | ((req: IncomingMessage, res: ServerResponse) => string);
|
|
11
13
|
export interface BeforeMiddlewareCSPDirectives {
|
|
12
14
|
'script-src': ContentSecurityPolicyDirectiveValue[];
|
|
@@ -14,6 +14,7 @@ export const urlencodedParser = bodyParser.urlencoded;
|
|
|
14
14
|
export const jsonParser = bodyParser.json;
|
|
15
15
|
const logger = getLogger('http');
|
|
16
16
|
export { asyncMiddleware as route };
|
|
17
|
+
export { compose as composeMiddleware };
|
|
17
18
|
const CSP_NONCE_KEY = 'csp-nonce';
|
|
18
19
|
export function useCspNonce() {
|
|
19
20
|
return useContext(CSP_NONCE_KEY) ?? 'fuck';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference types="vitest" />
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import react from '@vitejs/plugin-react';
|
|
4
|
+
import { defineConfig } from 'vite';
|
|
5
|
+
import { readEnv } from '../utils.js';
|
|
6
|
+
export function defineViteConfig({ base = '', reactCompiler = false, ssr = false, }) {
|
|
7
|
+
const port = readEnv.number('VITE_PORT', 5173);
|
|
8
|
+
return defineConfig({
|
|
9
|
+
plugins: [
|
|
10
|
+
react({
|
|
11
|
+
...(reactCompiler
|
|
12
|
+
? {
|
|
13
|
+
babel: {
|
|
14
|
+
plugins: ['babel-plugin-react-compiler'],
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
: {}),
|
|
18
|
+
}),
|
|
19
|
+
],
|
|
20
|
+
base,
|
|
21
|
+
build: {
|
|
22
|
+
chunkSizeWarningLimit: 750,
|
|
23
|
+
manifest: true,
|
|
24
|
+
rollupOptions: {
|
|
25
|
+
input: {
|
|
26
|
+
index: path.resolve(process.cwd(), 'src/entry-client.tsx'),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
server: !ssr
|
|
31
|
+
? {
|
|
32
|
+
host: readEnv('VITE_HOST', '0.0.0.0'),
|
|
33
|
+
port,
|
|
34
|
+
strictPort: true,
|
|
35
|
+
origin: readEnv('VITE_ORIGIN', `http://localhost:${port}`),
|
|
36
|
+
}
|
|
37
|
+
: undefined,
|
|
38
|
+
ssr: {
|
|
39
|
+
noExternal: ['react-helmet-async'],
|
|
40
|
+
},
|
|
41
|
+
test: {
|
|
42
|
+
setupFiles: ['./src/setupTests'],
|
|
43
|
+
include: ['src/**/*.{test,spec}.?(c|m)[jt]s?(x)'],
|
|
44
|
+
},
|
|
45
|
+
css: {
|
|
46
|
+
preprocessorOptions: {
|
|
47
|
+
scss: {
|
|
48
|
+
api: 'modern-compiler',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
export interface SsrMiddleWareOptions {
|
|
3
|
+
root?: string;
|
|
4
|
+
getInitialData?: (req: string) => Promise<unknown>;
|
|
5
|
+
useDevServer?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function createSsrMiddleware({ root, getInitialData, useDevServer, }?: SsrMiddleWareOptions): Promise<express.RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>[]>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import express, {} from 'express';
|
|
4
|
+
import { createServer as createViteServer } from 'vite';
|
|
5
|
+
import {} from './types.js';
|
|
6
|
+
import { route, useCspNonce } from '../middleware.js';
|
|
7
|
+
import { readEnv } from '../utils.js';
|
|
8
|
+
export async function createSsrMiddleware({ root = process.cwd(), getInitialData = async () => ({}), useDevServer = readEnv.boolean('VITE_USE_DEV_SERVER', false), } = {}) {
|
|
9
|
+
const resolve = (p) => path.resolve(root, p);
|
|
10
|
+
let vite;
|
|
11
|
+
const middlewares = [];
|
|
12
|
+
if (useDevServer) {
|
|
13
|
+
vite = await createViteServer({
|
|
14
|
+
root,
|
|
15
|
+
server: { middlewareMode: true },
|
|
16
|
+
appType: 'custom',
|
|
17
|
+
});
|
|
18
|
+
middlewares.push(vite.middlewares);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
middlewares.push(express.static(resolve('dist/client'), { index: false }));
|
|
22
|
+
}
|
|
23
|
+
middlewares.push(route(async (req, res) => {
|
|
24
|
+
try {
|
|
25
|
+
let render;
|
|
26
|
+
if (useDevServer) {
|
|
27
|
+
render = (await vite.ssrLoadModule('/src/entry-server.tsx')).render;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// @ts-expect-error foo foo fo
|
|
31
|
+
const result = await import('../../dist/server/entry-server.js');
|
|
32
|
+
render = result.render;
|
|
33
|
+
}
|
|
34
|
+
const rendered = await render(req, res, {
|
|
35
|
+
useDevServer,
|
|
36
|
+
getInitialData,
|
|
37
|
+
placeholders: `
|
|
38
|
+
{{ ssr-title }}
|
|
39
|
+
{{ ssr-meta }}
|
|
40
|
+
{{ ssr-preload }}
|
|
41
|
+
{{ ssr-js }}
|
|
42
|
+
{{ ssr-css }}
|
|
43
|
+
`,
|
|
44
|
+
nonce: useCspNonce(),
|
|
45
|
+
preamble: `
|
|
46
|
+
import RefreshRuntime from "/@react-refresh"
|
|
47
|
+
RefreshRuntime.injectIntoGlobalHook(window)
|
|
48
|
+
window.$RefreshReg$ = () => {}
|
|
49
|
+
window.$RefreshSig$ = () => (type) => type
|
|
50
|
+
window.__vite_plugin_react_preamble_installed__ = true
|
|
51
|
+
`,
|
|
52
|
+
});
|
|
53
|
+
const readManifest = async () => {
|
|
54
|
+
if (useDevServer) {
|
|
55
|
+
return { preload: '', css: '', js: '' };
|
|
56
|
+
}
|
|
57
|
+
const manifestPath = path.resolve(root, 'dist/client/.vite/manifest.json');
|
|
58
|
+
return getAssetLinks(manifestPath, 'src/entry-client.tsx');
|
|
59
|
+
};
|
|
60
|
+
let html = rendered.html;
|
|
61
|
+
const context = Object.assign({}, rendered.context, await readManifest());
|
|
62
|
+
const ssrPlaceholders = Object.fromEntries(Object.entries(context).map(([k, v]) => [`ssr-${k}`, v.toString()]));
|
|
63
|
+
html = replaceSsrPlaceholders(html, ssrPlaceholders);
|
|
64
|
+
html = `<!DOCTYPE html>\n${html}`;
|
|
65
|
+
return [200, html, { 'Content-type': 'text/html' }];
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error instanceof Response &&
|
|
69
|
+
error.status >= 300 &&
|
|
70
|
+
error.status <= 399) {
|
|
71
|
+
return res.redirect(error.status, error.headers.get('Location') || '');
|
|
72
|
+
}
|
|
73
|
+
if (useDevServer) {
|
|
74
|
+
vite.ssrFixStacktrace(error);
|
|
75
|
+
}
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}));
|
|
79
|
+
return middlewares;
|
|
80
|
+
}
|
|
81
|
+
function replaceSsrPlaceholders(template, values) {
|
|
82
|
+
return template.replace(/\{\{\s*([\w-]+)\s*\}\}/g, (match, variableName) => {
|
|
83
|
+
if (Object.prototype.hasOwnProperty.call(values, variableName)) {
|
|
84
|
+
const value = values[variableName];
|
|
85
|
+
if (value == null) {
|
|
86
|
+
return '';
|
|
87
|
+
}
|
|
88
|
+
return String(value);
|
|
89
|
+
}
|
|
90
|
+
return match;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async function getAssetLinks(manifestPath, input, publicPath = '/') {
|
|
94
|
+
const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf-8'));
|
|
95
|
+
if (!manifest[input]) {
|
|
96
|
+
throw Error('Entry not found in the manifest.json file');
|
|
97
|
+
}
|
|
98
|
+
const chunk = manifest[input];
|
|
99
|
+
const cssHtml = (chunk.css || [])
|
|
100
|
+
.map((href) => `<link rel="stylesheet" href="${publicPath}${href}" />`)
|
|
101
|
+
.join(' ');
|
|
102
|
+
// Generate HTML for preload links
|
|
103
|
+
const preloadList = [input];
|
|
104
|
+
if (Array.isArray(chunk.imports)) {
|
|
105
|
+
preloadList.push(...chunk.imports);
|
|
106
|
+
}
|
|
107
|
+
const preloadHtml = preloadList
|
|
108
|
+
.map((pre) => {
|
|
109
|
+
if (!manifest[pre]?.file) {
|
|
110
|
+
return '';
|
|
111
|
+
}
|
|
112
|
+
return `<link rel="modulepreload" href="${publicPath}${manifest[pre].file}" />`;
|
|
113
|
+
})
|
|
114
|
+
.join(' ');
|
|
115
|
+
return {
|
|
116
|
+
preload: preloadHtml,
|
|
117
|
+
css: cssHtml,
|
|
118
|
+
js: `<script type="module" src="${publicPath}${chunk.file}"></script>`,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Request, type Response } from 'express';
|
|
2
|
+
export interface SsrRenderOptions {
|
|
3
|
+
useDevServer: boolean;
|
|
4
|
+
placeholders: string;
|
|
5
|
+
nonce: string;
|
|
6
|
+
preamble: string;
|
|
7
|
+
getInitialData: (req: string) => Promise<unknown>;
|
|
8
|
+
}
|
|
9
|
+
export type EntryRenderFn = (req: Request, res: Response, options: SsrRenderOptions) => Promise<{
|
|
10
|
+
html: string;
|
|
11
|
+
context: any;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {} from 'express';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineViteConfig } from './vite/defineViteConfig.js';
|
package/dist/src/vite.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineViteConfig } from './vite/defineViteConfig.js';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {} from 'express';
|
|
2
|
+
import { BadRequest } from './errors.js';
|
|
3
|
+
export function createFetchHeaders(requestHeaders) {
|
|
4
|
+
const headers = new Headers();
|
|
5
|
+
for (const [key, values] of Object.entries(requestHeaders)) {
|
|
6
|
+
if (values) {
|
|
7
|
+
if (Array.isArray(values)) {
|
|
8
|
+
for (const value of values) {
|
|
9
|
+
headers.append(key, value);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
headers.set(key, values);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return headers;
|
|
18
|
+
}
|
|
19
|
+
export function createFetchRequest(req) {
|
|
20
|
+
try {
|
|
21
|
+
const origin = `${req.protocol}://${req.get('host')}`;
|
|
22
|
+
// Note: This had to take originalUrl into account for presumably vite's proxying
|
|
23
|
+
const url = new URL(req.originalUrl || req.url, origin);
|
|
24
|
+
const controller = new AbortController();
|
|
25
|
+
req.on('close', () => {
|
|
26
|
+
controller.abort();
|
|
27
|
+
});
|
|
28
|
+
const init = {
|
|
29
|
+
method: req.method,
|
|
30
|
+
headers: createFetchHeaders(req.headers),
|
|
31
|
+
signal: controller.signal,
|
|
32
|
+
};
|
|
33
|
+
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
34
|
+
init.body = req.body;
|
|
35
|
+
}
|
|
36
|
+
return new Request(url.href, init);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (error instanceof TypeError) {
|
|
40
|
+
throw BadRequest('Invalid request');
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devmoods/express-extras",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.1",
|
|
4
4
|
"description": "Kubernetes-ready utilities for rapid Node.js application development",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
6
|
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./vite": "./dist/vite.js",
|
|
10
|
+
"./vite/ssr": "./dist/vite/ssr.js",
|
|
11
|
+
"./vite/types": "./dist/vite/types.js"
|
|
12
|
+
},
|
|
8
13
|
"author": {
|
|
9
14
|
"name": "hanse",
|
|
10
15
|
"email": "hanse@koren.im"
|
|
@@ -22,6 +27,7 @@
|
|
|
22
27
|
"@types/koa-compose": "^3.2.8",
|
|
23
28
|
"@types/node": "22.10.2",
|
|
24
29
|
"@types/supertest": "^6.0.2",
|
|
30
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
25
31
|
"@vitest/coverage-v8": "^2.1.8",
|
|
26
32
|
"cookiejar": "^2.1.4",
|
|
27
33
|
"eslint": "^9.17.0",
|
|
@@ -31,6 +37,7 @@
|
|
|
31
37
|
"ts-node": "10.9.2",
|
|
32
38
|
"tsx": "^4.19.2",
|
|
33
39
|
"typescript": "5.7.2",
|
|
40
|
+
"vite": "^6.0.5",
|
|
34
41
|
"vitest": "^2.1.8",
|
|
35
42
|
"vitest-fail-on-console": "^0.7.1"
|
|
36
43
|
},
|
|
@@ -68,7 +75,9 @@
|
|
|
68
75
|
"singleQuote": true
|
|
69
76
|
},
|
|
70
77
|
"peerDependencies": {
|
|
71
|
-
"
|
|
78
|
+
"@vitejs/plugin-react": ">=4.3.4",
|
|
79
|
+
"faktory-worker": ">=4.5.1",
|
|
80
|
+
"vite": ">=6.0.5"
|
|
72
81
|
},
|
|
73
82
|
"engines": {
|
|
74
83
|
"node": ">=20.3.0 <23"
|
package/dist/config.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare const config: {
|
|
2
|
-
value: {
|
|
3
|
-
CI: boolean;
|
|
4
|
-
PORT: number;
|
|
5
|
-
AUTH_TOKEN_EXPIRES_IN: number;
|
|
6
|
-
AUTH_TEMP_TOKEN_EXPIRES_IN: number;
|
|
7
|
-
AUTH_SECRET: string;
|
|
8
|
-
REDIS_URL: string;
|
|
9
|
-
POSTGRES_URL: string;
|
|
10
|
-
SENTRY_DSN: string;
|
|
11
|
-
LOG_LEVEL: string;
|
|
12
|
-
LOG_SQL: boolean;
|
|
13
|
-
NODE_ENV: string;
|
|
14
|
-
CSRF_SECRET: string;
|
|
15
|
-
READINESS_PERIOD_MS: number;
|
|
16
|
-
GRACE_PERIOD_MS: number;
|
|
17
|
-
SLACK_WEBHOOK_URL: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|