simple-test-server

0.1.1 • Public • Published

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".
 

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i simple-test-server

    Weekly Downloads

    1

    Version

    0.1.1

    License

    ISC

    Last publish

    Collaborators

    • artmllr