express-mock-api-middleware
Advanced tools
Comparing version 0.0.1-1.test to 0.0.1
@@ -1,2 +0,1 @@ | ||
import { existsSync } from 'fs'; | ||
import { join, basename } from 'path'; | ||
@@ -16,5 +15,3 @@ import bodyParser from 'body-parser'; | ||
const absMockPath = mockDir; | ||
const absConfigPath = join(mockDir, '.umirc.mock.js'); | ||
const absPagesPath = join(mockDir, 'pages'); | ||
const debug = console.debug; | ||
const { debug } = console; | ||
const errors = []; | ||
@@ -27,8 +24,5 @@ | ||
if (process.env.WATCH_FILES === 'none') return; | ||
const watcher = chokidar.watch( | ||
[absConfigPath, absMockPath, join(absPagesPath, '**/_mock.js')], | ||
{ | ||
ignoreInitial: true, | ||
} | ||
); | ||
const watcher = chokidar.watch([absMockPath], { | ||
ignoreInitial: true, | ||
}); | ||
watcher.on('all', (event, file) => { | ||
@@ -49,33 +43,21 @@ debug(`[${event}] ${file}, reload mock data`); | ||
let ret = {}; | ||
if (existsSync(absConfigPath)) { | ||
debug(`load mock data from ${absConfigPath}`); | ||
ret = require(absConfigPath); // eslint-disable-line | ||
} else { | ||
const mockFiles = glob | ||
.sync('**/*.js', { | ||
cwd: absMockPath, | ||
}) | ||
.map(p => join(absMockPath, p)) | ||
.concat( | ||
glob | ||
.sync('**/_mock.js', { | ||
cwd: absPagesPath, | ||
}) | ||
.map(p => join(absPagesPath, p)) | ||
); | ||
debug(`load mock data from ${absMockPath}, including files ${JSON.stringify(mockFiles)}`); | ||
try { | ||
ret = mockFiles.reduce((memo, mockFile) => { | ||
const m = require(mockFile); // eslint-disable-line | ||
memo = { | ||
...memo, | ||
...(m.default || m), | ||
}; | ||
return memo; | ||
}, {}); | ||
} catch (e) { | ||
errors.push(e); | ||
signale.error(`Mock file parse failed`); | ||
console.error(e.message); | ||
} | ||
const mockFiles = glob | ||
.sync('**/*.js', { | ||
cwd: absMockPath, | ||
}) | ||
.map(p => join(absMockPath, p)); | ||
debug(`load mock data from ${absMockPath}, including files ${JSON.stringify(mockFiles)}`); | ||
try { | ||
ret = mockFiles.reduce((memo, mockFile) => { | ||
const m = require(mockFile); // eslint-disable-line | ||
memo = { | ||
...memo, | ||
...(m.default || m), | ||
}; | ||
return memo; | ||
}, {}); | ||
} catch (e) { | ||
errors.push(e); | ||
signale.error(`Mock file parse failed`); | ||
console.error(e.message); | ||
} | ||
@@ -151,7 +133,3 @@ return normalizeConfig(ret); | ||
Object.keys(require.cache).forEach(file => { | ||
if ( | ||
file === absConfigPath || | ||
file.indexOf(absMockPath) > -1 || | ||
basename(file) === '_mock.js' | ||
) { | ||
if (file.indexOf(absMockPath) > -1 || basename(file) === '_mock.js') { | ||
delete require.cache[file]; | ||
@@ -158,0 +136,0 @@ } |
{ | ||
"name": "express-mock-api-middleware", | ||
"version": "0.0.1-001.test", | ||
"description": "Webpack middleware for mocking restful APIs", | ||
"version": "0.0.1", | ||
"description": "Express middleware for mocking restful APIs", | ||
"main": "index.js", | ||
@@ -14,3 +14,3 @@ "scripts": { | ||
"keywords": [ | ||
"webpack", | ||
"express", | ||
"middleware", | ||
@@ -25,3 +25,22 @@ "api", | ||
}, | ||
"homepage": "https://github.com/TechStark/express-mock-api-middleware#readme" | ||
"homepage": "https://github.com/TechStark/express-mock-api-middleware#readme", | ||
"dependencies": { | ||
"assert": "^1.4.1", | ||
"body-parser": "^1.18.3", | ||
"chokidar": "^2.1.2", | ||
"glob": "^7.1.3", | ||
"multer": "^1.4.1", | ||
"path-to-regexp": "^3.0.0", | ||
"signale": "^1.4.0" | ||
}, | ||
"devDependencies": { | ||
"babel-eslint": "^10.0.1", | ||
"eslint": "^5.3.0", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-config-prettier": "^4.1.0", | ||
"eslint-plugin-babel": "^5.3.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-prettier": "^3.0.1", | ||
"prettier": "^1.16.4" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
7162
9
2
0
7
8
187
+ Addedassert@^1.4.1
+ Addedbody-parser@^1.18.3
+ Addedchokidar@^2.1.2
+ Addedglob@^7.1.3
+ Addedmulter@^1.4.1
+ Addedpath-to-regexp@^3.0.0
+ Addedsignale@^1.4.0
+ Addedansi-styles@3.2.1(transitive)
+ Addedanymatch@2.0.0(transitive)
+ Addedappend-field@1.0.0(transitive)
+ Addedarr-diff@4.0.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarr-union@3.1.0(transitive)
+ Addedarray-unique@0.3.2(transitive)
+ Addedassert@1.5.1(transitive)
+ Addedassign-symbols@1.0.0(transitive)
+ Addedasync-each@1.0.6(transitive)
+ Addedatob@2.1.2(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbase@0.11.2(transitive)
+ Addedbinary-extensions@1.13.1(transitive)
+ Addedbindings@1.5.0(transitive)
+ Addedbody-parser@1.20.3(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbraces@2.3.2(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedbusboy@0.2.14(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcache-base@1.0.1(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedchokidar@2.1.8(transitive)
+ Addedclass-utils@0.3.6(transitive)
+ Addedcollection-visit@1.0.0(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedconcat-stream@1.6.2(transitive)
+ Addedcontent-type@1.0.5(transitive)
+ Addedcopy-descriptor@0.1.1(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addeddefine-property@0.2.51.0.02.0.2(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addeddicer@0.2.5(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addederror-ex@1.3.2(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedexpand-brackets@2.1.4(transitive)
+ Addedextend-shallow@2.0.13.0.2(transitive)
+ Addedextglob@2.0.4(transitive)
+ Addedfigures@2.0.0(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedfill-range@4.0.0(transitive)
+ Addedfind-up@2.1.0(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfragment-cache@0.2.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfsevents@1.2.13(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedget-value@2.0.6(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedglob-parent@3.1.0(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhas-value@0.3.11.0.0(transitive)
+ Addedhas-values@0.1.41.0.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.32.0.4(transitive)
+ Addedis-accessor-descriptor@1.0.1(transitive)
+ Addedis-arrayish@0.2.1(transitive)
+ Addedis-binary-path@1.0.1(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-data-descriptor@1.0.1(transitive)
+ Addedis-descriptor@0.1.71.0.3(transitive)
+ Addedis-extendable@0.1.11.0.1(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@3.1.04.0.3(transitive)
+ Addedis-number@3.0.0(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedis-windows@1.0.2(transitive)
+ Addedisarray@0.0.11.0.0(transitive)
+ Addedisobject@2.1.03.0.1(transitive)
+ Addedjson-parse-better-errors@1.0.2(transitive)
+ Addedkind-of@3.2.24.0.06.0.3(transitive)
+ Addedload-json-file@4.0.0(transitive)
+ Addedlocate-path@2.0.0(transitive)
+ Addedmap-cache@0.2.2(transitive)
+ Addedmap-visit@1.0.0(transitive)
+ Addedmedia-typer@0.3.0(transitive)
+ Addedmicromatch@3.1.10(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmixin-deep@1.3.2(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedms@2.0.0(transitive)
+ Addedmulter@1.4.4(transitive)
+ Addednan@2.22.0(transitive)
+ Addednanomatch@1.2.13(transitive)
+ Addednormalize-path@2.1.13.0.0(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedobject-copy@0.1.0(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject-visit@1.0.1(transitive)
+ Addedobject.assign@4.1.5(transitive)
+ Addedobject.pick@1.3.0(transitive)
+ Addedon-finished@2.4.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedp-limit@1.3.0(transitive)
+ Addedp-locate@2.0.0(transitive)
+ Addedp-try@1.0.0(transitive)
+ Addedparse-json@4.0.0(transitive)
+ Addedpascalcase@0.1.1(transitive)
+ Addedpath-dirname@1.0.2(transitive)
+ Addedpath-exists@3.0.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpath-to-regexp@3.3.0(transitive)
+ Addedpify@3.0.0(transitive)
+ Addedpkg-conf@2.1.0(transitive)
+ Addedposix-character-classes@0.1.1(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedraw-body@2.5.2(transitive)
+ Addedreadable-stream@1.1.142.3.8(transitive)
+ Addedreaddirp@2.2.1(transitive)
+ Addedregex-not@1.0.2(transitive)
+ Addedremove-trailing-separator@1.1.0(transitive)
+ Addedrepeat-element@1.1.4(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedresolve-url@0.2.1(transitive)
+ Addedret@0.1.15(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsafe-regex@1.1.0(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedset-value@2.0.1(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedsignale@1.4.0(transitive)
+ Addedsnapdragon@0.8.2(transitive)
+ Addedsnapdragon-node@2.1.1(transitive)
+ Addedsnapdragon-util@3.0.1(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedsource-map-resolve@0.5.3(transitive)
+ Addedsource-map-url@0.4.1(transitive)
+ Addedsplit-string@3.1.0(transitive)
+ Addedstatic-extend@0.1.2(transitive)
+ Addedstatuses@2.0.1(transitive)
+ Addedstreamsearch@0.1.2(transitive)
+ Addedstring_decoder@0.10.311.1.1(transitive)
+ Addedstrip-bom@3.0.0(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedto-object-path@0.3.0(transitive)
+ Addedto-regex@3.0.2(transitive)
+ Addedto-regex-range@2.1.1(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedtype-is@1.6.18(transitive)
+ Addedtypedarray@0.0.6(transitive)
+ Addedunion-value@1.0.1(transitive)
+ Addedunpipe@1.0.0(transitive)
+ Addedunset-value@1.0.0(transitive)
+ Addedupath@1.2.0(transitive)
+ Addedurix@0.1.0(transitive)
+ Addeduse@3.1.1(transitive)
+ Addedutil@0.10.4(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedxtend@4.0.2(transitive)