Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jota-one/drosse

Package Overview
Dependencies
Maintainers
2
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jota-one/drosse - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

CHANGELOG.md

7

app/middlewares/morgan.js
const morgan = require('morgan')
const c = require('ansi-colors')
const useState = require('../use/state')
const state = useState()

@@ -52,2 +54,5 @@ morgan.token('time', function getTime() {

module.exports = morgan(format)
module.exports = morgan(format, {
skip: (req, res) =>
Object.values(state.get('reservedRoutes')).includes(req.url),
})

54

app/use/db.js

@@ -32,3 +32,6 @@ const Loki = require('lokijs')

.chain(res)
.map(file => file.path.split(path.sep).slice(0, -1).join(path.sep))
.map(file => {
const collection = file.path.split(path.sep).slice(0, -1).join(path.sep)
return collection || file.path.split('.').slice(0, -1).join('.')
})
.uniq()

@@ -45,3 +48,3 @@ .map(file => file.split(path.sep).join('.'))

logger.warn(
'collection:',
'📦 collection',
name,

@@ -53,3 +56,3 @@ "already exists and won't be overriden."

logger.warn(
'collection:',
'🌊 collection',
name,

@@ -64,16 +67,37 @@ 'already exists and will be overriden.'

const filesPath = path.join(dirname, name.split('.').join(path.sep))
return fs.readdir(filesPath).then(filenames =>
Promise.all(
filenames
.filter(filename => filename.endsWith('json'))
.map(filename =>
fs
.readFile(path.join(filesPath, filename), 'utf-8')
.then(content => {
logger.success(`loaded ${filename} into collection ${name}`)
return coll.insert(JSON.parse(content))
})
return fs
.readdir(filesPath)
.catch(e => {
logger.warn(e.path, 'is not a directory.')
logger.warn('I try as a JSON file...')
fs.readFile(e.path + '.json', 'utf-8').then(content => {
const files = JSON.parse(content)
if (!Array.isArray(files)) {
logger.error(
'Cannot import collection file into db. It must be an array.'
)
}
files.forEach(file => coll.insert(file))
logger.success(
`Collection successfully imported. ${files.length} files imported.`
)
})
return [] // so that the next then doesn't do anything...
})
.then(filenames =>
Promise.all(
filenames
.filter(filename => filename.endsWith('json'))
.map(filename =>
fs
.readFile(path.join(filesPath, filename), 'utf-8')
.then(content => {
logger.success(
`loaded ${filename} into collection ${name}`
)
return coll.insert(JSON.parse(content))
})
)
)
)
)
})

@@ -80,0 +104,0 @@ )

@@ -28,3 +28,3 @@ #!/usr/bin/env node

app.stdout.on('data', data => {
`${data}`.split('\n').forEach(msg => {
;`${data}`.split('\n').forEach(msg => {
d.send('log', { uuid, msg })

@@ -36,3 +36,3 @@ })

app.stderr.on('data', data => {
`${data}`.split('\n').forEach(msg => {
;`${data}`.split('\n').forEach(msg => {
d.send('log', { uuid, msg })

@@ -39,0 +39,0 @@ })

{
"name": "@jota-one/drosse",
"version": "1.3.0",
"version": "1.4.0",
"description": "Mock your backend the right way.",
"main": "app/index.js",
"bin": {
"drosse": "./bin/drosse.js"
"drosse": "./bin/drosse.js",
"drosse-serve": "./bin/serve.js"
},
"scripts": {
"serve": "./bin/serve.js"
"serve": "./bin/serve.js",
"build": "pkg . --out-path pkg"
},
"pkg": {
"scripts": [
"bin/*.js",
"cmd/*.js",
"app/**/*.js"
]
},
"repository": {

@@ -57,2 +66,3 @@ "type": "git",

"eslint-plugin-standard": "^4.0.1",
"pkg": "^4.4.9",
"prettier": "^2.1.2",

@@ -59,0 +69,0 @@ "standard": "^14.3.4"

@@ -1,2 +0,2 @@

<img src="./Drosse.svg"/>
<img src="https://raw.githubusercontent.com/jota-one/drosse/master/Drosse.svg" style="width:350px;max-width:100%;margin: 25px 0;"/>

@@ -7,3 +7,3 @@ ## What is it ?

## Installation
via [npm](https://www.npmjs.com/package/@jota-one/drosse)
### As [npm](https://www.npmjs.com/package/@jota-one/drosse) dependency in your node project

@@ -19,3 +19,3 @@ 1. Simply install it as a dev dependency of the project you want to mock.

"scripts": {
"mock-server": "npx drosse serve -r path/to/mocks-directory"
"mock-server": "npx drosse-serve -r path/to/mocks-directory"
},

@@ -28,2 +28,28 @@ "devDependencies": {

### As a global [npm](https://www.npmjs.com/package/@jota-one/drosse) package
1. Install drosse globally.
```
npm i -g @jota-one/drosse
```
2. Run it via the `serve` command and your drosse folder as root via the `-r` param.
```
drosse serve -r /path/to/my/my/mocks
```
### As a [Docker image](https://hub.docker.com/r/jotaone/drosse)
You can use a docker image if you don't want to install nodejs runtime on your machine.
**Note** though that you'll have to map your local folder to the container's `data` volume as well as the port your drosse is configured on.
1. Pull the docker image on your computer
```
docker pull jotaone/drosse
```
2. Run the container and map your mocks' path and port
```
docker run -v /path/to/my/mocks:/data -p 8000:8000 jotaone/drosse
```
## Usage

@@ -59,3 +85,3 @@ You need a directory where you will store all your mocks definitions.

":id": {
}

@@ -62,0 +88,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc