@rapidrest/core 1.3.1 → 1.4.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.
Files changed (82) hide show
  1. package/dist/lib/AlertUtils.js +7 -8
  2. package/dist/lib/AlertUtils.js.map +1 -1
  3. package/dist/lib/ClassLoader.js +7 -0
  4. package/dist/lib/ClassLoader.js.map +1 -1
  5. package/dist/lib/FileUtils.js +58 -79
  6. package/dist/lib/FileUtils.js.map +1 -1
  7. package/dist/lib/JWTUtils.js +26 -2
  8. package/dist/lib/JWTUtils.js.map +1 -1
  9. package/dist/lib/MessagingUtils.js +6 -3
  10. package/dist/lib/MessagingUtils.js.map +1 -1
  11. package/dist/lib/OASUtils.js +22 -1
  12. package/dist/lib/OASUtils.js.map +1 -1
  13. package/dist/lib/StringUtils.js +8 -5
  14. package/dist/lib/StringUtils.js.map +1 -1
  15. package/dist/lib/ValidationUtils.js +2 -2
  16. package/dist/lib/ValidationUtils.js.map +1 -1
  17. package/dist/types/FileUtils.d.ts +27 -9
  18. package/dist/types/JWTUtils.d.ts +9 -0
  19. package/dist/types/OASUtils.d.ts +17 -1
  20. package/dist/types/StringUtils.d.ts +3 -3
  21. package/package.json +2 -8
  22. package/docs/Makefile +0 -20
  23. package/docs/conf.py +0 -58
  24. package/docs/index.rst +0 -17
  25. package/docs/make.bat +0 -35
  26. package/docs/reference/@rapidrest/namespaces/ObjectDecorators/README.md +0 -21
  27. package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Config.md +0 -33
  28. package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Destroy.md +0 -27
  29. package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Init.md +0 -33
  30. package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Inject.md +0 -33
  31. package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Logger.md +0 -27
  32. package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Nullable.md +0 -27
  33. package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Validator.md +0 -25
  34. package/docs/reference/@rapidrest/namespaces/ObjectDecorators/type-aliases/ValidatorFunction.md +0 -31
  35. package/docs/reference/README.md +0 -35
  36. package/docs/reference/classes/AlertUtils.md +0 -158
  37. package/docs/reference/classes/ApiError.md +0 -251
  38. package/docs/reference/classes/ClassLoader.md +0 -224
  39. package/docs/reference/classes/Event.md +0 -109
  40. package/docs/reference/classes/EventUtils.md +0 -123
  41. package/docs/reference/classes/FileUtils.md +0 -193
  42. package/docs/reference/classes/JWTUtils.md +0 -139
  43. package/docs/reference/classes/MessagingUtils.md +0 -167
  44. package/docs/reference/classes/OASUtils.md +0 -227
  45. package/docs/reference/classes/ObjectFactory.md +0 -276
  46. package/docs/reference/classes/ObjectUtils.md +0 -60
  47. package/docs/reference/classes/StringUtils.md +0 -169
  48. package/docs/reference/classes/ThreadPool.md +0 -249
  49. package/docs/reference/classes/ThreadWorker.md +0 -91
  50. package/docs/reference/classes/UserUtils.md +0 -185
  51. package/docs/reference/classes/ValidationUtils.md +0 -294
  52. package/docs/reference/enumerations/AlertPriority.md +0 -61
  53. package/docs/reference/enumerations/JWTUtilsCompressionMethods.md +0 -21
  54. package/docs/reference/enumerations/WorkerMessageType.md +0 -43
  55. package/docs/reference/functions/sleep.md +0 -25
  56. package/docs/reference/globals.md +0 -73
  57. package/docs/reference/interfaces/Alert.md +0 -101
  58. package/docs/reference/interfaces/AlertAttachment.md +0 -51
  59. package/docs/reference/interfaces/AlertClose.md +0 -31
  60. package/docs/reference/interfaces/AlertUtilsAttachmentOptions.md +0 -42
  61. package/docs/reference/interfaces/AlertUtilsOptions.md +0 -41
  62. package/docs/reference/interfaces/InstanceOptions.md +0 -41
  63. package/docs/reference/interfaces/JWTPayload.md +0 -143
  64. package/docs/reference/interfaces/JWTUser.md +0 -55
  65. package/docs/reference/interfaces/JWTUtilsConfig.md +0 -45
  66. package/docs/reference/interfaces/JWTUtilsPayloadKeyOptions.md +0 -68
  67. package/docs/reference/interfaces/JWTUtilsPayloadOptions.md +0 -40
  68. package/docs/reference/interfaces/JWTUtilsPayloadPasswordOptions.md +0 -78
  69. package/docs/reference/interfaces/NewEvent.md +0 -25
  70. package/docs/reference/interfaces/OriginSettings.md +0 -25
  71. package/docs/reference/interfaces/SlackConfig.md +0 -33
  72. package/docs/reference/interfaces/SmtpAuth.md +0 -25
  73. package/docs/reference/interfaces/SmtpConfig.md +0 -41
  74. package/docs/reference/interfaces/Template.md +0 -105
  75. package/docs/reference/interfaces/TemplateMapBase.md +0 -13
  76. package/docs/reference/interfaces/TwilioConfig.md +0 -33
  77. package/docs/reference/interfaces/WorkerMessage.md +0 -31
  78. package/docs/reference/interfaces/WorkerOptions.md +0 -61
  79. package/docs/reference/type-aliases/BooleanFunc.md +0 -23
  80. package/docs/reference/type-aliases/TemplateMap.md +0 -17
  81. package/docs/reference/type-aliases/WorkerCallback.md +0 -31
  82. package/docs/reference/variables/Logger.md +0 -25
@@ -43,10 +43,13 @@ export class StringUtils {
43
43
  */
44
44
  static findAndReplace(contents, variables) {
45
45
  let output = contents;
46
- // Pre-compile one regex per key (O(n)) rather than creating new RegExp inside nested loops (O(n²))
46
+ // Pre-compile one regex per key (O(n)) rather than creating new RegExp inside nested loops (O(n²)).
47
+ // The key is escaped since it may contain regex metacharacters (e.g. from external input), which could
48
+ // otherwise be used for regex injection or catastrophic backtracking (ReDoS).
47
49
  const regexCache = new Map();
48
50
  for (const key in variables) {
49
- regexCache.set(key, new RegExp("(\\{\\{" + key + "\\}\\})", "g"));
51
+ const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
52
+ regexCache.set(key, new RegExp("(\\{\\{" + escapedKey + "\\}\\})", "g"));
50
53
  }
51
54
  // Go through all variables and perform replacement
52
55
  for (const key in variables) {
@@ -67,11 +70,11 @@ export class StringUtils {
67
70
  * Replaces all instances of the match regex pattern with the contents of the inner regular expression pattern for
68
71
  * the given string.
69
72
  *
70
- * e.g.
71
- *
73
+ * @example
74
+ * ```ts
72
75
  * let result = replaceAll('/my/path/{id}', new RegExp('\\{([^\\}]+)\\}'), ':');
73
76
  * console.log(result); // -> /my/path/:id
74
- *
77
+ * ```
75
78
  * @param {string} str The string to perform replacement on.
76
79
  * @param {RegExp} match The regular expression pattern to match containing an outer and inner pattern.
77
80
  * @param {string} prefix The prefix to prepend the replacement text with.
@@ -1 +1 @@
1
- {"version":3,"file":"StringUtils.js","sourceRoot":"","sources":["../../src/StringUtils.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,kDAAkD;AAClD,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,OAAO,WAAW;IACpB;;;;;;OAMG;IACI,MAAM,CAAC,aAAa,CAAC,GAAW;QACnC,IAAI,OAAO,GAAkB,IAAI,KAAK,EAAE,CAAC;QAEzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,IAAI,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAChC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;gBACf,IAAI,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBAClC,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;oBACb,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;oBAC5C,CAAC,GAAG,GAAG,CAAC;gBACZ,CAAC;qBAAM,CAAC;oBACJ,MAAM;gBACV,CAAC;YACL,CAAC;iBAAM,CAAC;gBACJ,MAAM;YACV,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,cAAc,CAAC,QAAgB,EAAE,SAAc;QACzD,IAA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AO,MAAM,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACI,MAAM,CAAC,UAAU,CAAC,GAAW,EAAE,KAAsB,EAAE,MAAc;QACxE,qGAAqG;QACrG,MAAM,MAAM,GACR,OAAO,KAAK,KAAK,QAAQ;YACrB,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC;YACxB,CAAC,CAAC,KAAK,CAAC,MAAM;gBACZ,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC;QACxD,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,WAAW,CAAC,GAAW;QACjC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,YAAY,CAAC,GAAW;QAClC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;CACJ"}
@@ -69,8 +69,8 @@ export class ValidationUtils {
69
69
  * Validates that the provided string matches the regexp pattern /[a-zA-Z0-9_\-\.@:\+]+/.
70
70
  */
71
71
  static checkName(val) {
72
- if (!/[a-zA-Z0-9_\-]+/.test(val)) {
73
- throw new Error("Value is not a name matching pattern /[a-zA-Z0-9_\-\.@:\+]+/");
72
+ if (!/^[a-zA-Z0-9_\-.@:+]+$/.test(val)) {
73
+ throw new Error("Value is not a name matching pattern /^[a-zA-Z0-9_\-\.@:\+]+$/");
74
74
  }
75
75
  return val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AAM,CAAC,UAAU,CAAC,GAAW;QAChC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAC1D,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,WAAW,CAAC,GAAW;QACjC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAQ,CAAC,GAAW;QAC9B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,SAAS,CAAC,GAAW;QAC/B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,YAAY,CAAC,GAAQ;QAC/B,MAAM,GAAG,GAAW,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAC5B,CAAC;CACJ"}
@@ -4,16 +4,27 @@
4
4
  */
5
5
  export declare class FileUtils {
6
6
  /**
7
- * Attempts to write the provided contents to the file path given. If a file already exists the user is prompted to
8
- * allow the file to be overwritten or merged. In the case of a merge, srcPath is used as a baseline in order to
9
- * perform a 3-way merge.
7
+ * Throws an error if the resolved `target` path is not contained within the resolved `rootDir` directory. Used
8
+ * to prevent path traversal (e.g. `../`) from escaping an intended root when a caller opts in by providing
9
+ * `rootDir`.
10
10
  *
11
- * @param {string} srcPath The baseline template file to use during a merge.
11
+ * @param {string} rootDir The directory that `target` must be contained within.
12
+ * @param {string} target The fully resolved path to verify.
13
+ */
14
+ private static assertContained;
15
+ /**
16
+ * Attempts to write the provided contents to the file path given. If a file already exists at the destination
17
+ * an error is thrown unless `overwrite` is set to `true`.
18
+ *
19
+ * @param {string} srcPath The baseline template file the contents were generated from.
12
20
  * @param {string} outPath The destination file path to be written.
13
21
  * @param {any} contents The contents of the file to write.
14
- * @param {boolean} overwrite Set to `true` to overwite the file and not perform a merge.
22
+ * @param {boolean} overwrite Set to `true` to overwrite an existing file at `outPath`.
23
+ * @param {string} rootDir Optional. When provided, `srcPath` and `outPath` must both resolve to a location
24
+ * contained within this directory, otherwise an error is thrown. Callers that pass externally-influenced paths
25
+ * should always supply this to prevent path traversal.
15
26
  */
16
- static writeFile(srcPath: string, outPath: string, contents: any, overwrite?: boolean): Promise<void>;
27
+ static writeFile(srcPath: string, outPath: string, contents: any, overwrite?: boolean, rootDir?: string): Promise<void>;
17
28
  /**
18
29
  * Generates a copy of the source file at the desired output destination and performs a swap of all values of the
19
30
  * variables specified.
@@ -21,16 +32,21 @@ export declare class FileUtils {
21
32
  * @param {string} srcPath The source file to copy.
22
33
  * @param {string} outPath The destination file to generate.
23
34
  * @param {any} variables The map of variable names to values to swap.
35
+ * @param {boolean} overwrite Set to `true` to overwrite an existing file at `outPath`.
36
+ * @param {string} rootDir Optional. When provided, all resolved source and destination paths must be contained
37
+ * within this directory, otherwise an error is thrown.
24
38
  */
25
- static copyFile(srcPath: string, outPath: string, variables?: any, overwrite?: boolean): Promise<void>;
39
+ static copyFile(srcPath: string, outPath: string, variables?: any, overwrite?: boolean, rootDir?: string): Promise<void>;
26
40
  /**
27
41
  * Generates a copy of the source file at the desired output destination using binary copy mode.
28
42
  *
29
43
  * @param {string} srcPath The source file to copy.
30
44
  * @param {string} outPath The destination file to generate.
31
45
  * @param {Map<string,string>} variables The map of variable names to values to swap. Applies to outPath only.
46
+ * @param {string} rootDir Optional. When provided, all resolved source and destination paths must be contained
47
+ * within this directory, otherwise an error is thrown.
32
48
  */
33
- static copyBinaryFile(srcPath: string, outPath: string, variables?: any): Promise<void>;
49
+ static copyBinaryFile(srcPath: string, outPath: string, variables?: any, rootDir?: string): Promise<void>;
34
50
  /**
35
51
  * Performs a deep copy of a directory tree at the given srcPath to the specified output directory. Performs
36
52
  * template replacement for all variables given and skips any files in the specified filter.
@@ -41,6 +57,8 @@ export declare class FileUtils {
41
57
  * @param {array} excludeFilters The list of file extension filters to exclude during the copy process.
42
58
  * @param {array} binaryFilters The list of file extension filters to copy as binary only.
43
59
  * @param {boolean} force Set to `true` to force writing over any existing files.
60
+ * @param {string} rootDir Optional. When provided, all resolved source and destination paths must be contained
61
+ * within this directory, otherwise an error is thrown.
44
62
  */
45
- static copyDirectory(srcPath: string, outPath: string, vars?: any, excludeFilters?: Array<string>, binaryFilters?: Array<string>, force?: boolean): Promise<void>;
63
+ static copyDirectory(srcPath: string, outPath: string, vars?: any, excludeFilters?: Array<string>, binaryFilters?: Array<string>, force?: boolean, rootDir?: string): Promise<void>;
46
64
  }
@@ -119,6 +119,15 @@ export interface JWTUtilsConfig {
119
119
  */
120
120
  export declare class JWTUtils {
121
121
  private static _parsedKeyCache;
122
+ /**
123
+ * Throws if `config.secret` looks like an asymmetric (RSA/EC) key but `config.options.algorithms` was not
124
+ * explicitly restricted. Signing/verifying with an asymmetric key while leaving `algorithms` unset opens the
125
+ * door to algorithm-confusion attacks (e.g. an attacker forging an HS256 token using the public key as the
126
+ * HMAC secret). HMAC secrets (plain strings/buffers that aren't PEM-encoded) are unaffected.
127
+ *
128
+ * @param config The JWT configuration to validate.
129
+ */
130
+ private static assertSafeAlgorithm;
122
131
  /**
123
132
  * Generates a new JWT token for the given config and user object. The user object must be a valid RapidREST
124
133
  * user.
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Options that restrict where `OASUtils.loadSpec` is permitted to load a specification from. Intended for callers
3
+ * that accept a spec path/URL from an external or untrusted source (e.g. a request parameter), to prevent path
4
+ * traversal (arbitrary local file read) and SSRF (requests to arbitrary/internal hosts).
5
+ */
6
+ export interface LoadSpecOptions {
7
+ /** If set, `file` must resolve to a path contained within one of these directories. */
8
+ allowedDirs?: string[];
9
+ /** If set, a `file` given as a URL must have a hostname contained in this list. */
10
+ allowedHosts?: string[];
11
+ }
1
12
  export declare class OASUtils {
2
13
  /**
3
14
  * Gets the datastore definition with the specified name.
@@ -47,10 +58,15 @@ export declare class OASUtils {
47
58
  /**
48
59
  * Attempts to load the Open API specification at the given path or URL.
49
60
  *
61
+ * **Security note**: `file` is used directly for local file access and outbound HTTP requests. If `file` may
62
+ * ever originate from an external or untrusted caller (e.g. a request parameter), pass `options.allowedDirs`
63
+ * and/or `options.allowedHosts` to restrict what can be loaded and prevent path traversal or SSRF.
64
+ *
50
65
  * @param {string} file The path or URL of the OpenAPI Specification file to load.
66
+ * @param {LoadSpecOptions} options Optional restrictions on what `file` is permitted to resolve to.
51
67
  * @returns {Promise<any>} A promise whose result will be the loaded OpenAPI Specification as an object.
52
68
  */
53
- static loadSpec(file: string): Promise<any>;
69
+ static loadSpec(file: string, options?: LoadSpecOptions): Promise<any>;
54
70
  /** Clears the spec parse cache. Useful in tests to force re-loading of specs. */
55
71
  static clearSpecCache(): void;
56
72
  }
@@ -24,11 +24,11 @@ export declare class StringUtils {
24
24
  * Replaces all instances of the match regex pattern with the contents of the inner regular expression pattern for
25
25
  * the given string.
26
26
  *
27
- * e.g.
28
- *
27
+ * @example
28
+ * ```ts
29
29
  * let result = replaceAll('/my/path/{id}', new RegExp('\\{([^\\}]+)\\}'), ':');
30
30
  * console.log(result); // -> /my/path/:id
31
- *
31
+ * ```
32
32
  * @param {string} str The string to perform replacement on.
33
33
  * @param {RegExp} match The regular expression pattern to match containing an outer and inner pattern.
34
34
  * @param {string} prefix The prefix to prepend the replacement text with.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rapidrest/core",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "A collection of common utilities and core functionality for rapidly building RESTful applications.",
5
5
  "repository": "https://github.com/rapidrest/core.git",
6
6
  "author": "RapidREST <rapidrests@gmail.com>",
@@ -12,8 +12,6 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "build": "yarn lint && rimraf dist && tsc",
15
- "deploy-docs": "ts-node tools/gh-pages-publish",
16
- "docs": "typedoc --plugin typedoc-plugin-markdown --out docs/reference src",
17
15
  "lint": "eslint ./src ./test",
18
16
  "local-audit": "yarn install && yarn npm audit -A -R \"$@\"",
19
17
  "checkup": "yarn dlx @yarnpkg/doctor \"$@\"",
@@ -30,7 +28,6 @@
30
28
  "jsonwebtoken": "^9.0.3",
31
29
  "jszip": "^3.10.1",
32
30
  "mkdirp": "^3.0.1",
33
- "readline": "^1.3.0",
34
31
  "triple-beam": "^1.4.1",
35
32
  "uuid": "^14.0.0",
36
33
  "validator": "^13.15.35"
@@ -69,8 +66,6 @@
69
66
  "rimraf": "^6.1.3",
70
67
  "ts-node": "^10.9.2",
71
68
  "twilio": "^6.0.2",
72
- "typedoc": "^0.28.19",
73
- "typedoc-plugin-markdown": "^4.12.0",
74
69
  "typescript": "^6.0.3",
75
70
  "vitest": "^4.1.8",
76
71
  "winston": "^3.19.0",
@@ -90,7 +85,6 @@
90
85
  "type": "module",
91
86
  "typings": "dist/types/index.d.ts",
92
87
  "files": [
93
- "dist",
94
- "docs"
88
+ "dist"
95
89
  ]
96
90
  }
package/docs/Makefile DELETED
@@ -1,20 +0,0 @@
1
- # Minimal makefile for Sphinx documentation
2
- #
3
-
4
- # You can set these variables from the command line, and also
5
- # from the environment for the first two.
6
- SPHINXOPTS ?=
7
- SPHINXBUILD ?= sphinx-build
8
- SOURCEDIR = .
9
- BUILDDIR = _build
10
-
11
- # Put it first so that "make" without argument is like "make help".
12
- help:
13
- @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
-
15
- .PHONY: help Makefile
16
-
17
- # Catch-all target: route all unknown targets to Sphinx using the new
18
- # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
- %: Makefile
20
- @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
package/docs/conf.py DELETED
@@ -1,58 +0,0 @@
1
- # Configuration file for the Sphinx documentation builder.
2
- #
3
- # This file only contains a selection of the most common options. For a full
4
- # list see the documentation:
5
- # https://www.sphinx-doc.org/en/master/usage/configuration.html
6
-
7
- # -- Path setup --------------------------------------------------------------
8
-
9
- # If extensions (or modules to document with autodoc) are in another directory,
10
- # add these directories to sys.path here. If the directory is relative to the
11
- # documentation root, use os.path.abspath to make it absolute, like shown here.
12
- #
13
- # import os
14
- # import sys
15
- # sys.path.insert(0, os.path.abspath('.'))
16
- import recommonmark
17
- from recommonmark.transform import AutoStructify
18
-
19
- source_suffix = ['.rst', '.md']
20
-
21
- # -- Project information -----------------------------------------------------
22
-
23
- project = 'RapidREST: Core Library'
24
- copyright = 'Jean-Philippe Steinmetz. All rights reserved.'
25
- author = 'RapidREST <rapidrests@gmail.com>'
26
-
27
- # -- General configuration ---------------------------------------------------
28
-
29
- # Add any Sphinx extension module names here, as strings. They can be
30
- # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
31
- # ones.
32
- extensions = [
33
- 'recommonmark',
34
- 'sphinx.ext.autodoc',
35
- ]
36
-
37
- # List of patterns, relative to source directory, that match files and
38
- # directories to ignore when looking for source files.
39
- # This pattern also affects html_static_path and html_extra_path.
40
- exclude_patterns = []
41
-
42
- master_doc = 'index'
43
-
44
- # Add any paths that contain custom static files (such as style sheets) here,
45
- # relative to this directory. They are copied after the builtin static files,
46
- # so a file named "default.css" will overwrite the builtin "default.css".
47
- html_static_path = ['_static']
48
-
49
- # app setup hook
50
- def setup(app):
51
- app.add_config_value('recommonmark_config', {
52
- 'auto_toc_tree_section': 'Contents',
53
- 'enable_math': False,
54
- 'enable_inline_math': False,
55
- 'enable_eval_rst': True,
56
- 'enable_auto_doc_ref': True,
57
- }, True)
58
- app.add_transform(AutoStructify)
package/docs/index.rst DELETED
@@ -1,17 +0,0 @@
1
- ===============================================================================
2
- RapidREST: Core Library
3
- ===============================================================================
4
-
5
- Repository: ``git@github.com:rapidrest/core.git``
6
-
7
- A collection of common utilities and core functionality for rapidly building RESTful applications.
8
-
9
- .. toctree::
10
- :caption: Project Info
11
-
12
- ../README
13
-
14
- .. toctree::
15
- :caption: API Reference
16
-
17
- reference/globals
package/docs/make.bat DELETED
@@ -1,35 +0,0 @@
1
- @ECHO OFF
2
-
3
- pushd %~dp0
4
-
5
- REM Command file for Sphinx documentation
6
-
7
- if "%SPHINXBUILD%" == "" (
8
- set SPHINXBUILD=sphinx-build
9
- )
10
- set SOURCEDIR=.
11
- set BUILDDIR=_build
12
-
13
- if "%1" == "" goto help
14
-
15
- %SPHINXBUILD% >NUL 2>NUL
16
- if errorlevel 9009 (
17
- echo.
18
- echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19
- echo.installed, then set the SPHINXBUILD environment variable to point
20
- echo.to the full path of the 'sphinx-build' executable. Alternatively you
21
- echo.may add the Sphinx directory to PATH.
22
- echo.
23
- echo.If you don't have Sphinx installed, grab it from
24
- echo.http://sphinx-doc.org/
25
- exit /b 1
26
- )
27
-
28
- %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
- goto end
30
-
31
- :help
32
- %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
-
34
- :end
35
- popd
@@ -1,21 +0,0 @@
1
- [**@rapidrest/core**](../../../README.md)
2
-
3
- ***
4
-
5
- [@rapidrest/core](../../../globals.md) / ObjectDecorators
6
-
7
- # ObjectDecorators
8
-
9
- ## Type Aliases
10
-
11
- - [ValidatorFunction](type-aliases/ValidatorFunction.md)
12
-
13
- ## Functions
14
-
15
- - [Config](functions/Config.md)
16
- - [Destroy](functions/Destroy.md)
17
- - [Init](functions/Init.md)
18
- - [Inject](functions/Inject.md)
19
- - [Logger](functions/Logger.md)
20
- - [Nullable](functions/Nullable.md)
21
- - [Validator](functions/Validator.md)
@@ -1,33 +0,0 @@
1
- [**@rapidrest/core**](../../../../README.md)
2
-
3
- ***
4
-
5
- [@rapidrest/core](../../../../globals.md) / [ObjectDecorators](../README.md) / Config
6
-
7
- # Function: Config()
8
-
9
- > **Config**(`path?`, `defaultValue?`): (`target`, `propertyKey`) => `void`
10
-
11
- Defined in: [src/decorators/ObjectDecorators.ts:61](https://github.com/rapidrest/core/blob/a4c031c9927a28230ae2f4bc0d881f4d5a54cdeb/src/decorators/ObjectDecorators.ts#L61)
12
-
13
- Apply this to a property to have a configuration variable be injected at instantiation. If no path is given, the
14
- global configuration object is injected.
15
-
16
- ## Parameters
17
-
18
- ### path?
19
-
20
- `string`
21
-
22
- The path to the configuration variable to inject.
23
-
24
- ### defaultValue?
25
-
26
- `any` = `undefined`
27
-
28
- Set to the desired default value. If `undefined` is specified then an error is thrown if
29
- no config variable is found at the given path.
30
-
31
- ## Returns
32
-
33
- (`target`, `propertyKey`) => `void`
@@ -1,27 +0,0 @@
1
- [**@rapidrest/core**](../../../../README.md)
2
-
3
- ***
4
-
5
- [@rapidrest/core](../../../../globals.md) / [ObjectDecorators](../README.md) / Destroy
6
-
7
- # Function: Destroy()
8
-
9
- > **Destroy**(`target`, `propertyKey`): `void`
10
-
11
- Defined in: [src/decorators/ObjectDecorators.ts:10](https://github.com/rapidrest/core/blob/a4c031c9927a28230ae2f4bc0d881f4d5a54cdeb/src/decorators/ObjectDecorators.ts#L10)
12
-
13
- Apply this to a class function to mark it as a destructor to be called by the `ObjectFactory` during cleanup.
14
-
15
- ## Parameters
16
-
17
- ### target
18
-
19
- `any`
20
-
21
- ### propertyKey
22
-
23
- `string`
24
-
25
- ## Returns
26
-
27
- `void`
@@ -1,33 +0,0 @@
1
- [**@rapidrest/core**](../../../../README.md)
2
-
3
- ***
4
-
5
- [@rapidrest/core](../../../../globals.md) / [ObjectDecorators](../README.md) / Init
6
-
7
- # Function: Init()
8
-
9
- > **Init**(`target`, `propertyKey`, `descriptor`): `void`
10
-
11
- Defined in: [src/decorators/ObjectDecorators.ts:49](https://github.com/rapidrest/core/blob/a4c031c9927a28230ae2f4bc0d881f4d5a54cdeb/src/decorators/ObjectDecorators.ts#L49)
12
-
13
- Apply this to a function to be executed once a new object instance has been created and all dependencies injected.
14
- Note: If the decorated function returns a Promise it is not gauranteed to finish execution before the object is
15
- returned during the instantiation process.
16
-
17
- ## Parameters
18
-
19
- ### target
20
-
21
- `any`
22
-
23
- ### propertyKey
24
-
25
- `string`
26
-
27
- ### descriptor
28
-
29
- `PropertyDescriptor`
30
-
31
- ## Returns
32
-
33
- `void`
@@ -1,33 +0,0 @@
1
- [**@rapidrest/core**](../../../../README.md)
2
-
3
- ***
4
-
5
- [@rapidrest/core](../../../../globals.md) / [ObjectDecorators](../README.md) / Inject
6
-
7
- # Function: Inject()
8
-
9
- > **Inject**(`type`, `options?`): (`target`, `propertyKey`) => `void`
10
-
11
- Defined in: [src/decorators/ObjectDecorators.ts:21](https://github.com/rapidrest/core/blob/a4c031c9927a28230ae2f4bc0d881f4d5a54cdeb/src/decorators/ObjectDecorators.ts#L21)
12
-
13
- Injects an object instance to the decorated property of the given name and type using the provided arguments
14
- if no object has been created yet.
15
-
16
- ## Parameters
17
-
18
- ### type
19
-
20
- `any`
21
-
22
- The fully qualified name or type of the class to instantiate. If a type is given it's class name will be inferred
23
- via the constructor name.
24
-
25
- ### options?
26
-
27
- [`InstanceOptions`](../../../../interfaces/InstanceOptions.md)
28
-
29
- The set of options to use when creating new instances of the injected class type.
30
-
31
- ## Returns
32
-
33
- (`target`, `propertyKey`) => `void`
@@ -1,27 +0,0 @@
1
- [**@rapidrest/core**](../../../../README.md)
2
-
3
- ***
4
-
5
- [@rapidrest/core](../../../../globals.md) / [ObjectDecorators](../README.md) / Logger
6
-
7
- # Function: Logger()
8
-
9
- > **Logger**(`target`, `propertyKey`): `void`
10
-
11
- Defined in: [src/decorators/ObjectDecorators.ts:77](https://github.com/rapidrest/core/blob/a4c031c9927a28230ae2f4bc0d881f4d5a54cdeb/src/decorators/ObjectDecorators.ts#L77)
12
-
13
- Apply this to a property to have the logger utility injected at instantiation.
14
-
15
- ## Parameters
16
-
17
- ### target
18
-
19
- `any`
20
-
21
- ### propertyKey
22
-
23
- `string` \| `symbol`
24
-
25
- ## Returns
26
-
27
- `void`
@@ -1,27 +0,0 @@
1
- [**@rapidrest/core**](../../../../README.md)
2
-
3
- ***
4
-
5
- [@rapidrest/core](../../../../globals.md) / [ObjectDecorators](../README.md) / Nullable
6
-
7
- # Function: Nullable()
8
-
9
- > **Nullable**(`target`, `propertyKey`): `void`
10
-
11
- Defined in: [src/decorators/ObjectDecorators.ts:90](https://github.com/rapidrest/core/blob/a4c031c9927a28230ae2f4bc0d881f4d5a54cdeb/src/decorators/ObjectDecorators.ts#L90)
12
-
13
- Apply this to a property to indicate that the value can be `null` or `undefined.`
14
-
15
- ## Parameters
16
-
17
- ### target
18
-
19
- `any`
20
-
21
- ### propertyKey
22
-
23
- `string` \| `symbol`
24
-
25
- ## Returns
26
-
27
- `void`
@@ -1,25 +0,0 @@
1
- [**@rapidrest/core**](../../../../README.md)
2
-
3
- ***
4
-
5
- [@rapidrest/core](../../../../globals.md) / [ObjectDecorators](../README.md) / Validator
6
-
7
- # Function: Validator()
8
-
9
- > **Validator**(`func`): (`target`, `propertyKey`) => `void`
10
-
11
- Defined in: [src/decorators/ObjectDecorators.ts:108](https://github.com/rapidrest/core/blob/a4c031c9927a28230ae2f4bc0d881f4d5a54cdeb/src/decorators/ObjectDecorators.ts#L108)
12
-
13
- Apply this to a property to specify the function that will be used to perform validation of the value.
14
-
15
- ## Parameters
16
-
17
- ### func
18
-
19
- [`ValidatorFunction`](../type-aliases/ValidatorFunction.md)
20
-
21
- The validation function to use for the given property.
22
-
23
- ## Returns
24
-
25
- (`target`, `propertyKey`) => `void`
@@ -1,31 +0,0 @@
1
- [**@rapidrest/core**](../../../../README.md)
2
-
3
- ***
4
-
5
- [@rapidrest/core](../../../../globals.md) / [ObjectDecorators](../README.md) / ValidatorFunction
6
-
7
- # Type Alias: ValidatorFunction
8
-
9
- > **ValidatorFunction** = (`value`) => `any`
10
-
11
- Defined in: [src/decorators/ObjectDecorators.ts:101](https://github.com/rapidrest/core/blob/a4c031c9927a28230ae2f4bc0d881f4d5a54cdeb/src/decorators/ObjectDecorators.ts#L101)
12
-
13
- A function used to validate a property value.
14
-
15
- ## Parameters
16
-
17
- ### value
18
-
19
- `any`
20
-
21
- The value to validate.
22
-
23
- ## Returns
24
-
25
- `any`
26
-
27
- The validated value to assign to the property.
28
-
29
- ## Throws
30
-
31
- An exception if the value cannot be validated.