@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.
Files changed (69) hide show
  1. package/dist/{index.d.ts → src/index.d.ts} +1 -0
  2. package/dist/{index.js → src/index.js} +1 -0
  3. package/dist/src/webapi.d.ts +3 -0
  4. package/dist/src/webapi.js +44 -0
  5. package/package.json +7 -2
  6. /package/dist/{__tests__ → src/__tests__}/__migrations__/1_a.d.ts +0 -0
  7. /package/dist/{__tests__ → src/__tests__}/__migrations__/1_a.js +0 -0
  8. /package/dist/{auth → src/auth}/emailAndPassword.d.ts +0 -0
  9. /package/dist/{auth → src/auth}/emailAndPassword.js +0 -0
  10. /package/dist/{auth → src/auth}/errors.d.ts +0 -0
  11. /package/dist/{auth → src/auth}/errors.js +0 -0
  12. /package/dist/{auth → src/auth}/passwordless.d.ts +0 -0
  13. /package/dist/{auth → src/auth}/passwordless.js +0 -0
  14. /package/dist/{auth → src/auth}/token.d.ts +0 -0
  15. /package/dist/{auth → src/auth}/token.js +0 -0
  16. /package/dist/{auth → src/auth}/types.d.ts +0 -0
  17. /package/dist/{auth → src/auth}/types.js +0 -0
  18. /package/dist/{auth.d.ts → src/auth.d.ts} +0 -0
  19. /package/dist/{auth.js → src/auth.js} +0 -0
  20. /package/dist/{cache.d.ts → src/cache.d.ts} +0 -0
  21. /package/dist/{cache.js → src/cache.js} +0 -0
  22. /package/dist/{cli.d.ts → src/cli.d.ts} +0 -0
  23. /package/dist/{cli.js → src/cli.js} +0 -0
  24. /package/dist/{config.d.ts → src/config.d.ts} +0 -0
  25. /package/dist/{config.js → src/config.js} +0 -0
  26. /package/dist/{context.d.ts → src/context.d.ts} +0 -0
  27. /package/dist/{context.js → src/context.js} +0 -0
  28. /package/dist/{csrf.d.ts → src/csrf.d.ts} +0 -0
  29. /package/dist/{csrf.js → src/csrf.js} +0 -0
  30. /package/dist/{email.d.ts → src/email.d.ts} +0 -0
  31. /package/dist/{email.js → src/email.js} +0 -0
  32. /package/dist/{errors.d.ts → src/errors.d.ts} +0 -0
  33. /package/dist/{errors.js → src/errors.js} +0 -0
  34. /package/dist/{faktory.d.ts → src/faktory.d.ts} +0 -0
  35. /package/dist/{faktory.js → src/faktory.js} +0 -0
  36. /package/dist/{listen.d.ts → src/listen.d.ts} +0 -0
  37. /package/dist/{listen.js → src/listen.js} +0 -0
  38. /package/dist/{logger.d.ts → src/logger.d.ts} +0 -0
  39. /package/dist/{logger.js → src/logger.js} +0 -0
  40. /package/dist/{manage.d.ts → src/manage.d.ts} +0 -0
  41. /package/dist/{manage.js → src/manage.js} +0 -0
  42. /package/dist/{middleware.d.ts → src/middleware.d.ts} +0 -0
  43. /package/dist/{middleware.js → src/middleware.js} +0 -0
  44. /package/dist/{migrate.d.ts → src/migrate.d.ts} +0 -0
  45. /package/dist/{migrate.js → src/migrate.js} +0 -0
  46. /package/dist/{postgres.d.ts → src/postgres.d.ts} +0 -0
  47. /package/dist/{postgres.js → src/postgres.js} +0 -0
  48. /package/dist/{redis.d.ts → src/redis.d.ts} +0 -0
  49. /package/dist/{redis.js → src/redis.js} +0 -0
  50. /package/dist/{routes.d.ts → src/routes.d.ts} +0 -0
  51. /package/dist/{routes.js → src/routes.js} +0 -0
  52. /package/dist/{sentry.d.ts → src/sentry.d.ts} +0 -0
  53. /package/dist/{sentry.js → src/sentry.js} +0 -0
  54. /package/dist/{setupTests.d.ts → src/setupTests.d.ts} +0 -0
  55. /package/dist/{setupTests.js → src/setupTests.js} +0 -0
  56. /package/dist/{slack.d.ts → src/slack.d.ts} +0 -0
  57. /package/dist/{slack.js → src/slack.js} +0 -0
  58. /package/dist/{utils.d.ts → src/utils.d.ts} +0 -0
  59. /package/dist/{utils.js → src/utils.js} +0 -0
  60. /package/dist/{validate.d.ts → src/validate.d.ts} +0 -0
  61. /package/dist/{validate.js → src/validate.js} +0 -0
  62. /package/dist/{vite → src/vite}/defineViteConfig.d.ts +0 -0
  63. /package/dist/{vite → src/vite}/defineViteConfig.js +0 -0
  64. /package/dist/{vite → src/vite}/ssr.d.ts +0 -0
  65. /package/dist/{vite → src/vite}/ssr.js +0 -0
  66. /package/dist/{vite → src/vite}/types.d.ts +0 -0
  67. /package/dist/{vite → src/vite}/types.js +0 -0
  68. /package/dist/{vite.d.ts → src/vite.d.ts} +0 -0
  69. /package/dist/{vite.js → src/vite.js} +0 -0
@@ -18,3 +18,4 @@ export * from './sentry.js';
18
18
  export * from './slack.js';
19
19
  export * from './utils.js';
20
20
  export * from './validate.js';
21
+ export * from './webapi.js';
@@ -19,3 +19,4 @@ export * from './sentry.js';
19
19
  export * from './slack.js';
20
20
  export * from './utils.js';
21
21
  export * from './validate.js';
22
+ export * from './webapi.js';
@@ -0,0 +1,3 @@
1
+ import { type Request as ExpressRequest } from 'express';
2
+ export declare function createFetchHeaders(requestHeaders: ExpressRequest['headers']): Headers;
3
+ export declare function createFetchRequest(req: ExpressRequest): Request;
@@ -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.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"
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