@devmoods/express-extras 0.28.3 → 0.28.5
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.d.ts +1 -1
- package/dist/auth.js +3 -2
- package/dist/cache.js +1 -4
- package/dist/errors.js +2 -1
- package/dist/listen.d.ts +2 -2
- package/dist/listen.js +4 -1
- package/dist/logger.d.ts +2 -2
- package/dist/logger.js +2 -0
- package/dist/manage.d.ts +5 -0
- package/dist/manage.js +7 -0
- package/dist/middleware.d.ts +1 -1
- package/dist/middleware.js +7 -1
- package/dist/postgres.d.ts +3 -3
- package/dist/postgres.js +1 -0
- package/dist/routes.d.ts +1 -1
- package/dist/routes.js +1 -0
- package/dist/setupTests.js +7 -2
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -0
- package/package.json +32 -36
package/dist/auth.d.ts
CHANGED
package/dist/auth.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as crypto from 'node:crypto';
|
|
2
2
|
import * as bcrypt from 'bcrypt';
|
|
3
3
|
import { Router, } from 'express';
|
|
4
|
-
import jwt from 'jsonwebtoken';
|
|
4
|
+
import * as jwt from 'jsonwebtoken';
|
|
5
5
|
import { v4 } from 'uuid';
|
|
6
6
|
import { setContext, useContext } from './context.js';
|
|
7
7
|
import { BadRequest, NotFound, Unauthorized } from './errors.js';
|
|
8
8
|
import { getLogger } from './logger.js';
|
|
9
9
|
import { route } from './middleware.js';
|
|
10
|
-
import {
|
|
10
|
+
import {} from './redis.js';
|
|
11
11
|
import { readEnv } from './utils.js';
|
|
12
|
+
import { validateBody, validateParams, } from './validate.js';
|
|
12
13
|
const logger = getLogger('auth');
|
|
13
14
|
const TOKEN_EXPIRES_IN = readEnv.number('AUTH_TOKEN_EXPIRES', 3600 * 48);
|
|
14
15
|
const TEMP_TOKEN_EXIRES_IN = readEnv.number('AUTH_TEMP_TOKEN_EXPIRES', 3600);
|
package/dist/cache.js
CHANGED
|
@@ -40,10 +40,7 @@ export function createMemoryCacheAdapter() {
|
|
|
40
40
|
return value;
|
|
41
41
|
},
|
|
42
42
|
async set(key, value, expires) {
|
|
43
|
-
cache.set(key, [
|
|
44
|
-
value,
|
|
45
|
-
expires == null ? null : Date.now() + expires * 1000,
|
|
46
|
-
]);
|
|
43
|
+
cache.set(key, [value, expires == null ? null : Date.now() + expires]);
|
|
47
44
|
},
|
|
48
45
|
async clear(key) {
|
|
49
46
|
if (key) {
|
package/dist/errors.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { STATUS_CODES } from 'node:http';
|
|
1
2
|
import * as Sentry from '@sentry/node';
|
|
2
3
|
import { errors } from 'compose-middleware';
|
|
3
|
-
import {
|
|
4
|
+
import {} from 'express';
|
|
4
5
|
import { DoesNotExistError, IntegrityError } from './postgres.js';
|
|
5
6
|
export class ApiError extends Error {
|
|
6
7
|
}
|
package/dist/listen.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
2
|
+
import { type Server } from 'node:http';
|
|
3
|
+
import { type Application } from 'express';
|
|
4
4
|
interface StoppableServer extends Server {
|
|
5
5
|
inspect(): Record<string, any>;
|
|
6
6
|
stop(): Promise<boolean>;
|
package/dist/listen.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { delay } from '@devmoods/fetch';
|
|
2
1
|
import * as http from 'node:http';
|
|
2
|
+
import {} from 'node:http';
|
|
3
|
+
import {} from 'node:net';
|
|
4
|
+
import { delay } from '@devmoods/fetch';
|
|
5
|
+
import {} from 'express';
|
|
3
6
|
import { getLogger } from './logger.js';
|
|
4
7
|
import { route } from './middleware.js';
|
|
5
8
|
import { envPort, readEnv } from './utils.js';
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
2
|
+
import { type Duplex } from 'node:stream';
|
|
3
|
+
import { type CreateSentry } from './sentry.js';
|
|
4
4
|
export type LoggerContext = Record<string, any>;
|
|
5
5
|
export interface LoggerOptions {
|
|
6
6
|
/**
|
package/dist/logger.js
CHANGED
package/dist/manage.d.ts
ADDED
package/dist/manage.js
ADDED
package/dist/middleware.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import bodyParser from 'body-parser';
|
|
2
|
-
import type
|
|
2
|
+
import { type RequestHandler } from 'express';
|
|
3
3
|
type UrlencodedParser = typeof bodyParser.urlencoded;
|
|
4
4
|
type JsonParser = typeof bodyParser.json;
|
|
5
5
|
export declare const urlencodedParser: UrlencodedParser;
|
package/dist/middleware.js
CHANGED
|
@@ -2,6 +2,7 @@ import * as Sentry from '@sentry/node';
|
|
|
2
2
|
import bodyParser from 'body-parser';
|
|
3
3
|
import { compose } from 'compose-middleware';
|
|
4
4
|
import cookieParser from 'cookie-parser';
|
|
5
|
+
import {} from 'express';
|
|
5
6
|
import helmet from 'helmet';
|
|
6
7
|
import { withRequestContext } from './context.js';
|
|
7
8
|
import { NotFound } from './errors.js';
|
|
@@ -26,7 +27,12 @@ export function before({ cookies = false, helmet: useHelmet = true, json: useJso
|
|
|
26
27
|
directives: {
|
|
27
28
|
'default-src': ["'self'"],
|
|
28
29
|
'base-uri': ["'self'"],
|
|
29
|
-
'connect-src': [
|
|
30
|
+
'connect-src': [
|
|
31
|
+
"'self'",
|
|
32
|
+
'ws:',
|
|
33
|
+
'*.sentry.io',
|
|
34
|
+
'*.cdn-apple.com',
|
|
35
|
+
],
|
|
30
36
|
'font-src': ["'self'", 'https:', 'data:'],
|
|
31
37
|
'form-action': ["'self'"],
|
|
32
38
|
'frame-ancestors': ["'self'"],
|
package/dist/postgres.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import pg, { type PoolClient, type QueryResult, type QueryResultRow } from 'pg';
|
|
1
|
+
import pg, { type PoolClient, type PoolConfig, type QueryResult, type QueryResultRow } from 'pg';
|
|
2
2
|
import { SQL, type SQLStatement } from 'sql-template-strings';
|
|
3
|
-
export interface PostgresOptions extends
|
|
3
|
+
export interface PostgresOptions extends PoolConfig {
|
|
4
4
|
onError?: (error: Error, client: any) => void;
|
|
5
|
-
url?:
|
|
5
|
+
url?: PoolConfig['connectionString'];
|
|
6
6
|
}
|
|
7
7
|
export declare class DoesNotExistError extends Error {
|
|
8
8
|
constructor(message: string);
|
package/dist/postgres.js
CHANGED
|
@@ -70,6 +70,7 @@ export class Transaction extends Connection {
|
|
|
70
70
|
* @param config
|
|
71
71
|
*/
|
|
72
72
|
export function createPostgres({ onError, url = readEnv('POSTGRES_URL'), ...config } = {}) {
|
|
73
|
+
// eslint-disable-next-line import/no-named-as-default-member
|
|
73
74
|
const pool = new pg.Pool({ connectionString: url, ...config });
|
|
74
75
|
if (onError) {
|
|
75
76
|
pool.on('error', onError);
|
package/dist/routes.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Express, type RequestHandler } from 'express';
|
|
2
2
|
export declare function createDocsRouter(app: Express, extras?: Record<string, any>): RequestHandler;
|
package/dist/routes.js
CHANGED
package/dist/setupTests.js
CHANGED
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devmoods/express-extras",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.5",
|
|
4
4
|
"description": "Kubernetes-ready utilities for rapid Node.js application development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,67 +23,65 @@
|
|
|
23
23
|
],
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@devmoods/eslint-config": "^1.
|
|
27
|
-
"@types/koa-compose": "^3.2.
|
|
28
|
-
"@types/node": "20.
|
|
29
|
-
"@types/supertest": "^2.0.
|
|
30
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
31
|
-
"@typescript-eslint/parser": "^6.
|
|
32
|
-
"@vitest/coverage-v8": "^0.34.
|
|
26
|
+
"@devmoods/eslint-config": "^1.8.0",
|
|
27
|
+
"@types/koa-compose": "^3.2.8",
|
|
28
|
+
"@types/node": "20.9.0",
|
|
29
|
+
"@types/supertest": "^2.0.16",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^6.10.0",
|
|
31
|
+
"@typescript-eslint/parser": "^6.10.0",
|
|
32
|
+
"@vitest/coverage-v8": "^0.34.6",
|
|
33
33
|
"chalk": "^5.3.0",
|
|
34
|
-
"eslint": "^8.
|
|
35
|
-
"eslint-plugin-
|
|
36
|
-
"eslint-plugin-
|
|
34
|
+
"eslint": "^8.53.0",
|
|
35
|
+
"eslint-plugin-import": "^2.29.0",
|
|
36
|
+
"eslint-plugin-jsx-a11y": "^6.8.0",
|
|
37
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
37
38
|
"eslint-plugin-react": "^7.33.2",
|
|
38
39
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
39
40
|
"faktory-worker": "^4.5.1",
|
|
40
|
-
"import-sort-cli": "6.0.0",
|
|
41
|
-
"import-sort-style-module": "6.0.0",
|
|
42
41
|
"prettier": "3.0.3",
|
|
43
42
|
"supertest": "6.3.3",
|
|
44
43
|
"ts-node": "10.9.1",
|
|
45
44
|
"typescript": "5.2.2",
|
|
46
|
-
"vitest": "^0.34.
|
|
45
|
+
"vitest": "^0.34.6"
|
|
47
46
|
},
|
|
48
47
|
"dependencies": {
|
|
49
48
|
"@devmoods/fetch": "^4.0.1",
|
|
50
|
-
"@sentry/node": "^7.
|
|
51
|
-
"@types/bcrypt": "^5.0.
|
|
52
|
-
"@types/body-parser": "^1.19.
|
|
53
|
-
"@types/cookie-parser": "^1.4.
|
|
54
|
-
"@types/express": "^4.17.
|
|
55
|
-
"@types/jsonwebtoken": "^9.0.
|
|
56
|
-
"@types/nodemailer": "^6.4.
|
|
57
|
-
"@types/pg": "^8.10.
|
|
58
|
-
"@types/superagent": "^4.1.
|
|
59
|
-
"@types/uuid": "^9.0.
|
|
49
|
+
"@sentry/node": "^7.79.0",
|
|
50
|
+
"@types/bcrypt": "^5.0.2",
|
|
51
|
+
"@types/body-parser": "^1.19.5",
|
|
52
|
+
"@types/cookie-parser": "^1.4.6",
|
|
53
|
+
"@types/express": "^4.17.21",
|
|
54
|
+
"@types/jsonwebtoken": "^9.0.5",
|
|
55
|
+
"@types/nodemailer": "^6.4.14",
|
|
56
|
+
"@types/pg": "^8.10.9",
|
|
57
|
+
"@types/superagent": "^4.1.21",
|
|
58
|
+
"@types/uuid": "^9.0.7",
|
|
60
59
|
"ajv": "^8.12.0",
|
|
61
60
|
"bcrypt": "^5.1.1",
|
|
62
61
|
"body-parser": "^1.20.2",
|
|
62
|
+
"commander": "^11.1.0",
|
|
63
63
|
"compose-middleware": "^5.0.1",
|
|
64
64
|
"cookie-parser": "^1.4.6",
|
|
65
65
|
"dotenv": "^16.3.1",
|
|
66
66
|
"express": "^4.18.2",
|
|
67
67
|
"express-route-parser": "^1.0.5",
|
|
68
|
-
"helmet": "^7.
|
|
68
|
+
"helmet": "^7.1.0",
|
|
69
69
|
"jsonwebtoken": "^9.0.2",
|
|
70
70
|
"meow": "^12.1.1",
|
|
71
|
-
"nodemailer": "^6.9.
|
|
71
|
+
"nodemailer": "^6.9.7",
|
|
72
72
|
"pg": "^8.11.3",
|
|
73
|
-
"redis": "^4.6.
|
|
73
|
+
"redis": "^4.6.10",
|
|
74
74
|
"sql-template-strings": "^2.2.2",
|
|
75
|
-
"uuid": "^9.0.
|
|
75
|
+
"uuid": "^9.0.1"
|
|
76
76
|
},
|
|
77
77
|
"prettier": {
|
|
78
78
|
"singleQuote": true
|
|
79
79
|
},
|
|
80
|
-
"importSort": {
|
|
81
|
-
".js, .jsx, .ts, .tsx": {
|
|
82
|
-
"style": "module"
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
80
|
"eslintConfig": {
|
|
86
81
|
"extends": "@devmoods/eslint-config",
|
|
82
|
+
"parserOptions": {
|
|
83
|
+
"project": "./tsconfig.json"
|
|
84
|
+
},
|
|
87
85
|
"rules": {
|
|
88
86
|
"@typescript-eslint/consistent-type-imports": "warn",
|
|
89
87
|
"@typescript-eslint/no-shadow": "off",
|
|
@@ -100,8 +98,6 @@
|
|
|
100
98
|
"lint": "eslint src",
|
|
101
99
|
"test": "./test.sh src",
|
|
102
100
|
"build": "pnpm run clean && tsc --project tsconfig.build.json",
|
|
103
|
-
"
|
|
104
|
-
"import-sort": "import-sort --write '**/*.{js,jsx,ts,tsx}'",
|
|
105
|
-
"format": "pnpm run import-sort && pnpm run prettier"
|
|
101
|
+
"format": "prettier --write '**/*.{js,css,md,ts,tsx}'"
|
|
106
102
|
}
|
|
107
103
|
}
|