🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

simple-test-server

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-test-server

Create simple test server

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

Simple Test Server

Create simple test server

Installation

You probably want to install this as a dev dependency...

npm install -D simple-test-server

Usage

const createTestServer = require("simple-test-server");

const PORT = 8080;
const routes = {
  "/hello": {
    status: 200,
    body: "Hello world!",
    headers: { "content-type": "text/plain" },
  },
  "default": {
    status: 404,
    body: "Not found",
    headers: { "content-type": "text/plain" },
  },
};

// This returns a promise
createTestServer(PORT, routes)

// After the promise returned from createTestServer resolves, requests to
// "/hello" will respond with 200, "Hello world!", with all other requests
// responding with 404, "Not found".

Keywords

simple

FAQs

Package last updated on 26 Aug 2017

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