Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
fixture-middleware
Advanced tools
Readme
Sometimes I want to mock certain paths of my API made with Express. Therefore, I created fixture-middleware which will use fixture data (mock) for any URL that matches a file inside the configured fixture directory.
npm install fixture-middleware --save-dev
yarn add fixture-middleware --dev
const path = require('path')
const express = require('express')
const fixtureMiddleware = require('fixture-middleware')
const app = express()
const fixtureDirectory = path.resolve(__dirname, './fixtures')
app.use(fixtureMiddleware(fixtureDirectory))
All URLs are normalized (all /
will be replaced by --
) and if a Accept
headers is present it will be used to determine the file extension, otherwise the first matching file will be returned.
Suppose we have the following files in the configured fixture directory:
`-- fixtures
|-- users.json
|-- users.html
`-- users--active.json
The following request will match those files as follows
Request | Response |
---|---|
URL: /users Headers: (no accept header) | File: users.html |
URL: /users Headers: accept=application.json | File: users.json |
URL: /users Headers: accept=application.html | File: users.html |
URL: /users/active Headers: (no accept header) | File: users--active.json |
URL: /users/active Headers: accept=application.json | File: users--active.json |
Important: Any unmatched request will be delegated to the next middleware.
yarn test
– to run all tests.yarn test -- --watch
– to run all tests in watch mode.yarn version --new-version x.x.x -m 'Version %s.'
.npm publish
.git push origin --tags
.Made with :heart: by Rubens Mariuzzo.
FAQs
Use fixture data in your express app!
The npm package fixture-middleware receives a total of 0 weekly downloads. As such, fixture-middleware popularity was classified as not popular.
We found that fixture-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.