@devmoods/express-extras 0.13.8 → 0.14.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/sentry.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import * as Sentry from '@sentry/node';
2
- import { Application } from 'express';
2
+ import { type Application } from 'express';
3
3
  export type { Sentry };
4
4
  export interface SentryOptions extends Sentry.NodeOptions {
5
5
  }
6
+ export declare type CreateSentry = ReturnType<typeof createSentry>;
6
7
  /**
7
8
  * Create a pre-configured Sentry client
8
9
  */
@@ -16,7 +17,7 @@ export declare function createSentry(options?: SentryOptions): {
16
17
  export declare function createSentryOptions(app: Application | null, options?: SentryOptions): {
17
18
  defaultIntegrations?: false | import("@sentry/types").Integration[] | undefined;
18
19
  integrations: import("@sentry/types").Integration[] | ((integrations: import("@sentry/types").Integration[]) => import("@sentry/types").Integration[]) | undefined;
19
- transport?: ((transportOptions: import("@sentry/node/types/transports").NodeTransportOptions) => import("@sentry/types").Transport) | undefined;
20
+ transport?: ((transportOptions: import("@sentry/node/types/transports/http.js").NodeTransportOptions) => import("@sentry/types").Transport) | undefined;
20
21
  stackParser?: import("@sentry/types").StackParser | import("@sentry/types").StackLineParser[] | undefined;
21
22
  release?: string | undefined;
22
23
  environment?: string | undefined;
@@ -28,7 +29,7 @@ export declare function createSentryOptions(app: Application | null, options?: S
28
29
  autoSessionTracking?: boolean | undefined;
29
30
  sendClientReports?: boolean | undefined;
30
31
  dist?: string | undefined;
31
- transportOptions?: Partial<import("@sentry/node/types/transports").NodeTransportOptions> | undefined;
32
+ transportOptions?: Partial<import("@sentry/node/types/transports/http.js").NodeTransportOptions> | undefined;
32
33
  tracesSampleRate: number;
33
34
  initialScope?: import("@sentry/types").CaptureContext | undefined;
34
35
  maxBreadcrumbs?: number | undefined;
package/dist/sentry.js CHANGED
@@ -1,35 +1,9 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.createSentryOptions = exports.createSentry = void 0;
27
- const Sentry = __importStar(require("@sentry/node"));
28
- const Tracing = __importStar(require("@sentry/tracing"));
1
+ import * as Sentry from '@sentry/node';
2
+ import * as Tracing from '@sentry/tracing';
29
3
  /**
30
4
  * Create a pre-configured Sentry client
31
5
  */
32
- function createSentry(options = {}) {
6
+ export function createSentry(options = {}) {
33
7
  return {
34
8
  client: Sentry,
35
9
  init(app, getOptions = (defaultOptions) => defaultOptions) {
@@ -37,11 +11,10 @@ function createSentry(options = {}) {
37
11
  },
38
12
  };
39
13
  }
40
- exports.createSentry = createSentry;
41
14
  /**
42
15
  * Construct sensible Sentry default options for an Express-based app.
43
16
  */
44
- function createSentryOptions(app, options = {}) {
17
+ export function createSentryOptions(app, options = {}) {
45
18
  return {
46
19
  dsn: process.env.SENTRY_DSN,
47
20
  integrations: [
@@ -52,4 +25,3 @@ function createSentryOptions(app, options = {}) {
52
25
  ...options,
53
26
  };
54
27
  }
55
- exports.createSentryOptions = createSentryOptions;
package/dist/slack.js CHANGED
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSlack = void 0;
4
- const fetch_1 = require("@devmoods/fetch");
5
- const logger_1 = require("./logger");
1
+ import { createFetch } from '@devmoods/fetch';
2
+ import { getLogger } from './logger.js';
6
3
  /**
7
4
  * Send messages to Slack using Incoming Webhooks
8
5
  *
@@ -16,8 +13,8 @@ const logger_1 = require("./logger");
16
13
  *
17
14
  * See https://api.slack.com/messaging/webhooks
18
15
  */
19
- function createSlack({ webhookUrl = process.env.SLACK_WEBHOOK_URL, dryRun = process.env.NODE_ENV !== 'production', } = {}) {
20
- const fetch = (0, fetch_1.createFetch)();
16
+ export function createSlack({ webhookUrl = process.env.SLACK_WEBHOOK_URL, dryRun = process.env.NODE_ENV !== 'production', } = {}) {
17
+ const fetch = createFetch();
21
18
  /**
22
19
  * Post a message to Slack
23
20
  *
@@ -43,7 +40,7 @@ function createSlack({ webhookUrl = process.env.SLACK_WEBHOOK_URL, dryRun = proc
43
40
  return response.jsonData;
44
41
  }
45
42
  catch (error) {
46
- (0, logger_1.getLogger)('core').error(error);
43
+ getLogger('core').error(error);
47
44
  throw error;
48
45
  }
49
46
  }
@@ -51,4 +48,3 @@ function createSlack({ webhookUrl = process.env.SLACK_WEBHOOK_URL, dryRun = proc
51
48
  postMessage,
52
49
  };
53
50
  }
54
- exports.createSlack = createSlack;
@@ -1,5 +1,5 @@
1
- import { Options } from 'ajv';
2
- import { RequestHandler } from 'express';
1
+ import { type Options } from 'ajv';
2
+ import { type RequestHandler } from 'express';
3
3
  export declare type ValidationSchema = {
4
4
  type?: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object' | 'null';
5
5
  format?: string;
package/dist/validate.js CHANGED
@@ -1,46 +1,38 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateSchema = exports.compileValidateSchema = exports.validateParams = exports.validateQuery = exports.validateBody = void 0;
7
- const ajv_1 = __importDefault(require("ajv"));
8
- const errors_1 = require("./errors");
9
- function validateBody(schema) {
1
+ import _Ajv from 'ajv';
2
+ import { BadRequest } from './errors.js';
3
+ const Ajv = _Ajv;
4
+ export function validateBody(schema) {
10
5
  const validate = compileValidateSchema(schema);
11
6
  return (req, res, next) => {
12
7
  const result = validate(req.body);
13
8
  if (!result.isValid) {
14
- return next((0, errors_1.BadRequest)({ body: result.errors }));
9
+ return next(BadRequest({ body: result.errors }));
15
10
  }
16
11
  next();
17
12
  };
18
13
  }
19
- exports.validateBody = validateBody;
20
- function validateQuery(schema) {
14
+ export function validateQuery(schema) {
21
15
  const validate = compileValidateSchema(schema, { coerceTypes: true });
22
16
  return (req, res, next) => {
23
17
  const result = validate(req.query);
24
18
  if (!result.isValid) {
25
- return next((0, errors_1.BadRequest)({ query: result.errors }));
19
+ return next(BadRequest({ query: result.errors }));
26
20
  }
27
21
  next();
28
22
  };
29
23
  }
30
- exports.validateQuery = validateQuery;
31
- function validateParams(schema) {
24
+ export function validateParams(schema) {
32
25
  const validate = compileValidateSchema(schema, { coerceTypes: true });
33
26
  return (req, res, next) => {
34
27
  const result = validate(req.params);
35
28
  if (!result.isValid) {
36
- return next((0, errors_1.BadRequest)({ params: result.errors }));
29
+ return next(BadRequest({ params: result.errors }));
37
30
  }
38
31
  next();
39
32
  };
40
33
  }
41
- exports.validateParams = validateParams;
42
- function compileValidateSchema(schema, options = {}) {
43
- const ajv = new ajv_1.default({
34
+ export function compileValidateSchema(schema, options = {}) {
35
+ const ajv = new Ajv({
44
36
  allErrors: true,
45
37
  ...options,
46
38
  });
@@ -61,9 +53,8 @@ function compileValidateSchema(schema, options = {}) {
61
53
  };
62
54
  };
63
55
  }
64
- exports.compileValidateSchema = compileValidateSchema;
65
- function validateSchema(data, schema, options = {}) {
66
- const ajv = new ajv_1.default({
56
+ export function validateSchema(data, schema, options = {}) {
57
+ const ajv = new Ajv({
67
58
  allErrors: true,
68
59
  ...options,
69
60
  });
@@ -81,7 +72,6 @@ function validateSchema(data, schema, options = {}) {
81
72
  errors,
82
73
  };
83
74
  }
84
- exports.validateSchema = validateSchema;
85
75
  function transformAjvErrors(errors) {
86
76
  if (errors == null) {
87
77
  return [];
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "@devmoods/express-extras",
3
- "version": "0.13.8",
3
+ "version": "0.14.0",
4
4
  "description": "Kubernetes-ready utilities for rapid Node.js application development",
5
+ "type": "module",
5
6
  "main": "./dist/index.js",
6
7
  "types": "./dist/index.d.ts",
7
8
  "bin": {
8
- "migrate": "bin/migrate"
9
+ "migrate": "bin/migrate.js"
9
10
  },
10
11
  "scripts": {
11
- "start": "ts-node example",
12
+ "start": "ts-node --esm example/index.ts",
12
13
  "clean": "rm -rf dist",
14
+ "lint": "eslint src",
13
15
  "test": "NODE_ENV=test jest",
14
- "build": "npm run clean && tsc --declaration --project tsconfig.build.json",
16
+ "build": "npm run clean && tsc --project tsconfig.build.json",
15
17
  "prepublishOnly": "npm run clean && npm run build",
16
18
  "prettier": "prettier --write '**/*.{js,css,md,ts,tsx}'",
17
19
  "import-sort": "import-sort --write '**/*.{js,jsx,ts,tsx}'",
@@ -32,9 +34,16 @@
32
34
  ],
33
35
  "license": "ISC",
34
36
  "devDependencies": {
35
- "@types/jest": "29.2.0",
36
- "@types/node": "18.11.7",
37
+ "@devmoods/eslint-config": "^1.0.0",
38
+ "@types/jest": "29.2.2",
39
+ "@types/node": "18.11.9",
37
40
  "@types/supertest": "2.0.12",
41
+ "@typescript-eslint/eslint-plugin": "^5.42.0",
42
+ "eslint": "^8.27.0",
43
+ "eslint-plugin-jsx-a11y": "^6.6.1",
44
+ "eslint-plugin-prettier": "^4.2.1",
45
+ "eslint-plugin-react": "^7.31.10",
46
+ "eslint-plugin-react-hooks": "^4.6.0",
38
47
  "import-sort-cli": "6.0.0",
39
48
  "import-sort-style-module": "6.0.0",
40
49
  "isomorphic-fetch": "3.0.0",
@@ -48,8 +57,8 @@
48
57
  "dependencies": {
49
58
  "@devmoods/fetch": "^3.3.0",
50
59
  "@godaddy/terminus": "^4.11.2",
51
- "@sentry/node": "^7.16.0",
52
- "@sentry/tracing": "^7.17.2",
60
+ "@sentry/node": "^7.17.4",
61
+ "@sentry/tracing": "^7.17.4",
53
62
  "@types/bcrypt": "^5.0.0",
54
63
  "@types/bunyan": "^1.8.8",
55
64
  "@types/cls-hooked": "^4.3.3",
@@ -67,14 +76,14 @@
67
76
  "cookie-parser": "^1.4.6",
68
77
  "dotenv-safe": "^8.2.0",
69
78
  "express": "^4.18.2",
70
- "helmet": "^5.1.1",
79
+ "helmet": "^6.0.0",
71
80
  "jsonwebtoken": "^8.5.1",
72
- "meow": "^9.0.0",
81
+ "meow": "^11.0.0",
73
82
  "nodemailer": "^6.8.0",
74
83
  "pg": "^8.8.0",
75
- "redis": "^4.3.1",
84
+ "redis": "^4.4.0",
76
85
  "sql-template-strings": "^2.2.2",
77
- "uuid": "^8.3.2"
86
+ "uuid": "^9.0.0"
78
87
  },
79
88
  "prettier": {
80
89
  "singleQuote": true
@@ -83,5 +92,13 @@
83
92
  ".js, .jsx, .ts, .tsx": {
84
93
  "style": "module"
85
94
  }
95
+ },
96
+ "eslintConfig": {
97
+ "extends": "@devmoods/eslint-config",
98
+ "rules": {
99
+ "@typescript-eslint/consistent-type-imports": "warn",
100
+ "@typescript-eslint/no-shadow": "off",
101
+ "react-hooks/rules-of-hooks": "off"
102
+ }
86
103
  }
87
104
  }
package/bin/migrate DELETED
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require('dotenv').config({
4
- allowEmptyValues: true,
5
- });
6
-
7
- require('ts-node').register({});
8
- const { cli } = require('../dist/migrate.js');
9
- cli();