@jota-one/drosse
Advanced tools
Comparing version 0.1.0 to 0.1.1
const express = require('express') | ||
const bodyParser = require('body-parser') | ||
const path = require('path') | ||
const { setScope, checkRootFile, getScope, routes } = require('./io') | ||
const { parse } = require('./parser') | ||
const app = express() | ||
const port = process.env.PORT || '8000' | ||
@@ -11,10 +13,25 @@ | ||
// define routes | ||
app.get('*', (req, res) => { | ||
res.send({ drosse: 8000 }); | ||
}) | ||
// start server | ||
module.exports = args => { | ||
console.log(args) | ||
const port = args.port || process.env.PORT || '8000' | ||
setScope('root', path.resolve(args.root) || path.resolve('.')) | ||
if (args.routesFile) { | ||
setScope('routesFile', args.routesFile) | ||
} | ||
// start server | ||
app.listen(port, () => { | ||
console.log(`Listening to requests on http://localhost:${port}`); | ||
}) | ||
// run some checks | ||
if (!checkRootFile()) { | ||
console.error(`Please create a "${getScope('routesFile')}.json" or a "${getScope('routesFile')}.js" file in this directory: ${getScope('root')}, and restart.`) | ||
process.exit() | ||
} | ||
// if everything is well configured, create the routes | ||
const routesDefinition = routes() | ||
parse(app, routesDefinition) | ||
app.listen(port, () => { | ||
console.log(`Listening to requests on http://localhost:${port}`) | ||
console.log(`The mocks will be read/written here: ${getScope('root')}`) | ||
}) | ||
} |
{ | ||
"name": "@jota-one/drosse", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Mock your backend the right way.", | ||
"main": "index.js", | ||
"scripts": { | ||
"serve": "node app" | ||
"serve": "node bin/drosse" | ||
}, | ||
@@ -22,3 +22,4 @@ "repository": { | ||
"body-parser": "^1.19.0", | ||
"express": "^4.17.1" | ||
"express": "^4.17.1", | ||
"yargs": "^15.3.1" | ||
}, | ||
@@ -25,0 +26,0 @@ "devDependencies": { |
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
4203
7
108
3
3
+ Addedyargs@^15.3.1
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedcamelcase@5.3.1(transitive)
+ Addedcliui@6.0.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedfind-up@4.1.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedlocate-path@5.0.0(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@4.1.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedrequire-main-filename@2.0.0(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedwhich-module@2.0.1(transitive)
+ Addedwrap-ansi@6.2.0(transitive)
+ Addedy18n@4.0.3(transitive)
+ Addedyargs@15.4.1(transitive)
+ Addedyargs-parser@18.1.3(transitive)