equipped 4.0.0-alpha.3 → 4.0.0-alpha.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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [4.0.0-alpha.5](https://github.com/kevinand11/equipped/compare/v4.0.0-alpha.4...v4.0.0-alpha.5) (2023-02-14)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * controllers undefined ([f5b77aa](https://github.com/kevinand11/equipped/commit/f5b77aa7ca0d93eed57b474c2e9dd729b3faa7aa))
11
+
12
+ ## [4.0.0-alpha.4](https://github.com/kevinand11/equipped/compare/v4.0.0-alpha.3...v4.0.0-alpha.4) (2023-02-14)
13
+
5
14
  ## [4.0.0-alpha.3](https://github.com/kevinand11/equipped/compare/v4.0.0-alpha.2...v4.0.0-alpha.3) (2023-02-14)
6
15
 
7
16
 
@@ -16,9 +16,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  var _Server_expressApp, _Server_httpServer, _Server_listener;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.Server = void 0;
19
+ const cookie_parser_1 = __importDefault(require("cookie-parser"));
19
20
  const cors_1 = __importDefault(require("cors"));
20
21
  const express_1 = __importDefault(require("express"));
21
- const cookie_parser_1 = __importDefault(require("cookie-parser"));
22
22
  const express_fileupload_1 = __importDefault(require("express-fileupload"));
23
23
  const express_rate_limit_1 = __importDefault(require("express-rate-limit"));
24
24
  const express_slow_down_1 = __importDefault(require("express-slow-down"));
@@ -33,8 +33,7 @@ const controllers_1 = require("./controllers");
33
33
  const middlewares_1 = require("./middlewares");
34
34
  const parseAuthUser_1 = require("./middlewares/parseAuthUser");
35
35
  const statusCodes_1 = require("./statusCodes");
36
- const preRoutes = [];
37
- const postRoutes = [
36
+ const postRoutes = () => [
38
37
  {
39
38
  path: '__health',
40
39
  method: 'get',
@@ -100,7 +99,7 @@ class Server {
100
99
  return __classPrivateFieldGet(this, _Server_listener, "f");
101
100
  }
102
101
  set routes(routes) {
103
- const allRoutes = [...preRoutes, ...routes, ...postRoutes];
102
+ const allRoutes = [...routes, ...postRoutes()];
104
103
  allRoutes.forEach(({ method, path, controllers }) => {
105
104
  controllers = [parseAuthUser_1.parseAuthUser, ...controllers];
106
105
  if (path)
@@ -1,6 +1,6 @@
1
- import { AuthUser, RefreshUser } from '../../utils/authUser';
2
- import { StorageFile } from '../../storage';
3
1
  import { CustomError } from '../../errors';
2
+ import { StorageFile } from '../../storage';
3
+ import { AuthUser, RefreshUser } from '../../utils/authUser';
4
4
  type HeaderKeys = 'AccessToken' | 'RefreshToken' | 'Referer' | 'ContentType' | 'UserAgent';
5
5
  export declare class Request {
6
6
  #private;
@@ -36,7 +36,7 @@ export declare const Validation: {
36
36
  isInvalid: <T_6>(errors: string[], value: T_6) => {
37
37
  valid: false;
38
38
  errors: string[];
39
- value: T_6;
39
+ value: unknown;
40
40
  };
41
41
  makeRule: <T_7>(func: Validate.Rule<T_7>) => Validate.Rule<T_7>;
42
42
  makeSanitizer: <T_8>(func: Validate.Sanitizer<T_8>) => (val: T_8) => T_8;
@@ -49,9 +49,9 @@ export declare const Validation: {
49
49
  isDeepEqualTo: <Type_1>(compare: Type_1, comparer: (val: Type_1, compare: Type_1) => boolean, error?: string | undefined) => Validate.Rule<Type_1>;
50
50
  arrayContains: <Type_2>(array: Type_2[], comparer: (val: Type_2, curr: Type_2) => boolean, error?: string | undefined) => Validate.Rule<Type_2>;
51
51
  isString: (error?: string | undefined) => Validate.Rule<any>;
52
- isLengthOf: (length: number, error?: string | undefined) => Validate.Rule<string>;
53
- isMinOf: (length: number, error?: string | undefined) => Validate.Rule<string>;
54
- isMaxOf: (length: number, error?: string | undefined) => Validate.Rule<string>;
52
+ isLengthOf: (length: number, stripHTMLTags?: boolean | undefined, error?: string | undefined) => Validate.Rule<string>;
53
+ isMinOf: (length: number, stripHTMLTags?: boolean | undefined, error?: string | undefined) => Validate.Rule<string>;
54
+ isMaxOf: (length: number, stripHTMLTags?: boolean | undefined, error?: string | undefined) => Validate.Rule<string>;
55
55
  isEmail: (error?: string | undefined) => Validate.Rule<string>;
56
56
  isUrl: (error?: string | undefined) => Validate.Rule<string>;
57
57
  isNumber: (error?: string | undefined) => Validate.Rule<any>;
@@ -63,11 +63,11 @@ export declare const Validation: {
63
63
  hasLengthOf: <Type_3>(length: number, error?: string | undefined) => Validate.Rule<Type_3[]>;
64
64
  hasMinOf: <Type_4>(length: number, error?: string | undefined) => Validate.Rule<Type_4[]>;
65
65
  hasMaxOf: <Type_5>(length: number, error?: string | undefined) => Validate.Rule<Type_5[]>;
66
- isArrayOf: <T_10>(comparer: (cur: T_10, idx: number) => boolean, error?: string | undefined) => Validate.Rule<T_10[]>;
67
- isUndefined: (error?: string | undefined) => Validate.Rule<any>;
68
- isNull: (error?: string | undefined) => Validate.Rule<any>;
69
- isBoolean: (error?: string | undefined) => Validate.Rule<any>;
70
- isInstanceOf: <T_11>(classDef: new () => T_11, error?: string | undefined) => Validate.Rule<any>;
66
+ isArrayOf: <Type_6>(comparer: (cur: Type_6, idx: number) => boolean, error?: string | undefined) => Validate.Rule<Type_6[]>;
67
+ isUndefined: (error?: string | undefined) => Validate.Rule<undefined>;
68
+ isNull: (error?: string | undefined) => Validate.Rule<null>;
69
+ isBoolean: (error?: string | undefined) => Validate.Rule<boolean>;
70
+ isInstanceOf: <T_10>(classDef: new () => T_10, error?: string | undefined) => Validate.Rule<T_10>;
71
71
  fileMimeTypes: string[];
72
72
  videoMimeTypes: string[];
73
73
  audioMimeTypes: string[];
@@ -76,13 +76,13 @@ export declare const Validation: {
76
76
  isAudio: (error?: string | undefined) => Validate.Rule<Validate.File>;
77
77
  isVideo: (error?: string | undefined) => Validate.Rule<Validate.File>;
78
78
  isFile: (error?: string | undefined) => Validate.Rule<Validate.File>;
79
- isTuple: <T_12 extends readonly ((v: any, idx: number) => boolean)[]>(comparer: readonly [...T_12], error?: string | undefined) => Validate.Rule<{ [K in keyof T_12]: T_12[K] extends (v: infer V, idx: number) => boolean ? V : never; }>;
79
+ isTuple: <T_11 extends readonly ((v: any, idx: number) => boolean)[]>(comparer: readonly [...T_11], error?: string | undefined) => Validate.Rule<{ [K in keyof T_11]: T_11[K] extends (v: infer V, idx: number) => boolean ? V : never; }>;
80
80
  isRecord: <V_1>(com: (cur: V_1) => boolean, error?: string | undefined) => Validate.Rule<Record<string, V_1>>;
81
81
  isMap: <K_1, V_2>(kCom: (cur: K_1) => boolean, vCom: (cur: V_2) => boolean, error?: string | undefined) => Validate.Rule<Map<K_1, V_2>>;
82
- isCustom: <T_13>(validity: (v: T_13) => boolean, error?: string | undefined) => Validate.Rule<T_13>;
83
- isTime: <T_14 extends Validate.Timeable>(error?: string | undefined) => Validate.Rule<T_14>;
84
- isLaterThan: <T_15 extends Validate.Timeable>(compare: Validate.Timeable, error?: string | undefined) => Validate.Rule<T_15>;
85
- isEarlierThan: <T_16 extends Validate.Timeable>(compare: Validate.Timeable, error?: string | undefined) => Validate.Rule<T_16>;
82
+ isCustom: <T_12>(validity: (v: T_12) => boolean, error?: string | undefined) => Validate.Rule<T_12>;
83
+ isTime: <T_13 extends Validate.Timeable>(error?: string | undefined) => Validate.Rule<T_13>;
84
+ isLaterThan: <T_14 extends Validate.Timeable>(compare: Validate.Timeable, error?: string | undefined) => Validate.Rule<T_14>;
85
+ isEarlierThan: <T_15 extends Validate.Timeable>(compare: Validate.Timeable, error?: string | undefined) => Validate.Rule<T_15>;
86
86
  capitalize: (text: string) => string;
87
87
  stripHTML: (html: string) => string;
88
88
  trimToLength: (body: string, length: number) => string;
@@ -93,16 +93,16 @@ export declare const Validation: {
93
93
  formatNumber: (num: number, dp?: number | undefined) => string;
94
94
  pluralize: (count: number, singular: string, plural: string) => string;
95
95
  getRandomValue: () => string;
96
- groupBy: <Type_6, Unique extends string | number>(array: Type_6[], func: (item: Type_6) => Unique) => {
96
+ groupBy: <Type_7, Unique extends string | number>(array: Type_7[], func: (item: Type_7) => Unique) => {
97
97
  key: Unique;
98
- values: Type_6[];
98
+ values: Type_7[];
99
99
  }[];
100
100
  getAlphabet: (num: number) => string;
101
- addToArray: <T_17>(array: T_17[], item: T_17, getKey: (a: T_17) => any, getComparer: (a: T_17) => string | number, asc?: boolean | undefined) => T_17[];
101
+ addToArray: <T_16>(array: T_16[], item: T_16, getKey: (a: T_16) => any, getComparer: (a: T_16) => string | number, asc?: boolean | undefined) => T_16[];
102
102
  divideByZero: (num: number, den: number) => number;
103
103
  getPercentage: (num: number, den: number) => number;
104
- getRandomSample: <Type_7>(population: Type_7[], n: number) => Type_7[];
105
- shuffleArray: <Type_8>(array: Type_8[]) => Type_8[];
104
+ getRandomSample: <Type_8>(population: Type_8[], n: number) => Type_8[];
105
+ shuffleArray: <Type_9>(array: Type_9[]) => Type_9[];
106
106
  };
107
107
  type Rules<T> = {
108
108
  required?: boolean | (() => boolean);
@@ -29,9 +29,10 @@ const Validate = __importStar(require("valleyed"));
29
29
  const errors_1 = require("../errors");
30
30
  const instance_1 = require("../instance");
31
31
  const isNotTruncated = (error) => Validate.makeRule((file) => {
32
+ const val = file;
32
33
  error = error ?? `is larger than allowed limit of ${instance_1.Instance.get().settings.maxFileUploadSizeInMb}mb`;
33
- const valid = file ? !file.isTruncated : true;
34
- return valid ? Validate.isValid(file) : Validate.isInvalid([error], file);
34
+ const valid = val ? !val.isTruncated : true;
35
+ return valid ? Validate.isValid(val) : Validate.isInvalid([error], val);
35
36
  });
36
37
  exports.Validation = { ...Validate, isNotTruncated };
37
38
  const validate = (data, rules) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "equipped",
3
- "version": "4.0.0-alpha.3",
3
+ "version": "4.0.0-alpha.5",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "main": "lib/index.js",
@@ -57,7 +57,7 @@
57
57
  "pug": "^3.0.2",
58
58
  "redis": "^4.6.4",
59
59
  "socket.io": "4.6.0",
60
- "valleyed": "^4.0.2-patched"
60
+ "valleyed": "^4.0.3"
61
61
  },
62
62
  "repository": {
63
63
  "url": "git://github.com/kevinand11/equipped.git"