mock-config-server 2.4.0 → 3.0.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/LICENSE +21 -21
- package/README.md +502 -326
- package/package.json +113 -113
- package/dist/bin/bin.d.ts +0 -2
- package/dist/bin/bin.js +0 -8
- package/dist/bin/build.d.ts +0 -2
- package/dist/bin/build.js +0 -49
- package/dist/bin/cli.d.ts +0 -1
- package/dist/bin/cli.js +0 -48
- package/dist/bin/helpers/index.d.ts +0 -3
- package/dist/bin/helpers/index.js +0 -19
- package/dist/bin/helpers/resolveConfigFile.d.ts +0 -2
- package/dist/bin/helpers/resolveConfigFile.js +0 -20
- package/dist/bin/helpers/resolveConfigFilePath.d.ts +0 -1
- package/dist/bin/helpers/resolveConfigFilePath.js +0 -39
- package/dist/bin/helpers/resolveExportsFromSourceCode.d.ts +0 -1
- package/dist/bin/helpers/resolveExportsFromSourceCode.js +0 -11
- package/dist/bin/resolveConfigFilePath/resolveConfigFilePath.d.ts +0 -1
- package/dist/bin/resolveConfigFilePath/resolveConfigFilePath.js +0 -39
- package/dist/bin/run.d.ts +0 -6
- package/dist/bin/run.js +0 -17
- package/dist/bin/validateMockServerConfig/validateBaseUrl/validateBaseUrl.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateBaseUrl/validateBaseUrl.js +0 -12
- package/dist/bin/validateMockServerConfig/validateCors/validateCors.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateCors/validateCors.js +0 -82
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateGraphqlConfig.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateGraphqlConfig.js +0 -48
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateRoutes/validateRoutes.d.ts +0 -2
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateRoutes/validateRoutes.js +0 -71
- package/dist/bin/validateMockServerConfig/validateInterceptors/validateInterceptors.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateInterceptors/validateInterceptors.js +0 -21
- package/dist/bin/validateMockServerConfig/validateMockServerConfig.d.ts +0 -2
- package/dist/bin/validateMockServerConfig/validateMockServerConfig.js +0 -30
- package/dist/bin/validateMockServerConfig/validatePort/validatePort.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validatePort/validatePort.js +0 -9
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRestConfig.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRestConfig.js +0 -52
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRoutes/validateRoutes.d.ts +0 -2
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRoutes/validateRoutes.js +0 -105
- package/dist/bin/validateMockServerConfig/validateStaticPath/validateStaticPath.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateStaticPath/validateStaticPath.js +0 -44
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -17
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.d.ts +0 -3
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.js +0 -78
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/index.d.ts +0 -1
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/index.js +0 -17
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.d.ts +0 -2
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.js +0 -30
- package/dist/src/core/graphql/index.d.ts +0 -1
- package/dist/src/core/graphql/index.js +0 -17
- package/dist/src/core/middlewares/cookieParseMiddleware/cookieParseMiddleware.d.ts +0 -2
- package/dist/src/core/middlewares/cookieParseMiddleware/cookieParseMiddleware.js +0 -16
- package/dist/src/core/middlewares/cookieParseMiddleware/helpers/index.d.ts +0 -1
- package/dist/src/core/middlewares/cookieParseMiddleware/helpers/index.js +0 -17
- package/dist/src/core/middlewares/cookieParseMiddleware/helpers/parseCookie/parseCookie.d.ts +0 -3
- package/dist/src/core/middlewares/cookieParseMiddleware/helpers/parseCookie/parseCookie.js +0 -17
- package/dist/src/core/middlewares/corsMiddleware/corsMiddleware.d.ts +0 -3
- package/dist/src/core/middlewares/corsMiddleware/corsMiddleware.js +0 -44
- package/dist/src/core/middlewares/corsMiddleware/helpers/getAllowedOrigins/getAllowedOrigins.d.ts +0 -2
- package/dist/src/core/middlewares/corsMiddleware/helpers/getAllowedOrigins/getAllowedOrigins.js +0 -13
- package/dist/src/core/middlewares/corsMiddleware/helpers/index.d.ts +0 -1
- package/dist/src/core/middlewares/corsMiddleware/helpers/index.js +0 -17
- package/dist/src/core/middlewares/destroyerMiddleware/destroyerMiddleware.d.ts +0 -7
- package/dist/src/core/middlewares/destroyerMiddleware/destroyerMiddleware.js +0 -23
- package/dist/src/core/middlewares/index.d.ts +0 -7
- package/dist/src/core/middlewares/index.js +0 -23
- package/dist/src/core/middlewares/noCorsMiddleware/noCorsMiddleware.d.ts +0 -2
- package/dist/src/core/middlewares/noCorsMiddleware/noCorsMiddleware.js +0 -24
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.d.ts +0 -11
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.js +0 -19
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getLevenshteinDistance/getLevenshteinDistance.d.ts +0 -1
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getLevenshteinDistance/getLevenshteinDistance.js +0 -80
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/getRestUrlSuggestions.d.ts +0 -11
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/getRestUrlSuggestions.js +0 -34
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getActualRestUrlMeaningfulString/getActualRestUrlMeaningfulString.d.ts +0 -1
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getActualRestUrlMeaningfulString/getActualRestUrlMeaningfulString.js +0 -7
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getPatternRestUrlMeaningfulString/getPatternRestUrlMeaningfulString.d.ts +0 -1
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getPatternRestUrlMeaningfulString/getPatternRestUrlMeaningfulString.js +0 -5
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/index.d.ts +0 -2
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/index.js +0 -18
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/index.d.ts +0 -3
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/index.js +0 -19
- package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.d.ts +0 -8
- package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.js +0 -53
- package/dist/src/core/middlewares/requestInterceptorMiddleware/requestInterceptorMiddleware.d.ts +0 -3
- package/dist/src/core/middlewares/requestInterceptorMiddleware/requestInterceptorMiddleware.js +0 -11
- package/dist/src/core/middlewares/staticMiddleware/staticMiddleware.d.ts +0 -3
- package/dist/src/core/middlewares/staticMiddleware/staticMiddleware.js +0 -30
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.d.ts +0 -3
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.js +0 -44
- package/dist/src/core/rest/createRestRoutes/helpers/index.d.ts +0 -1
- package/dist/src/core/rest/createRestRoutes/helpers/index.js +0 -17
- package/dist/src/core/rest/createRestRoutes/helpers/prepareRestRequestConfigs/prepareRestRequestConfigs.d.ts +0 -2
- package/dist/src/core/rest/createRestRoutes/helpers/prepareRestRequestConfigs/prepareRestRequestConfigs.js +0 -32
- package/dist/src/core/rest/index.d.ts +0 -1
- package/dist/src/core/rest/index.js +0 -17
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.js +0 -19
- package/dist/src/server/createMockServer/createMockServer.d.ts +0 -3
- package/dist/src/server/createMockServer/createMockServer.js +0 -60
- package/dist/src/server/index.d.ts +0 -2
- package/dist/src/server/index.js +0 -18
- package/dist/src/server/startMockServer/startMockServer.d.ts +0 -5
- package/dist/src/server/startMockServer/startMockServer.js +0 -20
- package/dist/src/static/views/assets/icons/scheme-dark.svg +0 -3
- package/dist/src/static/views/assets/icons/scheme-light.svg +0 -3
- package/dist/src/static/views/assets/images/404.png +0 -0
- package/dist/src/static/views/assets/images/logo.png +0 -0
- package/dist/src/static/views/assets/images/success.png +0 -0
- package/dist/src/static/views/assets/styles/global.css +0 -88
- package/dist/src/static/views/components/header/index.css +0 -55
- package/dist/src/static/views/components/header/index.ejs +0 -40
- package/dist/src/static/views/components/header/index.js +0 -1
- package/dist/src/static/views/features/scheme/dark.css +0 -12
- package/dist/src/static/views/features/scheme/index.ejs +0 -3
- package/dist/src/static/views/features/scheme/index.js +0 -31
- package/dist/src/static/views/features/scheme/light.css +0 -12
- package/dist/src/static/views/features/tab/index.css +0 -30
- package/dist/src/static/views/features/tab/index.ejs +0 -2
- package/dist/src/static/views/features/tab/index.js +0 -12
- package/dist/src/static/views/pages/404/index.css +0 -10
- package/dist/src/static/views/pages/404/index.ejs +0 -85
- package/dist/src/utils/constants/appPath.d.ts +0 -1
- package/dist/src/utils/constants/appPath.js +0 -4
- package/dist/src/utils/constants/default.d.ts +0 -11
- package/dist/src/utils/constants/default.js +0 -14
- package/dist/src/utils/constants/index.d.ts +0 -2
- package/dist/src/utils/constants/index.js +0 -18
- package/dist/src/utils/helpers/config/index.d.ts +0 -1
- package/dist/src/utils/helpers/config/index.js +0 -17
- package/dist/src/utils/helpers/config/isEntitiesEqual/isEntityValuesEqual.d.ts +0 -1
- package/dist/src/utils/helpers/config/isEntitiesEqual/isEntityValuesEqual.js +0 -29
- package/dist/src/utils/helpers/graphql/getGraphQLInput/getGraphQLInput.d.ts +0 -3
- package/dist/src/utils/helpers/graphql/getGraphQLInput/getGraphQLInput.js +0 -21
- package/dist/src/utils/helpers/graphql/index.d.ts +0 -3
- package/dist/src/utils/helpers/graphql/index.js +0 -19
- package/dist/src/utils/helpers/graphql/parseGraphQLRequest/parseGraphQLRequest.d.ts +0 -3
- package/dist/src/utils/helpers/graphql/parseGraphQLRequest/parseGraphQLRequest.js +0 -12
- package/dist/src/utils/helpers/graphql/parseQuery/parseQuery.d.ts +0 -7
- package/dist/src/utils/helpers/graphql/parseQuery/parseQuery.js +0 -21
- package/dist/src/utils/helpers/index.d.ts +0 -6
- package/dist/src/utils/helpers/index.js +0 -22
- package/dist/src/utils/helpers/interceptors/callRequestInterceptor/callRequestInterceptor.d.ts +0 -8
- package/dist/src/utils/helpers/interceptors/callRequestInterceptor/callRequestInterceptor.js +0 -19
- package/dist/src/utils/helpers/interceptors/callResponseInterceptors/callResponseInterceptors.d.ts +0 -15
- package/dist/src/utils/helpers/interceptors/callResponseInterceptors/callResponseInterceptors.js +0 -52
- package/dist/src/utils/helpers/interceptors/helpers/setDelay.d.ts +0 -1
- package/dist/src/utils/helpers/interceptors/helpers/setDelay.js +0 -8
- package/dist/src/utils/helpers/interceptors/index.d.ts +0 -2
- package/dist/src/utils/helpers/interceptors/index.js +0 -18
- package/dist/src/utils/helpers/isPlainObject/isPlainObject.d.ts +0 -1
- package/dist/src/utils/helpers/isPlainObject/isPlainObject.js +0 -5
- package/dist/src/utils/helpers/sleep.d.ts +0 -1
- package/dist/src/utils/helpers/sleep.js +0 -7
- package/dist/src/utils/helpers/url/convertWin32PathToUnix/convertWin32PathToUnix.d.ts +0 -1
- package/dist/src/utils/helpers/url/convertWin32PathToUnix/convertWin32PathToUnix.js +0 -8
- package/dist/src/utils/helpers/url/getUrlParts/getUrlParts.d.ts +0 -1
- package/dist/src/utils/helpers/url/getUrlParts/getUrlParts.js +0 -6
- package/dist/src/utils/helpers/url/index.d.ts +0 -4
- package/dist/src/utils/helpers/url/index.js +0 -20
- package/dist/src/utils/helpers/url/removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes.d.ts +0 -1
- package/dist/src/utils/helpers/url/removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes.js +0 -5
- package/dist/src/utils/helpers/url/urlJoin/urlJoin.d.ts +0 -1
- package/dist/src/utils/helpers/url/urlJoin/urlJoin.js +0 -14
- package/dist/src/utils/types/graphql.d.ts +0 -34
- package/dist/src/utils/types/graphql.js +0 -2
- package/dist/src/utils/types/index.d.ts +0 -5
- package/dist/src/utils/types/index.js +0 -21
- package/dist/src/utils/types/interceptors.d.ts +0 -30
- package/dist/src/utils/types/interceptors.js +0 -2
- package/dist/src/utils/types/rest.d.ts +0 -39
- package/dist/src/utils/types/rest.js +0 -2
- package/dist/src/utils/types/server.d.ts +0 -47
- package/dist/src/utils/types/server.js +0 -2
- package/dist/src/utils/types/values.d.ts +0 -10
- package/dist/src/utils/types/values.js +0 -2
package/package.json
CHANGED
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "mock-config-server",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Tool that easily and quickly imitates server operation, create full fake api in few steps",
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "SIBERIA CAN CODE 🧊",
|
|
7
|
-
"url": "https://github.com/siberiacancode"
|
|
8
|
-
},
|
|
9
|
-
"contributors": [
|
|
10
|
-
{
|
|
11
|
-
"name": "Dmitry Babin",
|
|
12
|
-
"url": "https://github.com/debabin"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"name": "Nursultan Zianurov",
|
|
16
|
-
"url": "https://github.com/MiaInturi"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"name": "Sergey Kryavkin",
|
|
20
|
-
"url": "https://github.com/RiceWithMeat"
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"main": "./dist/index.js",
|
|
25
|
-
"types": "./dist/index.d.ts",
|
|
26
|
-
"bin": {
|
|
27
|
-
"mock-config-server": "dist/bin/bin.js",
|
|
28
|
-
"mcs": "dist/bin/bin.js"
|
|
29
|
-
},
|
|
30
|
-
"files": [
|
|
31
|
-
"dist"
|
|
32
|
-
],
|
|
33
|
-
"engines": {
|
|
34
|
-
"node": ">=14"
|
|
35
|
-
},
|
|
36
|
-
"scripts": {
|
|
37
|
-
"prepare": "husky install",
|
|
38
|
-
"build": "shx rm -rf dist && tsc -p tsconfig.production.json && tsc-alias -p tsconfig.production.json && shx cp -R src/static dist/src/static",
|
|
39
|
-
"start": "yarn build && node ./dist/bin/bin.js",
|
|
40
|
-
"dev": "nodemon --watch src --watch bin --watch mock-server.config.* -e js,ts,ejs --exec \"yarn start\"",
|
|
41
|
-
"test": "jest",
|
|
42
|
-
"type": "tsc --noEmit",
|
|
43
|
-
"lint": "eslint . --ext ts --no-error-on-unmatched-pattern",
|
|
44
|
-
"stylelint": "stylelint \"src/static/**/*.css\"",
|
|
45
|
-
"format": "prettier --write {src,bin}/**/*.ts",
|
|
46
|
-
"pretty": "yarn
|
|
47
|
-
},
|
|
48
|
-
"lint-staged": {
|
|
49
|
-
"*.css": "yarn stylelint",
|
|
50
|
-
"*.js": "yarn format",
|
|
51
|
-
"*.ts": "yarn pretty"
|
|
52
|
-
},
|
|
53
|
-
"dependencies": {
|
|
54
|
-
"@types/body-parser": "^1.19.2",
|
|
55
|
-
"@types/express": "^4.17.17",
|
|
56
|
-
"@types/flat": "^5.0.2",
|
|
57
|
-
"@types/yargs": "^17.0.24",
|
|
58
|
-
"ansi-colors": "^4.1.3",
|
|
59
|
-
"body-parser": "^1.20.0",
|
|
60
|
-
"ejs": "^3.1.9",
|
|
61
|
-
"esbuild": "^0.17
|
|
62
|
-
"express": "^4.18.1",
|
|
63
|
-
"flat": "^5.0.2",
|
|
64
|
-
"graphql": "^16.6.0",
|
|
65
|
-
"please-upgrade-node": "^3.2.0",
|
|
66
|
-
"shx": "^0.3.4",
|
|
67
|
-
"yargs": "^17.7.1"
|
|
68
|
-
},
|
|
69
|
-
"devDependencies": {
|
|
70
|
-
"@types/jest": "^29.4.0",
|
|
71
|
-
"@types/supertest": "^2.0.12",
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
73
|
-
"@typescript-eslint/parser": "^
|
|
74
|
-
"eslint": "^8.35.0",
|
|
75
|
-
"eslint-config-airbnb": "^19.0.4",
|
|
76
|
-
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
77
|
-
"eslint-config-prettier": "^8.7.0",
|
|
78
|
-
"eslint-import-resolver-typescript": "^3.4.1",
|
|
79
|
-
"eslint-plugin-import": "^2.27.5",
|
|
80
|
-
"eslint-plugin-prettier": "^
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"supertest": "^6.3.3",
|
|
92
|
-
"ts-jest": "^29.0.3",
|
|
93
|
-
"tsc-alias": "^1.8.5",
|
|
94
|
-
"typescript": "^
|
|
95
|
-
},
|
|
96
|
-
"homepage": "https://github.com/siberiacancode/mock-config-server",
|
|
97
|
-
"repository": {
|
|
98
|
-
"type": "git",
|
|
99
|
-
"url": "https://github.com/siberiacancode/mock-config-server.git"
|
|
100
|
-
},
|
|
101
|
-
"keywords": [
|
|
102
|
-
"server",
|
|
103
|
-
"fake",
|
|
104
|
-
"REST",
|
|
105
|
-
"rest",
|
|
106
|
-
"API",
|
|
107
|
-
"api",
|
|
108
|
-
"mock",
|
|
109
|
-
"mocking",
|
|
110
|
-
"config",
|
|
111
|
-
"data"
|
|
112
|
-
]
|
|
113
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "mock-config-server",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Tool that easily and quickly imitates server operation, create full fake api in few steps",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "SIBERIA CAN CODE 🧊",
|
|
7
|
+
"url": "https://github.com/siberiacancode"
|
|
8
|
+
},
|
|
9
|
+
"contributors": [
|
|
10
|
+
{
|
|
11
|
+
"name": "Dmitry Babin",
|
|
12
|
+
"url": "https://github.com/debabin"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "Nursultan Zianurov",
|
|
16
|
+
"url": "https://github.com/MiaInturi"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "Sergey Kryavkin",
|
|
20
|
+
"url": "https://github.com/RiceWithMeat"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"bin": {
|
|
27
|
+
"mock-config-server": "dist/bin/bin.js",
|
|
28
|
+
"mcs": "dist/bin/bin.js"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=14"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"prepare": "husky install",
|
|
38
|
+
"build": "shx rm -rf dist && tsc -p tsconfig.production.json && tsc-alias -p tsconfig.production.json && shx cp -R src/static dist/src/static",
|
|
39
|
+
"start": "yarn build && node ./dist/bin/bin.js",
|
|
40
|
+
"dev": "nodemon --watch src --watch bin --watch mock-server.config.* -e js,ts,ejs --exec \"yarn start\"",
|
|
41
|
+
"test": "jest",
|
|
42
|
+
"type": "tsc --noEmit",
|
|
43
|
+
"lint": "eslint . --ext ts --no-error-on-unmatched-pattern",
|
|
44
|
+
"stylelint": "stylelint \"src/static/**/*.css\"",
|
|
45
|
+
"format": "prettier --write \"{src,bin}/**/*.ts\"",
|
|
46
|
+
"pretty": "yarn format && yarn lint --fix && yarn type"
|
|
47
|
+
},
|
|
48
|
+
"lint-staged": {
|
|
49
|
+
"*.css": "yarn stylelint",
|
|
50
|
+
"*.js": "yarn format",
|
|
51
|
+
"*.ts": "yarn pretty"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@types/body-parser": "^1.19.2",
|
|
55
|
+
"@types/express": "^4.17.17",
|
|
56
|
+
"@types/flat": "^5.0.2",
|
|
57
|
+
"@types/yargs": "^17.0.24",
|
|
58
|
+
"ansi-colors": "^4.1.3",
|
|
59
|
+
"body-parser": "^1.20.0",
|
|
60
|
+
"ejs": "^3.1.9",
|
|
61
|
+
"esbuild": "^0.18.17",
|
|
62
|
+
"express": "^4.18.1",
|
|
63
|
+
"flat": "^5.0.2",
|
|
64
|
+
"graphql": "^16.6.0",
|
|
65
|
+
"please-upgrade-node": "^3.2.0",
|
|
66
|
+
"shx": "^0.3.4",
|
|
67
|
+
"yargs": "^17.7.1"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@types/jest": "^29.4.0",
|
|
71
|
+
"@types/supertest": "^2.0.12",
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^6.2.0",
|
|
73
|
+
"@typescript-eslint/parser": "^6.2.0",
|
|
74
|
+
"eslint": "^8.35.0",
|
|
75
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
76
|
+
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
77
|
+
"eslint-config-prettier": "^8.7.0",
|
|
78
|
+
"eslint-import-resolver-typescript": "^3.4.1",
|
|
79
|
+
"eslint-plugin-import": "^2.27.5",
|
|
80
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
81
|
+
"husky": "^8.0.1",
|
|
82
|
+
"jest": "^29.4.2",
|
|
83
|
+
"lint-staged": "^13.1.1",
|
|
84
|
+
"nodemon": "^3.0.1",
|
|
85
|
+
"prettier": "^3.0.0",
|
|
86
|
+
"style-loader": "^3.3.2",
|
|
87
|
+
"stylelint": "^15.6.1",
|
|
88
|
+
"stylelint-config-prettier": "^9.0.5",
|
|
89
|
+
"stylelint-config-standard": "^34.0.0",
|
|
90
|
+
"stylelint-order": "^6.0.3",
|
|
91
|
+
"supertest": "^6.3.3",
|
|
92
|
+
"ts-jest": "^29.0.3",
|
|
93
|
+
"tsc-alias": "^1.8.5",
|
|
94
|
+
"typescript": "^5.1.6"
|
|
95
|
+
},
|
|
96
|
+
"homepage": "https://github.com/siberiacancode/mock-config-server",
|
|
97
|
+
"repository": {
|
|
98
|
+
"type": "git",
|
|
99
|
+
"url": "https://github.com/siberiacancode/mock-config-server.git"
|
|
100
|
+
},
|
|
101
|
+
"keywords": [
|
|
102
|
+
"server",
|
|
103
|
+
"fake",
|
|
104
|
+
"REST",
|
|
105
|
+
"rest",
|
|
106
|
+
"API",
|
|
107
|
+
"api",
|
|
108
|
+
"mock",
|
|
109
|
+
"mocking",
|
|
110
|
+
"config",
|
|
111
|
+
"data"
|
|
112
|
+
]
|
|
113
|
+
}
|
package/dist/bin/bin.d.ts
DELETED
package/dist/bin/bin.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const pleaseUpgradeNode = require('please-upgrade-node');
|
|
5
|
-
const packageJson = require('../../package.json');
|
|
6
|
-
pleaseUpgradeNode(packageJson);
|
|
7
|
-
const { cli } = require('./cli');
|
|
8
|
-
cli();
|
package/dist/bin/build.d.ts
DELETED
package/dist/bin/build.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.build = void 0;
|
|
4
|
-
const esbuild_1 = require("esbuild");
|
|
5
|
-
const helpers_1 = require("./helpers");
|
|
6
|
-
const run_1 = require("./run");
|
|
7
|
-
const build = async (argv) => {
|
|
8
|
-
const configFilePath = (0, helpers_1.resolveConfigFilePath)(argv.config);
|
|
9
|
-
if (!configFilePath) {
|
|
10
|
-
throw new Error('Cannot find config file mock-server.config.(ts|mts|cts|js|mjs|cjs)');
|
|
11
|
-
}
|
|
12
|
-
const buildOptions = {
|
|
13
|
-
entryPoints: [configFilePath],
|
|
14
|
-
bundle: true,
|
|
15
|
-
platform: 'node',
|
|
16
|
-
target: 'esnext',
|
|
17
|
-
minifySyntax: true,
|
|
18
|
-
minify: true,
|
|
19
|
-
write: false,
|
|
20
|
-
metafile: false,
|
|
21
|
-
logLevel: 'info',
|
|
22
|
-
plugins: []
|
|
23
|
-
};
|
|
24
|
-
if (argv.watch) {
|
|
25
|
-
const watchPlugin = {
|
|
26
|
-
name: 'watch',
|
|
27
|
-
setup: (build) => {
|
|
28
|
-
let instance;
|
|
29
|
-
build.onStart(() => {
|
|
30
|
-
instance?.destroy();
|
|
31
|
-
});
|
|
32
|
-
build.onEnd((result) => {
|
|
33
|
-
if (!result.errors.length) {
|
|
34
|
-
const mockConfig = (0, helpers_1.resolveConfigFile)(result.outputFiles[0].text);
|
|
35
|
-
instance = (0, run_1.run)(mockConfig, argv);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
buildOptions.plugins.push(watchPlugin);
|
|
41
|
-
const ctx = await (0, esbuild_1.context)(buildOptions);
|
|
42
|
-
ctx.watch();
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const { outputFiles } = await (0, esbuild_1.build)(buildOptions);
|
|
46
|
-
const mockConfig = (0, helpers_1.resolveConfigFile)(outputFiles[0].text);
|
|
47
|
-
(0, run_1.run)(mockConfig, argv);
|
|
48
|
-
};
|
|
49
|
-
exports.build = build;
|
package/dist/bin/cli.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const cli: () => void;
|
package/dist/bin/cli.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
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.cli = void 0;
|
|
7
|
-
const yargs_1 = __importDefault(require("yargs"));
|
|
8
|
-
const helpers_1 = require("yargs/helpers");
|
|
9
|
-
const build_1 = require("./build");
|
|
10
|
-
const cli = () => {
|
|
11
|
-
const argv = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
12
|
-
.usage('mcs [options]')
|
|
13
|
-
.epilogue('More info: https://github.com/siberiacancode/mock-config-server#readme')
|
|
14
|
-
.options({
|
|
15
|
-
baseUrl: {
|
|
16
|
-
alias: 'b',
|
|
17
|
-
description: 'Set base url for mock server',
|
|
18
|
-
type: 'string'
|
|
19
|
-
},
|
|
20
|
-
port: {
|
|
21
|
-
alias: 'p',
|
|
22
|
-
description: 'Set port for server',
|
|
23
|
-
type: 'number'
|
|
24
|
-
},
|
|
25
|
-
staticPath: {
|
|
26
|
-
alias: 's',
|
|
27
|
-
description: 'Set static path for mock server',
|
|
28
|
-
type: 'string'
|
|
29
|
-
},
|
|
30
|
-
config: {
|
|
31
|
-
alias: 'c',
|
|
32
|
-
description: 'Set path to config file',
|
|
33
|
-
type: 'string'
|
|
34
|
-
},
|
|
35
|
-
watch: {
|
|
36
|
-
alias: 'w',
|
|
37
|
-
description: 'Enables server restart after config file changes',
|
|
38
|
-
type: 'boolean'
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
.version()
|
|
42
|
-
.alias('version', 'v')
|
|
43
|
-
.help()
|
|
44
|
-
.alias('help', 'h')
|
|
45
|
-
.parse();
|
|
46
|
-
(0, build_1.build)(argv);
|
|
47
|
-
};
|
|
48
|
-
exports.cli = cli;
|
|
@@ -1,19 +0,0 @@
|
|
|
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("./resolveConfigFile"), exports);
|
|
18
|
-
__exportStar(require("./resolveConfigFilePath"), exports);
|
|
19
|
-
__exportStar(require("./resolveExportsFromSourceCode"), exports);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveConfigFile = void 0;
|
|
4
|
-
const helpers_1 = require("../../src/utils/helpers");
|
|
5
|
-
const resolveExportsFromSourceCode_1 = require("./resolveExportsFromSourceCode");
|
|
6
|
-
const resolveConfigFile = (configSourceCode) => {
|
|
7
|
-
if (!configSourceCode) {
|
|
8
|
-
throw new Error('Cannot handle source code of mock-server.config.(ts|js)');
|
|
9
|
-
}
|
|
10
|
-
const mockServerConfigExports = (0, resolveExportsFromSourceCode_1.resolveExportsFromSourceCode)(configSourceCode);
|
|
11
|
-
const mockServerConfig = mockServerConfigExports.default;
|
|
12
|
-
if (!mockServerConfig) {
|
|
13
|
-
throw new Error('Cannot handle exports of mock-server.config.(ts|js)');
|
|
14
|
-
}
|
|
15
|
-
if (!(0, helpers_1.isPlainObject)(mockServerConfig)) {
|
|
16
|
-
throw new Error('configuration should be plain object; see our doc (https://www.npmjs.com/package/mock-config-server) for more information');
|
|
17
|
-
}
|
|
18
|
-
return mockServerConfig;
|
|
19
|
-
};
|
|
20
|
-
exports.resolveConfigFile = resolveConfigFile;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const resolveConfigFilePath: (cliConfigFilePath?: string) => string | undefined;
|
|
@@ -1,39 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.resolveConfigFilePath = void 0;
|
|
30
|
-
const fs = __importStar(require("fs"));
|
|
31
|
-
const path_1 = __importDefault(require("path"));
|
|
32
|
-
const resolveConfigFilePath = (cliConfigFilePath) => {
|
|
33
|
-
const appPath = process.cwd();
|
|
34
|
-
if (cliConfigFilePath)
|
|
35
|
-
return path_1.default.resolve(appPath, cliConfigFilePath);
|
|
36
|
-
const configFileNameRegex = /mock-server.config.(?:ts|mts|cts|js|mjs|cjs)/;
|
|
37
|
-
return fs.readdirSync(appPath).find((fileName) => configFileNameRegex.test(fileName));
|
|
38
|
-
};
|
|
39
|
-
exports.resolveConfigFilePath = resolveConfigFilePath;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const resolveExportsFromSourceCode: (sourceCode: string) => any;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveExportsFromSourceCode = void 0;
|
|
4
|
-
const resolveExportsFromSourceCode = (sourceCode) => {
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
const moduleInstance = new module.constructor();
|
|
7
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
8
|
-
moduleInstance._compile(sourceCode, '');
|
|
9
|
-
return moduleInstance.exports;
|
|
10
|
-
};
|
|
11
|
-
exports.resolveExportsFromSourceCode = resolveExportsFromSourceCode;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const resolveConfigFilePath: (cliConfigFilePath?: string) => string | undefined;
|
|
@@ -1,39 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.resolveConfigFilePath = void 0;
|
|
30
|
-
const fs = __importStar(require("fs"));
|
|
31
|
-
const path_1 = __importDefault(require("path"));
|
|
32
|
-
const resolveConfigFilePath = (cliConfigFilePath) => {
|
|
33
|
-
const appPath = process.cwd();
|
|
34
|
-
if (cliConfigFilePath)
|
|
35
|
-
return path_1.default.resolve(appPath, cliConfigFilePath);
|
|
36
|
-
const configFileNameRegex = /mock-server.config.(?:ts|mts|cts|js|mjs|cjs)/;
|
|
37
|
-
return fs.readdirSync(appPath).find((fileName) => configFileNameRegex.test(fileName));
|
|
38
|
-
};
|
|
39
|
-
exports.resolveConfigFilePath = resolveConfigFilePath;
|
package/dist/bin/run.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import type { MockServerConfig, MockServerConfigArgv } from '../src';
|
|
4
|
-
export declare const run: (mockConfig: MockServerConfig, argv: MockServerConfigArgv) => (import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> & {
|
|
5
|
-
destroy: (callback?: ((err?: Error | undefined) => void) | undefined) => import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
|
6
|
-
}) | undefined;
|
package/dist/bin/run.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.run = void 0;
|
|
5
|
-
const server_1 = require("../src/server");
|
|
6
|
-
const validateMockServerConfig_1 = require("./validateMockServerConfig/validateMockServerConfig");
|
|
7
|
-
const run = (mockConfig, argv) => {
|
|
8
|
-
try {
|
|
9
|
-
const mergedMockServerConfig = { ...mockConfig, ...argv };
|
|
10
|
-
(0, validateMockServerConfig_1.validateMockServerConfig)(mergedMockServerConfig);
|
|
11
|
-
return (0, server_1.startMockServer)(mergedMockServerConfig);
|
|
12
|
-
}
|
|
13
|
-
catch (error) {
|
|
14
|
-
console.error(error.message);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
exports.run = run;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const validateBaseUrl: (baseUrl: unknown) => void;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateBaseUrl = void 0;
|
|
4
|
-
const validateBaseUrl = (baseUrl) => {
|
|
5
|
-
if (typeof baseUrl !== 'string' && typeof baseUrl !== 'undefined') {
|
|
6
|
-
throw new Error('baseUrl');
|
|
7
|
-
}
|
|
8
|
-
if (typeof baseUrl === 'string' && !baseUrl.startsWith('/')) {
|
|
9
|
-
throw new Error('baseUrl');
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
exports.validateBaseUrl = validateBaseUrl;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const validateCors: (cors: unknown) => void;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateCors = void 0;
|
|
4
|
-
const helpers_1 = require("../../../src/utils/helpers");
|
|
5
|
-
const validateOrigin = (origin) => {
|
|
6
|
-
const isOriginArray = Array.isArray(origin);
|
|
7
|
-
if (isOriginArray) {
|
|
8
|
-
origin.forEach((originElement, index) => {
|
|
9
|
-
const isOriginElementStringOrRegExp = typeof originElement === 'string' || originElement instanceof RegExp;
|
|
10
|
-
if (!isOriginElementStringOrRegExp) {
|
|
11
|
-
throw new Error(`origin[${index}]`);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const isOriginStringOrRegexp = typeof origin === 'string' || origin instanceof RegExp;
|
|
17
|
-
const isOriginFunction = typeof origin === 'function';
|
|
18
|
-
if (!isOriginStringOrRegexp && !isOriginFunction) {
|
|
19
|
-
throw new Error('origin');
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const validateMethods = (methods) => {
|
|
23
|
-
const isMethodsArray = Array.isArray(methods);
|
|
24
|
-
if (isMethodsArray) {
|
|
25
|
-
const allowedMethods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'];
|
|
26
|
-
methods.forEach((method, index) => {
|
|
27
|
-
// ✅ important:
|
|
28
|
-
// compare without 'toUpperCase' because 'Access-Control-Allow-Methods' value is case-sensitive
|
|
29
|
-
if (!allowedMethods.includes(method)) {
|
|
30
|
-
throw new Error(`methods[${index}]`);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if (typeof methods !== 'undefined') {
|
|
36
|
-
throw new Error('methods');
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const validateHeaders = (headers) => {
|
|
40
|
-
const isHeadersArray = Array.isArray(headers);
|
|
41
|
-
if (isHeadersArray) {
|
|
42
|
-
headers.forEach((header, index) => {
|
|
43
|
-
if (typeof header !== 'string') {
|
|
44
|
-
throw new Error(`headers[${index}]`);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (typeof headers !== 'undefined') {
|
|
50
|
-
throw new Error('headers');
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const validateCredentials = (credentials) => {
|
|
54
|
-
if (typeof credentials !== 'boolean' && typeof credentials !== 'undefined') {
|
|
55
|
-
throw new Error('credentials');
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const validateMaxAge = (maxAge) => {
|
|
59
|
-
if (typeof maxAge !== 'number' && typeof maxAge !== 'undefined') {
|
|
60
|
-
throw new Error('maxAge');
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const validateCors = (cors) => {
|
|
64
|
-
const isCorsObject = (0, helpers_1.isPlainObject)(cors);
|
|
65
|
-
if (isCorsObject) {
|
|
66
|
-
try {
|
|
67
|
-
validateOrigin(cors.origin);
|
|
68
|
-
validateMethods(cors.methods);
|
|
69
|
-
validateHeaders(cors.headers);
|
|
70
|
-
validateCredentials(cors.credentials);
|
|
71
|
-
validateMaxAge(cors.maxAge);
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
throw new Error(`cors.${error.message}`);
|
|
75
|
-
}
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (typeof cors !== 'undefined') {
|
|
79
|
-
throw new Error('cors');
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
exports.validateCors = validateCors;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const validateGraphqlConfig: (graphqlConfig: unknown) => void;
|