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

supertest-prefix

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

supertest-prefix

An extension to supertest which adds prefix to the routes

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.9K
decreased by-7.48%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

Supertest Prefix

An extension to supertest which adds a prefix to the routes

Usage

import request from 'supertest';
import supertestPrefix from 'supertest-prefix';

// Creates the prefix
const prefix = supertestPrefix('/api');

// Uses the prefix
await request
  .get('/cars') // Becomes /api/cars
  .use(prefix)
  .expect(200);

await request
  .get('http://localhost:3000/cars') // Becomes http://localhost:3000/api/cars
  .use(prefix)
  .expect(200);

Using with npm 'superagent-defaults'

https://www.npmjs.com/package/superagent-defaults

import supertest from 'supertest';
import defaults from 'superagent-defaults';
import supertestPrefix from 'supertest-prefix';

// Creates the prefix
const prefix = supertestPrefix('/api');

// Create a defaults context
var request = defaults();

// Setup prefix as a default config
request
  .use(prefix);

// Use supertest like you always have; the prefix will be applied to each request automatically
await request
  .get('/cars')
  .expect(200);

Contributors

Would you like to contribute to this library? Don't be shy! Contact me if you are interested on it.

Keywords

FAQs

Package last updated on 21 Feb 2018

Did you know?

Socket

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.

Install

Related posts

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