mock-config-server 1.0.4 → 2.0.1
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/README.md +277 -213
- package/dist/bin/mock-config-server.d.ts +2 -2
- package/dist/bin/mock-config-server.js +67 -65
- package/dist/bin/resolveExportsFromSourceCode.d.ts +1 -1
- package/dist/bin/resolveExportsFromSourceCode.js +11 -11
- package/dist/bin/validateMockServerConfig/validateBaseUrl/validateBaseUrl.d.ts +1 -0
- package/dist/bin/validateMockServerConfig/validateBaseUrl/validateBaseUrl.js +12 -0
- package/dist/bin/validateMockServerConfig/validateCors/validateCors.d.ts +1 -0
- package/dist/bin/validateMockServerConfig/validateCors/validateCors.js +82 -0
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateGraphqlConfig.d.ts +1 -0
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateGraphqlConfig.js +48 -0
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateRoutes/validateRoutes.d.ts +2 -0
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateRoutes/validateRoutes.js +71 -0
- package/dist/bin/validateMockServerConfig/validateInterceptors/validateInterceptors.d.ts +1 -0
- package/dist/bin/validateMockServerConfig/validateInterceptors/validateInterceptors.js +21 -0
- package/dist/bin/validateMockServerConfig/validateMockServerConfig.d.ts +1 -0
- package/dist/bin/validateMockServerConfig/validateMockServerConfig.js +34 -0
- package/dist/bin/validateMockServerConfig/validatePort/validatePort.d.ts +1 -0
- package/dist/bin/validateMockServerConfig/validatePort/validatePort.js +9 -0
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRestConfig.d.ts +1 -0
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRestConfig.js +52 -0
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRoutes/validateRoutes.d.ts +2 -0
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRoutes/validateRoutes.js +104 -0
- package/dist/bin/validateMockServerConfig/validateStaticPath/validateStaticPath.d.ts +1 -0
- package/dist/bin/validateMockServerConfig/validateStaticPath/validateStaticPath.js +44 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -17
- package/dist/src/configs/isEntitiesEqual/isEntityValuesEqual.d.ts +1 -2
- package/dist/src/configs/isEntitiesEqual/isEntityValuesEqual.js +29 -29
- package/dist/src/cors/corsMiddleware/corsMiddleware.d.ts +3 -3
- package/dist/src/cors/corsMiddleware/corsMiddleware.js +44 -32
- package/dist/src/cors/getOrigins/getAllowedOrigins.d.ts +2 -2
- package/dist/src/cors/getOrigins/getAllowedOrigins.js +13 -16
- package/dist/src/cors/noCorsMiddleware/noCorsMiddleware.d.ts +2 -2
- package/dist/src/cors/noCorsMiddleware/noCorsMiddleware.js +20 -15
- package/dist/src/graphql/createGraphQLRoutes/createGraphQLRoutes.d.ts +3 -0
- package/dist/src/graphql/createGraphQLRoutes/createGraphQLRoutes.js +73 -0
- package/dist/src/graphql/getGraphQLInput/getGraphQLInput.d.ts +3 -0
- package/dist/src/graphql/getGraphQLInput/getGraphQLInput.js +21 -0
- package/dist/src/graphql/parseGraphQLRequest/parseGraphQLRequest.d.ts +3 -0
- package/dist/src/graphql/parseGraphQLRequest/parseGraphQLRequest.js +12 -0
- package/dist/src/graphql/parseQuery/parseQuery.d.ts +7 -0
- package/dist/src/graphql/parseQuery/parseQuery.js +21 -0
- package/dist/src/graphql/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.d.ts +2 -0
- package/dist/src/graphql/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.js +28 -0
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.js +19 -19
- package/dist/src/notFound/notFoundMiddleware.d.ts +8 -0
- package/dist/src/notFound/notFoundMiddleware.js +47 -0
- package/dist/src/notFound/urlSuggestions/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.d.ts +6 -0
- package/dist/src/notFound/urlSuggestions/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.js +18 -0
- package/dist/src/notFound/urlSuggestions/getGraphqlUrlSuggestions/index.d.ts +1 -0
- package/dist/src/notFound/urlSuggestions/getGraphqlUrlSuggestions/index.js +17 -0
- package/dist/src/notFound/urlSuggestions/getLevenshteinDistance/getLevenshteinDistance.d.ts +1 -0
- package/dist/src/notFound/urlSuggestions/getLevenshteinDistance/getLevenshteinDistance.js +80 -0
- package/dist/src/notFound/urlSuggestions/getRestUrlSuggestions/getRestUrlSuggestions.d.ts +6 -0
- package/dist/src/notFound/urlSuggestions/getRestUrlSuggestions/getRestUrlSuggestions.js +34 -0
- package/dist/src/notFound/urlSuggestions/getRestUrlSuggestions/helpers/getActualRestUrlMeaningfulString/getActualRestUrlMeaningfulString.d.ts +1 -0
- package/dist/src/notFound/urlSuggestions/getRestUrlSuggestions/helpers/getActualRestUrlMeaningfulString/getActualRestUrlMeaningfulString.js +7 -0
- package/dist/src/notFound/urlSuggestions/getRestUrlSuggestions/helpers/getPatternRestUrlMeaningfulString/getPatternRestUrlMeaningfulString.d.ts +1 -0
- package/dist/src/notFound/urlSuggestions/getRestUrlSuggestions/helpers/getPatternRestUrlMeaningfulString/getPatternRestUrlMeaningfulString.js +5 -0
- package/dist/src/notFound/urlSuggestions/getRestUrlSuggestions/helpers/index.d.ts +2 -0
- package/dist/src/notFound/urlSuggestions/getRestUrlSuggestions/helpers/index.js +18 -0
- package/dist/src/notFound/urlSuggestions/getRestUrlSuggestions/index.d.ts +1 -0
- package/dist/src/notFound/urlSuggestions/getRestUrlSuggestions/index.js +17 -0
- package/dist/src/notFound/urlSuggestions/index.d.ts +2 -0
- package/dist/src/notFound/urlSuggestions/index.js +18 -0
- package/dist/src/rest/createRestRoutes/createRestRoutes.d.ts +3 -0
- package/dist/src/{routes/createRoutes/createRoutes.js → rest/createRestRoutes/createRestRoutes.js} +41 -43
- package/dist/src/rest/prepareRestRequestConfigs/prepareRestRequestConfigs.d.ts +2 -0
- package/dist/src/{configs/prepareRequestConfigs/prepareRequestConfigs.js → rest/prepareRestRequestConfigs/prepareRestRequestConfigs.js} +30 -30
- package/dist/src/routes/callRequestInterceptors/callRequestInterceptors.d.ts +12 -12
- package/dist/src/routes/callRequestInterceptors/callRequestInterceptors.js +13 -13
- package/dist/src/routes/callResponseInterceptors/callResponseInterceptors.d.ts +14 -14
- package/dist/src/routes/callResponseInterceptors/callResponseInterceptors.js +31 -31
- package/dist/src/server/createMockServer/createMockServer.d.ts +3 -3
- package/dist/src/server/createMockServer/createMockServer.js +49 -35
- package/dist/src/server/startMockServer/startMockServer.d.ts +2 -2
- package/dist/src/server/startMockServer/startMockServer.js +17 -13
- package/dist/src/static/staticMiddleware/staticMiddleware.d.ts +3 -3
- package/dist/src/static/staticMiddleware/staticMiddleware.js +30 -29
- package/dist/src/static/views/notFound.ejs +42 -0
- package/dist/src/utils/constants/appPath.d.ts +1 -1
- package/dist/src/utils/constants/appPath.js +4 -4
- package/dist/src/utils/constants/default.d.ts +11 -10
- package/dist/src/utils/constants/default.js +14 -13
- package/dist/src/utils/constants/index.d.ts +2 -2
- package/dist/src/utils/constants/index.js +18 -18
- package/dist/src/utils/helpers/index.d.ts +3 -2
- package/dist/src/utils/helpers/index.js +19 -18
- package/dist/src/utils/helpers/isPlainObject.d.ts +1 -1
- package/dist/src/utils/helpers/isPlainObject.js +5 -5
- package/dist/src/utils/helpers/sleep.d.ts +1 -1
- package/dist/src/utils/helpers/sleep.js +7 -7
- package/dist/src/utils/helpers/url/convertWin32PathToUnix/convertWin32PathToUnix.d.ts +1 -0
- package/dist/src/utils/helpers/url/convertWin32PathToUnix/convertWin32PathToUnix.js +8 -0
- package/dist/src/utils/helpers/url/getUrlParts/getUrlParts.d.ts +1 -0
- package/dist/src/utils/helpers/url/getUrlParts/getUrlParts.js +6 -0
- package/dist/src/utils/helpers/url/index.d.ts +4 -0
- package/dist/src/utils/helpers/url/index.js +20 -0
- package/dist/src/utils/helpers/url/removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes.d.ts +1 -0
- package/dist/src/utils/helpers/url/removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes.js +5 -0
- package/dist/src/utils/helpers/url/urlJoin/urlJoin.d.ts +1 -0
- package/dist/src/utils/helpers/url/urlJoin/urlJoin.js +14 -0
- package/dist/src/utils/types/configs.d.ts +63 -34
- package/dist/src/utils/types/configs.js +2 -2
- package/dist/src/utils/types/graphql.d.ts +5 -0
- package/dist/src/utils/types/graphql.js +2 -0
- package/dist/src/utils/types/index.d.ts +4 -3
- package/dist/src/utils/types/index.js +20 -19
- package/dist/src/utils/types/interceptors.d.ts +15 -15
- package/dist/src/utils/types/interceptors.js +2 -2
- package/dist/src/utils/types/server.d.ts +32 -24
- package/dist/src/utils/types/server.js +2 -2
- package/package.json +102 -99
- package/dist/src/configs/prepareRequestConfigs/prepareRequestConfigs.d.ts +0 -2
- package/dist/src/routes/createRoutes/createRoutes.d.ts +0 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<body class="container">
|
|
4
|
+
<h1>404</h1>
|
|
5
|
+
<div>
|
|
6
|
+
Seems to be your config does not have data for '<%= requestMethod %>
|
|
7
|
+
<%= decodeURIComponent(url) %> request, or you have typo in it.
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<% if (restUrlSuggestions.length || graphqlUrlSuggestions.length) { %>
|
|
11
|
+
<h2>
|
|
12
|
+
Maybe you are looking for one of these paths?
|
|
13
|
+
</h2>
|
|
14
|
+
<% } %>
|
|
15
|
+
|
|
16
|
+
<% if (restUrlSuggestions.length) { %>
|
|
17
|
+
<div>
|
|
18
|
+
<h3>REST</h3>
|
|
19
|
+
<ul>
|
|
20
|
+
<% restUrlSuggestions.forEach((restUrlSuggestion) => { %>
|
|
21
|
+
<li>
|
|
22
|
+
<a href=<%= restUrlSuggestion %>><%= decodeURIComponent(restUrlSuggestion) %></a>
|
|
23
|
+
</li>
|
|
24
|
+
<% }) %>
|
|
25
|
+
</ul>
|
|
26
|
+
</div>
|
|
27
|
+
<% } %>
|
|
28
|
+
|
|
29
|
+
<% if (graphqlUrlSuggestions.length) { %>
|
|
30
|
+
<div>
|
|
31
|
+
<h3>GraphQL</h3>
|
|
32
|
+
<ul>
|
|
33
|
+
<% graphqlUrlSuggestions.forEach((graphqlUrlSuggestion) => { %>
|
|
34
|
+
<li>
|
|
35
|
+
<%= decodeURIComponent(graphqlUrlSuggestion) %>
|
|
36
|
+
</li>
|
|
37
|
+
<% }) %>
|
|
38
|
+
</ul>
|
|
39
|
+
</div>
|
|
40
|
+
<% } %>
|
|
41
|
+
</body>
|
|
42
|
+
</html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const APP_PATH: string;
|
|
1
|
+
export declare const APP_PATH: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.APP_PATH = void 0;
|
|
4
|
-
exports.APP_PATH = process.cwd();
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.APP_PATH = void 0;
|
|
4
|
+
exports.APP_PATH = process.cwd();
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export declare const DEFAULT: {
|
|
2
|
-
PORT: number;
|
|
3
|
-
CORS: {
|
|
4
|
-
ORIGIN: string;
|
|
5
|
-
METHODS: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
1
|
+
export declare const DEFAULT: {
|
|
2
|
+
PORT: number;
|
|
3
|
+
CORS: {
|
|
4
|
+
ORIGIN: string;
|
|
5
|
+
METHODS: string;
|
|
6
|
+
ALLOWED_HEADERS: string;
|
|
7
|
+
EXPOSED_HEADERS: string;
|
|
8
|
+
CREDENTIALS: boolean;
|
|
9
|
+
MAX_AGE: number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT = void 0;
|
|
4
|
-
exports.DEFAULT = {
|
|
5
|
-
PORT: 31299,
|
|
6
|
-
CORS: {
|
|
7
|
-
ORIGIN: '*',
|
|
8
|
-
METHODS: '*',
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT = void 0;
|
|
4
|
+
exports.DEFAULT = {
|
|
5
|
+
PORT: 31299,
|
|
6
|
+
CORS: {
|
|
7
|
+
ORIGIN: '*',
|
|
8
|
+
METHODS: '*',
|
|
9
|
+
ALLOWED_HEADERS: '*',
|
|
10
|
+
EXPOSED_HEADERS: '*',
|
|
11
|
+
CREDENTIALS: true,
|
|
12
|
+
MAX_AGE: 3600
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './appPath';
|
|
2
|
-
export * from './default';
|
|
1
|
+
export * from './appPath';
|
|
2
|
+
export * from './default';
|
|
@@ -1,18 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./appPath"), exports);
|
|
18
|
-
__exportStar(require("./default"), exports);
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./appPath"), exports);
|
|
18
|
+
__exportStar(require("./default"), exports);
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from './isPlainObject';
|
|
2
|
-
export * from './sleep';
|
|
1
|
+
export * from './isPlainObject';
|
|
2
|
+
export * from './sleep';
|
|
3
|
+
export * from './url';
|
|
@@ -1,18 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./isPlainObject"), exports);
|
|
18
|
-
__exportStar(require("./sleep"), exports);
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./isPlainObject"), exports);
|
|
18
|
+
__exportStar(require("./sleep"), exports);
|
|
19
|
+
__exportStar(require("./url"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const isPlainObject: (value: any) =>
|
|
1
|
+
export declare const isPlainObject: (value: any) => value is Record<string, unknown>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPlainObject = void 0;
|
|
4
|
-
const isPlainObject = (value) => typeof value === 'object' && !Array.isArray(value) && value !== null;
|
|
5
|
-
exports.isPlainObject = isPlainObject;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPlainObject = void 0;
|
|
4
|
+
const isPlainObject = (value) => typeof value === 'object' && !Array.isArray(value) && value !== null;
|
|
5
|
+
exports.isPlainObject = isPlainObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const sleep: (seconds: number) => Promise<unknown>;
|
|
1
|
+
export declare const sleep: (seconds: number) => Promise<unknown>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sleep = void 0;
|
|
4
|
-
const sleep = (seconds) => new Promise((resolve) => {
|
|
5
|
-
setTimeout(resolve, seconds * 1000);
|
|
6
|
-
});
|
|
7
|
-
exports.sleep = sleep;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sleep = void 0;
|
|
4
|
+
const sleep = (seconds) => new Promise((resolve) => {
|
|
5
|
+
setTimeout(resolve, seconds * 1000);
|
|
6
|
+
});
|
|
7
|
+
exports.sleep = sleep;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const convertWin32PathToUnix: (win32Path: string) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertWin32PathToUnix = void 0;
|
|
4
|
+
const convertWin32PathToUnix = (win32Path) => win32Path
|
|
5
|
+
.replace(/^\\\\\?\\/, '')
|
|
6
|
+
.replace(/\\/g, '/')
|
|
7
|
+
.replace(/\/\/+/g, '/');
|
|
8
|
+
exports.convertWin32PathToUnix = convertWin32PathToUnix;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getUrlParts: (url: string) => string[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUrlParts = void 0;
|
|
4
|
+
const removeLeadingAndTrailingSlashes_1 = require("../removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes");
|
|
5
|
+
const getUrlParts = (url) => (0, removeLeadingAndTrailingSlashes_1.removeLeadingAndTrailingSlashes)(url).split('/');
|
|
6
|
+
exports.getUrlParts = getUrlParts;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./getUrlParts/getUrlParts"), exports);
|
|
18
|
+
__exportStar(require("./removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes"), exports);
|
|
19
|
+
__exportStar(require("./urlJoin/urlJoin"), exports);
|
|
20
|
+
__exportStar(require("./convertWin32PathToUnix/convertWin32PathToUnix"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const removeLeadingAndTrailingSlashes: (string: string) => string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeLeadingAndTrailingSlashes = void 0;
|
|
4
|
+
const removeLeadingAndTrailingSlashes = (string) => string.replace(/^\/+|\/+$/g, '');
|
|
5
|
+
exports.removeLeadingAndTrailingSlashes = removeLeadingAndTrailingSlashes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const urlJoin: (...paths: string[]) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
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.urlJoin = void 0;
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const convertWin32PathToUnix_1 = require("../convertWin32PathToUnix/convertWin32PathToUnix");
|
|
10
|
+
const urlJoin = (...paths) => {
|
|
11
|
+
const pathsToJoin = os_1.default.platform() === 'win32' ? paths.map((path) => (0, convertWin32PathToUnix_1.convertWin32PathToUnix)(path)) : paths;
|
|
12
|
+
return path_1.default.posix.join(...pathsToJoin);
|
|
13
|
+
};
|
|
14
|
+
exports.urlJoin = urlJoin;
|
|
@@ -1,34 +1,63 @@
|
|
|
1
|
-
export type PlainObject = Record<string, string | number>;
|
|
2
|
-
export type PlainFunction = (...args: any[]) => any;
|
|
3
|
-
export type
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export type
|
|
34
|
-
export type
|
|
1
|
+
export type PlainObject = Record<string, string | number>;
|
|
2
|
+
export type PlainFunction = (...args: any[]) => any;
|
|
3
|
+
export type BodyValue = any;
|
|
4
|
+
export type VariablesValue = any;
|
|
5
|
+
export type QueryValue = Record<string, string | string[]>;
|
|
6
|
+
export type HeadersOrParamsValue = Record<string, string>;
|
|
7
|
+
export type RestEntities = 'headers' | 'query' | 'params' | 'body';
|
|
8
|
+
export type RestEntitiesValue = BodyValue | QueryValue | HeadersOrParamsValue;
|
|
9
|
+
export type RestEntitiesValues = {
|
|
10
|
+
[Key in RestEntities]: Key extends 'body' ? BodyValue : Key extends 'query' ? QueryValue : Key extends 'headers' | 'params' ? HeadersOrParamsValue : never;
|
|
11
|
+
};
|
|
12
|
+
export interface RestMethodsEntities {
|
|
13
|
+
get: Extract<RestEntities, 'headers' | 'query' | 'params'>;
|
|
14
|
+
delete: Extract<RestEntities, 'headers' | 'query' | 'params'>;
|
|
15
|
+
post: RestEntities;
|
|
16
|
+
put: RestEntities;
|
|
17
|
+
patch: RestEntities;
|
|
18
|
+
}
|
|
19
|
+
export interface RestRouteConfig<Method extends RestMethod> {
|
|
20
|
+
entities?: {
|
|
21
|
+
[Key in RestMethodsEntities[Method]]?: RestEntitiesValues[Key];
|
|
22
|
+
};
|
|
23
|
+
data: any;
|
|
24
|
+
interceptors?: Pick<import('./interceptors').Interceptors, 'response'>;
|
|
25
|
+
}
|
|
26
|
+
export type RestMethod = 'get' | 'post' | 'delete' | 'put' | 'patch';
|
|
27
|
+
export interface BaseRestRequestConfig<Method extends RestMethod> {
|
|
28
|
+
path: `/${string}` | RegExp;
|
|
29
|
+
method: Method;
|
|
30
|
+
routes: RestRouteConfig<Method>[];
|
|
31
|
+
interceptors?: import('./interceptors').Interceptors;
|
|
32
|
+
}
|
|
33
|
+
export type RestGetRequestConfig = BaseRestRequestConfig<'get'>;
|
|
34
|
+
export type RestPostRequestConfig = BaseRestRequestConfig<'post'>;
|
|
35
|
+
export type RestPutRequestConfig = BaseRestRequestConfig<'put'>;
|
|
36
|
+
export type RestDeleteRequestConfig = BaseRestRequestConfig<'delete'>;
|
|
37
|
+
export type RestPatchRequestConfig = BaseRestRequestConfig<'patch'>;
|
|
38
|
+
export type RestRequestConfig = RestGetRequestConfig | RestPostRequestConfig | RestPutRequestConfig | RestDeleteRequestConfig | RestPatchRequestConfig;
|
|
39
|
+
export type GraphQLEntities = 'headers' | 'query' | 'variables';
|
|
40
|
+
export type GraphQLEntitiesValues = {
|
|
41
|
+
[Key in GraphQLEntities]: Key extends 'variables' ? VariablesValue : PlainObject;
|
|
42
|
+
};
|
|
43
|
+
export interface GraphQLOperationsEntities {
|
|
44
|
+
query: GraphQLEntities;
|
|
45
|
+
mutation: GraphQLEntities;
|
|
46
|
+
}
|
|
47
|
+
export type GraphQLOperationType = 'query' | 'mutation';
|
|
48
|
+
export type GraphQLOperationName = string | RegExp;
|
|
49
|
+
export interface GraphQLRouteConfig {
|
|
50
|
+
entities?: {
|
|
51
|
+
[Key in GraphQLOperationsEntities[GraphQLOperationType]]?: GraphQLEntitiesValues[Key];
|
|
52
|
+
};
|
|
53
|
+
data: any;
|
|
54
|
+
interceptors?: Pick<import('./interceptors').Interceptors, 'response'>;
|
|
55
|
+
}
|
|
56
|
+
export interface GraphQLQuery {
|
|
57
|
+
operationType: GraphQLOperationType;
|
|
58
|
+
operationName: GraphQLOperationName;
|
|
59
|
+
}
|
|
60
|
+
export interface GraphQLRequestConfig extends GraphQLQuery {
|
|
61
|
+
routes: GraphQLRouteConfig[];
|
|
62
|
+
interceptors?: import('./interceptors').Interceptors;
|
|
63
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export * from './configs';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './configs';
|
|
2
|
+
export * from './graphql';
|
|
3
|
+
export * from './interceptors';
|
|
4
|
+
export * from './server';
|
|
@@ -1,19 +1,20 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./configs"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./configs"), exports);
|
|
18
|
+
__exportStar(require("./graphql"), exports);
|
|
19
|
+
__exportStar(require("./interceptors"), exports);
|
|
20
|
+
__exportStar(require("./server"), exports);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export interface InterceptorRequestParams {
|
|
2
|
-
request: import('express').Request;
|
|
3
|
-
}
|
|
4
|
-
export type InterceptorRequest = (params: InterceptorRequestParams) => void;
|
|
5
|
-
export interface InterceptorResponseParams {
|
|
6
|
-
request: import('express').Request;
|
|
7
|
-
response: import('express').Response;
|
|
8
|
-
setDelay: (delay: number) => Promise<void>;
|
|
9
|
-
setStatusCode: (statusCode: number) => void;
|
|
10
|
-
}
|
|
11
|
-
export type InterceptorResponse = <Data>(data: Data, params: InterceptorResponseParams) => any;
|
|
12
|
-
export interface Interceptors {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
1
|
+
export interface InterceptorRequestParams {
|
|
2
|
+
request: import('express').Request;
|
|
3
|
+
}
|
|
4
|
+
export type InterceptorRequest = (params: InterceptorRequestParams) => void;
|
|
5
|
+
export interface InterceptorResponseParams {
|
|
6
|
+
request: import('express').Request;
|
|
7
|
+
response: import('express').Response;
|
|
8
|
+
setDelay: (delay: number) => Promise<void>;
|
|
9
|
+
setStatusCode: (statusCode: number) => void;
|
|
10
|
+
}
|
|
11
|
+
export type InterceptorResponse = <Data>(data: Data, params: InterceptorResponseParams) => any;
|
|
12
|
+
export interface Interceptors {
|
|
13
|
+
request?: InterceptorRequest;
|
|
14
|
+
response?: InterceptorResponse;
|
|
15
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
export type StaticPathObject = {
|
|
2
|
-
prefix: string
|
|
3
|
-
path: string
|
|
4
|
-
};
|
|
5
|
-
export type StaticPath = string | StaticPathObject | (StaticPathObject | string)[];
|
|
6
|
-
export type CorsHeader = string;
|
|
7
|
-
export type CorsOrigin = string | RegExp | (RegExp | string)[];
|
|
8
|
-
export type Cors = {
|
|
9
|
-
origin: CorsOrigin | (() => Promise<CorsOrigin> | CorsOrigin);
|
|
10
|
-
methods?: Uppercase<import('./configs').RestMethod>[];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export type
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
baseUrl?: BaseUrl;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
export type StaticPathObject = {
|
|
2
|
+
prefix: `/${string}`;
|
|
3
|
+
path: `/${string}`;
|
|
4
|
+
};
|
|
5
|
+
export type StaticPath = `/${string}` | StaticPathObject | (StaticPathObject | `/${string}`)[];
|
|
6
|
+
export type CorsHeader = string;
|
|
7
|
+
export type CorsOrigin = string | RegExp | (RegExp | string)[];
|
|
8
|
+
export type Cors = {
|
|
9
|
+
origin: CorsOrigin | ((request: import('express').Request) => Promise<CorsOrigin> | CorsOrigin);
|
|
10
|
+
methods?: Uppercase<import('./configs').RestMethod>[];
|
|
11
|
+
allowedHeaders?: CorsHeader[];
|
|
12
|
+
exposedHeaders?: CorsHeader[];
|
|
13
|
+
credentials?: boolean;
|
|
14
|
+
maxAge?: number;
|
|
15
|
+
};
|
|
16
|
+
export type Port = number;
|
|
17
|
+
export type BaseUrl = `/${string}`;
|
|
18
|
+
export interface MockServerConfig {
|
|
19
|
+
baseUrl?: BaseUrl;
|
|
20
|
+
rest?: {
|
|
21
|
+
baseUrl?: BaseUrl;
|
|
22
|
+
configs: import('./configs').RestRequestConfig[];
|
|
23
|
+
};
|
|
24
|
+
graphql?: {
|
|
25
|
+
baseUrl?: BaseUrl;
|
|
26
|
+
configs: import('./configs').GraphQLRequestConfig[];
|
|
27
|
+
};
|
|
28
|
+
port?: Port;
|
|
29
|
+
staticPath?: StaticPath;
|
|
30
|
+
interceptors?: import('./interceptors').Interceptors;
|
|
31
|
+
cors?: Cors;
|
|
32
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|