@devmoods/express-extras 0.47.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/{index.d.ts → src/index.d.ts} +1 -0
- package/dist/{index.js → src/index.js} +1 -0
- package/dist/src/webapi.d.ts +3 -0
- package/dist/src/webapi.js +44 -0
- package/package.json +7 -2
- /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.d.ts +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/{config.d.ts → src/config.d.ts} +0 -0
- /package/dist/{config.js → src/config.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/{middleware.d.ts → src/middleware.d.ts} +0 -0
- /package/dist/{middleware.js → src/middleware.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
- /package/dist/{vite → src/vite}/defineViteConfig.d.ts +0 -0
- /package/dist/{vite → src/vite}/defineViteConfig.js +0 -0
- /package/dist/{vite → src/vite}/ssr.d.ts +0 -0
- /package/dist/{vite → src/vite}/ssr.js +0 -0
- /package/dist/{vite → src/vite}/types.d.ts +0 -0
- /package/dist/{vite → src/vite}/types.js +0 -0
- /package/dist/{vite.d.ts → src/vite.d.ts} +0 -0
- /package/dist/{vite.js → src/vite.js} +0 -0
|
@@ -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.47.
|
|
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"
|
|
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
|
|
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
|