@centeredgesoft/runtime-mock-routes 2.4.0 → 2.5.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/.devcontainer/Dockerfile +16 -0
- package/.devcontainer/devcontainer.json +32 -0
- package/README.md +1 -1
- package/build/src/appV2.d.ts +1 -1
- package/build/src/appV2.js +4 -1
- package/package.json +1 -1
- package/src/appV2.ts +6 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/typescript-node/.devcontainer/base.Dockerfile
|
|
2
|
+
|
|
3
|
+
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 16, 14, 12, 16-bullseye, 14-bullseye, 12-bullseye, 16-buster, 14-buster, 12-buster
|
|
4
|
+
ARG VARIANT="16-bullseye"
|
|
5
|
+
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}
|
|
6
|
+
|
|
7
|
+
# [Optional] Uncomment this section to install additional OS packages.
|
|
8
|
+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
|
9
|
+
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
|
10
|
+
|
|
11
|
+
# [Optional] Uncomment if you want to install an additional version of node using nvm
|
|
12
|
+
# ARG EXTRA_NODE_VERSION=10
|
|
13
|
+
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
|
|
14
|
+
|
|
15
|
+
# [Optional] Uncomment if you want to install more global node packages
|
|
16
|
+
# RUN su node -c "npm install -g <your-package-list -here>"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
|
2
|
+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/typescript-node
|
|
3
|
+
{
|
|
4
|
+
"name": "Node.js & TypeScript",
|
|
5
|
+
"build": {
|
|
6
|
+
"dockerfile": "Dockerfile",
|
|
7
|
+
// Update 'VARIANT' to pick a Node version: 16, 14, 12.
|
|
8
|
+
// Append -bullseye or -buster to pin to an OS version.
|
|
9
|
+
// Use -bullseye variants on local on arm64/Apple Silicon.
|
|
10
|
+
"args": {
|
|
11
|
+
"VARIANT": "16-bullseye"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
// Set *default* container specific settings.json values on container create.
|
|
16
|
+
"settings": {},
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
// Add the IDs of extensions you want installed when the container is created.
|
|
20
|
+
"extensions": [
|
|
21
|
+
"dbaeumer.vscode-eslint"
|
|
22
|
+
],
|
|
23
|
+
|
|
24
|
+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
|
25
|
+
// "forwardPorts": [],
|
|
26
|
+
|
|
27
|
+
// Use 'postCreateCommand' to run commands after the container is created.
|
|
28
|
+
// "postCreateCommand": "yarn install",
|
|
29
|
+
|
|
30
|
+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
|
31
|
+
"remoteUser": "node"
|
|
32
|
+
}
|
package/README.md
CHANGED
package/build/src/appV2.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare type SupportedMethod = SupportedMethodsType[number];
|
|
|
4
4
|
export declare const isSupportedMethod: (obj: any) => obj is "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
5
5
|
export interface RuntimeRequestMethodBody {
|
|
6
6
|
body: any;
|
|
7
|
-
status?: number;
|
|
7
|
+
status?: number | ((...args: any[]) => number);
|
|
8
8
|
headers?: Record<string, string>;
|
|
9
9
|
}
|
|
10
10
|
export interface RequestParameters {
|
package/build/src/appV2.js
CHANGED
|
@@ -150,7 +150,10 @@ const appFactory = (runtimeCollection) => {
|
|
|
150
150
|
headers: req.headers
|
|
151
151
|
};
|
|
152
152
|
if (method.status) {
|
|
153
|
-
|
|
153
|
+
const status = typeof method.status === 'function'
|
|
154
|
+
? method.status(tokenParams)
|
|
155
|
+
: method.status;
|
|
156
|
+
res.status(status);
|
|
154
157
|
}
|
|
155
158
|
if (method.headers) {
|
|
156
159
|
const processedHeaders = Object.keys(method.headers).reduce((acc, curr) => (Object.assign(Object.assign({}, acc), { [curr]: handlebars_1.default.compile(method.headers[curr])(tokenParams) })), {});
|
package/package.json
CHANGED
package/src/appV2.ts
CHANGED
|
@@ -35,7 +35,7 @@ export const isSupportedMethod = (obj: any): obj is SupportedMethod => Supported
|
|
|
35
35
|
|
|
36
36
|
export interface RuntimeRequestMethodBody {
|
|
37
37
|
body: any;
|
|
38
|
-
status?: number;
|
|
38
|
+
status?: number | ((...args: any[])=>number);
|
|
39
39
|
headers?: Record<string, string>;
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -196,7 +196,11 @@ export const appFactory = (runtimeCollection?: RuntimeRequestCollection) => {
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
if (method.status) {
|
|
199
|
-
|
|
199
|
+
const status = typeof method.status === 'function'
|
|
200
|
+
? method.status(tokenParams)
|
|
201
|
+
: method.status
|
|
202
|
+
|
|
203
|
+
res.status(status);
|
|
200
204
|
}
|
|
201
205
|
|
|
202
206
|
if (method.headers) {
|