mock-config-server 3.5.0 → 3.6.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/README.md +2 -0
- package/dist/bin/bin.js +3 -3
- package/dist/bin/build.js +5 -5
- package/dist/bin/cli.js +18 -18
- package/dist/bin/helpers/createTemplate.js +4 -4
- package/dist/bin/helpers/getValidationMessageFromPath.js +2 -2
- package/dist/bin/helpers/isOnlyRequestedDataResolvingPropertyExists.js +3 -3
- package/dist/bin/helpers/resolveConfigFile.js +3 -3
- package/dist/bin/helpers/resolveExportsFromSourceCode.js +1 -1
- package/dist/bin/init.js +36 -36
- package/dist/bin/run.js +6 -6
- package/dist/bin/validateMockServerConfig/corsSchema/corsSchema.d.ts +2 -2
- package/dist/bin/validateMockServerConfig/corsSchema/corsSchema.js +6 -6
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/graphqlConfigSchema.d.ts +82 -72
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/graphqlConfigSchema.js +4 -4
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.d.ts +25 -21
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.js +3 -5
- package/dist/bin/validateMockServerConfig/queueSchema/queueSchema.d.ts +2 -2
- package/dist/bin/validateMockServerConfig/queueSchema/queueSchema.js +1 -1
- package/dist/bin/validateMockServerConfig/restConfigSchema/restConfigSchema.d.ts +270 -240
- package/dist/bin/validateMockServerConfig/restConfigSchema/restConfigSchema.js +6 -6
- package/dist/bin/validateMockServerConfig/restConfigSchema/routeConfigSchema/routeConfigSchema.d.ts +33 -28
- package/dist/bin/validateMockServerConfig/restConfigSchema/routeConfigSchema/routeConfigSchema.js +7 -9
- package/dist/bin/validateMockServerConfig/utils/entitiesSchema/entitiesSchema.d.ts +4 -8
- package/dist/bin/validateMockServerConfig/utils/entitiesSchema/entitiesSchema.js +11 -11
- package/dist/bin/validateMockServerConfig/utils/requiredPropertiesSchema/requiredPropertiesSchema.d.ts +1 -1
- package/dist/bin/validateMockServerConfig/utils/sharedSchema/sharedSchema.js +2 -2
- package/dist/bin/validateMockServerConfig/validateApiMockServerConfig.js +3 -3
- package/dist/bin/validateMockServerConfig/validateMockServerConfig.js +1 -1
- package/dist/src/core/database/createDatabaseRoutes/createDatabaseRoutes.js +3 -3
- package/dist/src/core/database/createDatabaseRoutes/helpers/array/createNewId/createNewId.js +1 -1
- package/dist/src/core/database/createDatabaseRoutes/helpers/createNestedDatabaseRoutes/createNestedDatabaseRoutes.js +15 -13
- package/dist/src/core/database/createDatabaseRoutes/helpers/createShallowDatabaseRoutes/createShallowDatabaseRoutes.js +15 -13
- package/dist/src/core/database/createDatabaseRoutes/helpers/filter/filter.js +19 -13
- package/dist/src/core/database/createDatabaseRoutes/helpers/search/search.js +3 -3
- package/dist/src/core/database/createDatabaseRoutes/helpers/sort/sort.js +5 -5
- package/dist/src/core/database/createDatabaseRoutes/helpers/splitDatabaseByNesting/splitDatabaseByNesting.js +1 -1
- package/dist/src/core/database/createDatabaseRoutes/storages/File/FileStorage.js +1 -1
- package/dist/src/core/database/createDatabaseRoutes/storages/File/FileWriter.js +1 -1
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.js +24 -19
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.js +1 -1
- package/dist/src/core/middlewares/cookieParseMiddleware/helpers/parseCookie/parseCookie.js +3 -3
- package/dist/src/core/middlewares/corsMiddleware/corsMiddleware.js +8 -8
- package/dist/src/core/middlewares/corsMiddleware/helpers/getAllowedOrigins/getAllowedOrigins.js +2 -2
- package/dist/src/core/middlewares/destroyerMiddleware/destroyerMiddleware.js +2 -2
- package/dist/src/core/middlewares/errorMiddleware/errorMiddleware.js +1 -1
- package/dist/src/core/middlewares/noCorsMiddleware/noCorsMiddleware.js +7 -7
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.js +1 -1
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/getRestUrlSuggestions.js +2 -2
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getActualRestUrlMeaningfulString/getActualRestUrlMeaningfulString.js +1 -1
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getPatternRestUrlMeaningfulString/getPatternRestUrlMeaningfulString.js +1 -1
- package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.js +7 -7
- package/dist/src/core/middlewares/requestInterceptorMiddleware/requestInterceptorMiddleware.js +1 -1
- package/dist/src/core/middlewares/staticMiddleware/staticMiddleware.js +2 -2
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.js +19 -14
- package/dist/src/core/rest/createRestRoutes/helpers/prepareRestRequestConfigs/prepareRestRequestConfigs.js +1 -1
- package/dist/src/server/createDatabaseMockServer/createDatabaseMockServer.js +6 -6
- package/dist/src/server/createGraphQLMockServer/createGraphQLMockServer.js +6 -6
- package/dist/src/server/createMockServer/createMockServer.js +8 -8
- package/dist/src/server/createRestMockServer/createRestMockServer.js +6 -6
- package/dist/src/utils/constants/checkModes.js +18 -18
- package/dist/src/utils/constants/default.js +4 -4
- package/dist/src/utils/helpers/config/resolveEntityValues/resolveEntityValues.js +20 -20
- package/dist/src/utils/helpers/entities/convertToEntityDescriptor/convertToEntityDescriptor.js +1 -1
- package/dist/src/utils/helpers/entities/isEntityDescriptor/isEntityDescriptor.js +1 -1
- package/dist/src/utils/helpers/graphql/getGraphQLInput/getGraphQLInput.js +3 -3
- package/dist/src/utils/helpers/graphql/parseQuery/parseQuery.js +1 -1
- package/dist/src/utils/helpers/isPlainObject/isPlainObject.js +1 -1
- package/dist/src/utils/helpers/url/convertWin32PathToUnix/convertWin32PathToUnix.js +1 -1
- package/dist/src/utils/helpers/url/getUrlParts/getUrlParts.js +1 -1
- package/dist/src/utils/helpers/url/removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes.js +1 -1
- package/dist/src/utils/helpers/url/urlJoin/urlJoin.js +1 -1
- package/dist/src/utils/types/graphql.d.ts +1 -1
- package/dist/src/utils/types/rest.d.ts +1 -1
- package/package.json +21 -23
|
@@ -22,16 +22,16 @@ function _interop_require_default(obj) {
|
|
|
22
22
|
const createRestMockServer = (restMockServerConfig, server = (0, _express.default)())=>{
|
|
23
23
|
var _restMockServerConfig_interceptors;
|
|
24
24
|
const { cors, staticPath, configs, database, interceptors } = restMockServerConfig;
|
|
25
|
-
server.set(
|
|
26
|
-
server.set(
|
|
27
|
-
server.use(_express.default.static((0, _helpers.urlJoin)(__dirname,
|
|
25
|
+
server.set('view engine', 'ejs');
|
|
26
|
+
server.set('views', (0, _helpers.urlJoin)(__dirname, '../../static/views'));
|
|
27
|
+
server.use(_express.default.static((0, _helpers.urlJoin)(__dirname, '../../static/views')));
|
|
28
28
|
server.use(_bodyparser.default.urlencoded({
|
|
29
29
|
extended: false
|
|
30
30
|
}));
|
|
31
31
|
server.use(_bodyparser.default.json({
|
|
32
|
-
limit:
|
|
32
|
+
limit: '10mb'
|
|
33
33
|
}));
|
|
34
|
-
server.set(
|
|
34
|
+
server.set('json spaces', 2);
|
|
35
35
|
server.use(_bodyparser.default.text());
|
|
36
36
|
(0, _middlewares.cookieParseMiddleware)(server);
|
|
37
37
|
const serverRequestInterceptor = (_restMockServerConfig_interceptors = restMockServerConfig.interceptors) === null || _restMockServerConfig_interceptors === void 0 ? void 0 : _restMockServerConfig_interceptors.request;
|
|
@@ -42,7 +42,7 @@ const createRestMockServer = (restMockServerConfig, server = (0, _express.defaul
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
var _restMockServerConfig_baseUrl;
|
|
45
|
-
const baseUrl = (_restMockServerConfig_baseUrl = restMockServerConfig.baseUrl) !== null && _restMockServerConfig_baseUrl !== void 0 ? _restMockServerConfig_baseUrl :
|
|
45
|
+
const baseUrl = (_restMockServerConfig_baseUrl = restMockServerConfig.baseUrl) !== null && _restMockServerConfig_baseUrl !== void 0 ? _restMockServerConfig_baseUrl : '/';
|
|
46
46
|
if (cors) {
|
|
47
47
|
(0, _middlewares.corsMiddleware)(server, cors);
|
|
48
48
|
} else {
|
|
@@ -35,28 +35,28 @@ _export(exports, {
|
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
const CHECK_ACTUAL_VALUE_CHECK_MODES = [
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
'exists',
|
|
39
|
+
'notExists'
|
|
40
40
|
];
|
|
41
41
|
const COMPARE_WITH_DESCRIPTOR_ANY_VALUE_CHECK_MODES = [
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
'equals',
|
|
43
|
+
'notEquals'
|
|
44
44
|
];
|
|
45
45
|
const COMPARE_WITH_DESCRIPTOR_STRING_VALUE_CHECK_MODES = [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
'includes',
|
|
47
|
+
'notIncludes',
|
|
48
|
+
'startsWith',
|
|
49
|
+
'notStartsWith',
|
|
50
|
+
'endsWith',
|
|
51
|
+
'notEndsWith'
|
|
52
52
|
];
|
|
53
53
|
const COMPARE_WITH_DESCRIPTOR_VALUE_CHECK_MODES = [
|
|
54
54
|
...COMPARE_WITH_DESCRIPTOR_ANY_VALUE_CHECK_MODES,
|
|
55
55
|
...COMPARE_WITH_DESCRIPTOR_STRING_VALUE_CHECK_MODES
|
|
56
56
|
];
|
|
57
57
|
const CALCULATE_BY_DESCRIPTOR_VALUE_CHECK_MODES = [
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
'regExp',
|
|
59
|
+
'function'
|
|
60
60
|
];
|
|
61
61
|
const CHECK_MODES = [
|
|
62
62
|
...CHECK_ACTUAL_VALUE_CHECK_MODES,
|
|
@@ -66,12 +66,12 @@ const CHECK_MODES = [
|
|
|
66
66
|
const PLAIN_ENTITY_CHECK_MODES = [
|
|
67
67
|
...CHECK_ACTUAL_VALUE_CHECK_MODES,
|
|
68
68
|
...COMPARE_WITH_DESCRIPTOR_ANY_VALUE_CHECK_MODES,
|
|
69
|
-
|
|
69
|
+
'function'
|
|
70
70
|
];
|
|
71
71
|
const NEGATION_CHECK_MODES = [
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
'notExists',
|
|
73
|
+
'notEquals',
|
|
74
|
+
'notIncludes',
|
|
75
|
+
'notStartsWith',
|
|
76
|
+
'notEndsWith'
|
|
77
77
|
];
|
|
@@ -11,10 +11,10 @@ Object.defineProperty(exports, "DEFAULT", {
|
|
|
11
11
|
const DEFAULT = {
|
|
12
12
|
PORT: 31299,
|
|
13
13
|
CORS: {
|
|
14
|
-
ORIGIN:
|
|
15
|
-
METHODS:
|
|
16
|
-
ALLOWED_HEADERS:
|
|
17
|
-
EXPOSED_HEADERS:
|
|
14
|
+
ORIGIN: '*',
|
|
15
|
+
METHODS: 'GET,OPTIONS,PUT,PATCH,POST,DELETE',
|
|
16
|
+
ALLOWED_HEADERS: '*',
|
|
17
|
+
EXPOSED_HEADERS: '*',
|
|
18
18
|
CREDENTIALS: true,
|
|
19
19
|
MAX_AGE: 3600
|
|
20
20
|
}
|
|
@@ -14,28 +14,28 @@ const _isPlainObject = require("../../isPlainObject/isPlainObject");
|
|
|
14
14
|
const _isPrimitive = require("../../isPrimitive/isPrimitive");
|
|
15
15
|
const _isRegExp = require("../../isRegExp/isRegExp");
|
|
16
16
|
const checkFunction = (checkMode, actualValue, descriptorValue)=>{
|
|
17
|
-
if (checkMode ===
|
|
17
|
+
if (checkMode === 'function' && typeof descriptorValue === 'function') return descriptorValue(actualValue, checkFunction);
|
|
18
18
|
const actualValueString = String(actualValue);
|
|
19
|
-
if (checkMode ===
|
|
20
|
-
const isActualValueUndefined = typeof actualValue ===
|
|
21
|
-
if (checkMode ===
|
|
22
|
-
if (checkMode ===
|
|
19
|
+
if (checkMode === 'regExp' && (0, _isRegExp.isRegExp)(descriptorValue)) return descriptorValue.test(actualValueString);
|
|
20
|
+
const isActualValueUndefined = typeof actualValue === 'undefined';
|
|
21
|
+
if (checkMode === 'exists') return !isActualValueUndefined;
|
|
22
|
+
if (checkMode === 'notExists') return isActualValueUndefined;
|
|
23
23
|
// ✅ important:
|
|
24
24
|
// cast values to string for ignore types of values
|
|
25
25
|
const descriptorValueString = String(descriptorValue);
|
|
26
|
-
if (checkMode ===
|
|
27
|
-
if (checkMode ===
|
|
28
|
-
if (checkMode ===
|
|
29
|
-
if (checkMode ===
|
|
30
|
-
if (checkMode ===
|
|
31
|
-
if (checkMode ===
|
|
32
|
-
if (checkMode ===
|
|
33
|
-
if (checkMode ===
|
|
34
|
-
throw new Error(
|
|
26
|
+
if (checkMode === 'equals') return actualValueString === descriptorValueString;
|
|
27
|
+
if (checkMode === 'notEquals') return actualValueString !== descriptorValueString;
|
|
28
|
+
if (checkMode === 'includes') return actualValueString.includes(descriptorValueString);
|
|
29
|
+
if (checkMode === 'notIncludes') return !actualValueString.includes(descriptorValueString);
|
|
30
|
+
if (checkMode === 'startsWith') return actualValueString.startsWith(descriptorValueString);
|
|
31
|
+
if (checkMode === 'notStartsWith') return !actualValueString.startsWith(descriptorValueString);
|
|
32
|
+
if (checkMode === 'endsWith') return actualValueString.endsWith(descriptorValueString);
|
|
33
|
+
if (checkMode === 'notEndsWith') return !actualValueString.endsWith(descriptorValueString);
|
|
34
|
+
throw new Error('Wrong checkMode');
|
|
35
35
|
};
|
|
36
36
|
const resolveEntityValues = (checkMode, actualValue, descriptorValue)=>{
|
|
37
|
-
if (checkMode ===
|
|
38
|
-
if (checkMode ===
|
|
37
|
+
if (checkMode === 'function') return descriptorValue(actualValue, checkFunction);
|
|
38
|
+
if (checkMode === 'exists' || checkMode === 'notExists') return checkFunction(checkMode, actualValue, descriptorValue);
|
|
39
39
|
// ✅ actual: primitive, descriptor: primitive
|
|
40
40
|
const isActualValuePrimitive = (0, _isPrimitive.isPrimitive)(actualValue);
|
|
41
41
|
const isDescriptorValuePrimitive = (0, _isPrimitive.isPrimitive)(descriptorValue);
|
|
@@ -52,7 +52,7 @@ const resolveEntityValues = (checkMode, actualValue, descriptorValue)=>{
|
|
|
52
52
|
// ✅ actual: primitive, descriptor: object => skip
|
|
53
53
|
const isDescriptorValueObject = (0, _isPlainObject.isPlainObject)(descriptorValue) || (0, _isRegExp.isRegExp)(descriptorValue);
|
|
54
54
|
if (isActualValuePrimitive && isDescriptorValueObject) {
|
|
55
|
-
if (checkMode ===
|
|
55
|
+
if (checkMode === 'regExp') return checkFunction(checkMode, actualValue, descriptorValue);
|
|
56
56
|
// ✅ important: resolving primitive with object make no sense
|
|
57
57
|
return isNegativeCheckMode;
|
|
58
58
|
}
|
|
@@ -70,7 +70,7 @@ const resolveEntityValues = (checkMode, actualValue, descriptorValue)=>{
|
|
|
70
70
|
}
|
|
71
71
|
// ✅ actual: array, descriptor: object => skip
|
|
72
72
|
if (isActualValueArray && isDescriptorValueObject) {
|
|
73
|
-
if (checkMode ===
|
|
73
|
+
if (checkMode === 'regExp') return actualValue.some((actualValueElement)=>checkFunction(checkMode, actualValueElement, descriptorValue));
|
|
74
74
|
// ✅ important: resolving array with object make no sense
|
|
75
75
|
return isNegativeCheckMode;
|
|
76
76
|
}
|
|
@@ -81,7 +81,7 @@ const resolveEntityValues = (checkMode, actualValue, descriptorValue)=>{
|
|
|
81
81
|
// ✅ actual: object, descriptor: array
|
|
82
82
|
if (isActualValueObject && isDescriptorValueArray) {
|
|
83
83
|
// ✅ important: any object can not pass RegExp check
|
|
84
|
-
if (checkMode ===
|
|
84
|
+
if (checkMode === 'regExp') return false;
|
|
85
85
|
const flattenActualValue = (0, _flat.flatten)(actualValue);
|
|
86
86
|
if (isNegativeCheckMode) {
|
|
87
87
|
return descriptorValue.every((descriptorValueElement)=>{
|
|
@@ -99,7 +99,7 @@ const resolveEntityValues = (checkMode, actualValue, descriptorValue)=>{
|
|
|
99
99
|
// ✅ actual: object, descriptor: object
|
|
100
100
|
if (isActualValueObject && isDescriptorValueObject) {
|
|
101
101
|
// ✅ important: any object can not pass RegExp check
|
|
102
|
-
if (checkMode ===
|
|
102
|
+
if (checkMode === 'regExp') return false;
|
|
103
103
|
const flattenActualValue = (0, _flat.flatten)(actualValue);
|
|
104
104
|
const flattenDescriptorValue = (0, _flat.flatten)(descriptorValue);
|
|
105
105
|
if (Object.keys(flattenActualValue).length !== Object.keys(flattenDescriptorValue).length) return isNegativeCheckMode;
|
package/dist/src/utils/helpers/entities/convertToEntityDescriptor/convertToEntityDescriptor.js
CHANGED
|
@@ -10,6 +10,6 @@ Object.defineProperty(exports, "convertToEntityDescriptor", {
|
|
|
10
10
|
});
|
|
11
11
|
const _isEntityDescriptor = require("../isEntityDescriptor/isEntityDescriptor");
|
|
12
12
|
const convertToEntityDescriptor = (valueOrDescriptor)=>(0, _isEntityDescriptor.isEntityDescriptor)(valueOrDescriptor) ? valueOrDescriptor : {
|
|
13
|
-
checkMode:
|
|
13
|
+
checkMode: 'equals',
|
|
14
14
|
value: valueOrDescriptor
|
|
15
15
|
};
|
|
@@ -9,4 +9,4 @@ Object.defineProperty(exports, "isEntityDescriptor", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _isPlainObject = require("../../isPlainObject/isPlainObject");
|
|
12
|
-
const isEntityDescriptor = (value)=>(0, _isPlainObject.isPlainObject)(value) &&
|
|
12
|
+
const isEntityDescriptor = (value)=>(0, _isPlainObject.isPlainObject)(value) && 'checkMode' in value;
|
|
@@ -9,16 +9,16 @@ Object.defineProperty(exports, "getGraphQLInput", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const getGraphQLInput = (request)=>{
|
|
12
|
-
if (request.method ===
|
|
12
|
+
if (request.method === 'GET') {
|
|
13
13
|
const { query, variables } = request.query;
|
|
14
14
|
// ✅ important:
|
|
15
15
|
// if 'variables' was sent as encoded uri component then it already decoded into object and we do not need to use JSON.parse
|
|
16
16
|
return {
|
|
17
17
|
query: query === null || query === void 0 ? void 0 : query.toString(),
|
|
18
|
-
variables: typeof variables ===
|
|
18
|
+
variables: typeof variables === 'string' ? JSON.parse(variables) : variables
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
if (request.method ===
|
|
21
|
+
if (request.method === 'POST') {
|
|
22
22
|
const { query, variables } = request.body;
|
|
23
23
|
return {
|
|
24
24
|
query,
|
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "parseQuery", {
|
|
|
11
11
|
const _graphql = require("graphql");
|
|
12
12
|
const parseDocumentNode = (node)=>{
|
|
13
13
|
var _operationDefinition_name;
|
|
14
|
-
const operationDefinition = node.definitions.find((definition)=>definition.kind ===
|
|
14
|
+
const operationDefinition = node.definitions.find((definition)=>definition.kind === 'OperationDefinition');
|
|
15
15
|
var _operationDefinition_name_value;
|
|
16
16
|
return {
|
|
17
17
|
operationType: operationDefinition.operation,
|
|
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "isPlainObject", {
|
|
|
8
8
|
return isPlainObject;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const isPlainObject = (value)=>typeof value ===
|
|
11
|
+
const isPlainObject = (value)=>typeof value === 'object' && !Array.isArray(value) && value !== null && !(value instanceof RegExp);
|
|
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "convertWin32PathToUnix", {
|
|
|
8
8
|
return convertWin32PathToUnix;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const convertWin32PathToUnix = (win32Path)=>win32Path.replace(/^\\\\\?\\/,
|
|
11
|
+
const convertWin32PathToUnix = (win32Path)=>win32Path.replace(/^\\\\\?\\/, '').replace(/\\/g, '/').replace(/\/\/+/g, '/');
|
|
@@ -9,4 +9,4 @@ Object.defineProperty(exports, "getUrlParts", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _removeLeadingAndTrailingSlashes = require("../removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes");
|
|
12
|
-
const getUrlParts = (url)=>(0, _removeLeadingAndTrailingSlashes.removeLeadingAndTrailingSlashes)(url).split(
|
|
12
|
+
const getUrlParts = (url)=>(0, _removeLeadingAndTrailingSlashes.removeLeadingAndTrailingSlashes)(url).split('/');
|
|
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "removeLeadingAndTrailingSlashes", {
|
|
|
8
8
|
return removeLeadingAndTrailingSlashes;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const removeLeadingAndTrailingSlashes = (string)=>string.replace(/^\/+|\/+$/g,
|
|
11
|
+
const removeLeadingAndTrailingSlashes = (string)=>string.replace(/^\/+|\/+$/g, '');
|
|
@@ -17,6 +17,6 @@ function _interop_require_default(obj) {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
const urlJoin = (...paths)=>{
|
|
20
|
-
const pathsToJoin = _os.default.platform() ===
|
|
20
|
+
const pathsToJoin = _os.default.platform() === 'win32' ? paths.map((path)=>(0, _convertWin32PathToUnix.convertWin32PathToUnix)(path)) : paths;
|
|
21
21
|
return _path.default.posix.join(...pathsToJoin);
|
|
22
22
|
};
|
|
@@ -32,7 +32,7 @@ export type GraphQLRouteConfig = ({
|
|
|
32
32
|
data: ((request: Request, entities: GraphQLEntitiesByEntityName) => Data | Promise<Data>) | Data;
|
|
33
33
|
}) & {
|
|
34
34
|
entities?: GraphQLEntitiesByEntityName;
|
|
35
|
-
interceptors?:
|
|
35
|
+
interceptors?: Interceptors;
|
|
36
36
|
};
|
|
37
37
|
interface BaseGraphQLRequestConfig {
|
|
38
38
|
operationType: GraphQLOperationType;
|
|
@@ -36,7 +36,7 @@ export type RestRouteConfig<Method extends RestMethod> = ({
|
|
|
36
36
|
file: string;
|
|
37
37
|
}) & {
|
|
38
38
|
entities?: RestEntitiesByEntityName<Method>;
|
|
39
|
-
interceptors?:
|
|
39
|
+
interceptors?: Interceptors;
|
|
40
40
|
};
|
|
41
41
|
export type RestPathString = `/${string}`;
|
|
42
42
|
interface BaseRestRequestConfig<Method extends RestMethod> {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mock-config-server",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Tool that easily and quickly imitates server operation, create full fake api in few steps",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "SIBERIA CAN CODE 🧊",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"build": "shx rm -rf dist && yarn build:types && yarn build:swc && yarn build:copy-templates",
|
|
51
51
|
"start": "yarn build && node ./dist/bin/bin.js",
|
|
52
52
|
"dev": "nodemon --watch src --watch bin --watch mock-server.config.* -e js,ts,ejs --exec \"yarn start\"",
|
|
53
|
-
"test": "
|
|
53
|
+
"unit-test": "vitest",
|
|
54
54
|
"lint": "eslint . --ext .ts --no-error-on-unmatched-pattern --fix",
|
|
55
55
|
"stylelint": "stylelint \"src/static/**/*.css\" --fix",
|
|
56
56
|
"format": "prettier --write \"**/*.(ts|js)\"",
|
|
@@ -71,40 +71,38 @@
|
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@types/body-parser": "^1.19.5",
|
|
73
73
|
"@types/express": "^4.17.21",
|
|
74
|
-
"@types/flat": "^5.0.
|
|
74
|
+
"@types/flat": "^5.0.5",
|
|
75
75
|
"@types/prompts": "^2.4.9",
|
|
76
76
|
"@types/yargs": "^17.0.32",
|
|
77
77
|
"ansi-colors": "^4.1.3",
|
|
78
78
|
"body-parser": "^1.20.2",
|
|
79
|
-
"ejs": "^3.1.
|
|
80
|
-
"esbuild": "^0.
|
|
81
|
-
"express": "^4.
|
|
82
|
-
"express-urlrewrite": "^2.0.
|
|
79
|
+
"ejs": "^3.1.10",
|
|
80
|
+
"esbuild": "^0.21.4",
|
|
81
|
+
"express": "^4.19.2",
|
|
82
|
+
"express-urlrewrite": "^2.0.2",
|
|
83
83
|
"flat": "^5.0.2",
|
|
84
|
-
"graphql": "^16.
|
|
84
|
+
"graphql": "^16.8.1",
|
|
85
85
|
"please-upgrade-node": "^3.2.0",
|
|
86
86
|
"prompts": "^2.4.2",
|
|
87
87
|
"yargs": "^17.7.2",
|
|
88
|
-
"zod": "^3.
|
|
88
|
+
"zod": "^3.23.8"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@siberiacancode/eslint": "^1.
|
|
92
|
-
"@siberiacancode/
|
|
93
|
-
"@siberiacancode/
|
|
94
|
-
"@siberiacancode/
|
|
91
|
+
"@siberiacancode/eslint": "^1.1.1",
|
|
92
|
+
"@siberiacancode/prettier": "^1.1.1",
|
|
93
|
+
"@siberiacancode/stylelint": "^1.1.1",
|
|
94
|
+
"@siberiacancode/vitest": "^1.2.3",
|
|
95
95
|
"@swc/cli": "^0.3.12",
|
|
96
|
-
"@swc/core": "^1.
|
|
97
|
-
"@swc/jest": "^0.2.36",
|
|
98
|
-
"@types/jest": "^29.5.11",
|
|
96
|
+
"@swc/core": "^1.5.24",
|
|
99
97
|
"@types/supertest": "^6.0.2",
|
|
100
|
-
"husky": "^
|
|
101
|
-
"lint-staged": "^15.2.
|
|
102
|
-
"nodemon": "^3.
|
|
98
|
+
"husky": "^9.0.11",
|
|
99
|
+
"lint-staged": "^15.2.5",
|
|
100
|
+
"nodemon": "^3.1.2",
|
|
103
101
|
"shx": "^0.3.4",
|
|
104
|
-
"style-loader": "^
|
|
105
|
-
"supertest": "^
|
|
106
|
-
"tsc-alias": "^1.8.
|
|
107
|
-
"typescript": "^5.
|
|
102
|
+
"style-loader": "^4.0.0",
|
|
103
|
+
"supertest": "^7.0.0",
|
|
104
|
+
"tsc-alias": "^1.8.10",
|
|
105
|
+
"typescript": "^5.4.5"
|
|
108
106
|
},
|
|
109
107
|
"homepage": "https://github.com/siberiacancode/mock-config-server",
|
|
110
108
|
"repository": {
|