deco-express 0.1.3 → 0.1.6

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.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
7
  var __export = (target, all) => {
@@ -18,14 +16,6 @@ var __copyProps = (to, from, except, desc) => {
18
16
  }
19
17
  return to;
20
18
  };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
20
 
31
21
  // src/index.ts
@@ -59,7 +49,6 @@ function Controller(baseRoute = "") {
59
49
  __name(Controller, "Controller");
60
50
 
61
51
  // src/decorators/validation.ts
62
- var import_joi = __toESM(require("joi"));
63
52
  function Validate(schema) {
64
53
  return function(_target, _propertyKey, descriptor) {
65
54
  const originalMethod = descriptor.value;
@@ -67,16 +56,7 @@ function Validate(schema) {
67
56
  try {
68
57
  await schema.validateAsync(req.body);
69
58
  } catch (error) {
70
- if (error instanceof import_joi.default.ValidationError) {
71
- return res.status(422).json({
72
- message: "Validation failed",
73
- details: error.details.map((d) => ({
74
- field: d.path.join("."),
75
- message: d.message
76
- }))
77
- });
78
- }
79
- return next(error);
59
+ return res.status(422).json(error);
80
60
  }
81
61
  return originalMethod.call(this, req, res, next);
82
62
  };
package/dist/index.mjs CHANGED
@@ -24,7 +24,6 @@ function Controller(baseRoute = "") {
24
24
  __name(Controller, "Controller");
25
25
 
26
26
  // src/decorators/validation.ts
27
- import Joi from "joi";
28
27
  function Validate(schema) {
29
28
  return function(_target, _propertyKey, descriptor) {
30
29
  const originalMethod = descriptor.value;
@@ -32,16 +31,7 @@ function Validate(schema) {
32
31
  try {
33
32
  await schema.validateAsync(req.body);
34
33
  } catch (error) {
35
- if (error instanceof Joi.ValidationError) {
36
- return res.status(422).json({
37
- message: "Validation failed",
38
- details: error.details.map((d) => ({
39
- field: d.path.join("."),
40
- message: d.message
41
- }))
42
- });
43
- }
44
- return next(error);
34
+ return res.status(422).json(error);
45
35
  }
46
36
  return originalMethod.call(this, req, res, next);
47
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deco-express",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
4
4
  "author": "ndrolp",
5
5
  "description": "Decorator-based utilities for building Express.js REST APIs in TypeScript",
6
6
  "main": "./dist/index.js",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "express": "^5.1.0",
49
- "joi": "^17.13.3",
49
+ "joi": "^18.0.2",
50
50
  "reflect-metadata": "^0.2.2"
51
51
  }
52
52
  }