🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@john-yuan/dev-server

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@john-yuan/dev-server

A simple server based on express. Can be used to start a static file server very quick. Also support route definition.

Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
5
66.67%
Maintainers
1
Weekly downloads
 
Created
Source

Dev Server

A simple server based on express. Can be used to start a static file server very quick. Also support route definition.

Install

This module is published to NPM, you can install it with the following command:

npm i @john-yuan/dev-server

Note that this module is not fully tested, so keep this in mind, before you use it.

Example

var server = require('@john-yuan/dev-server');

// The `server.start` method returns an instance of `Express`
var app = server.start({
    // The web root directory. If it is a relative path, it is based on process.cwd()
    webroot: 'web',
    // The path of the index file. It is based on `webroot`
    index: 'index.html',
    // The host to listen
    host: '0.0.0.0',
    // The port to listen
    port: 8080,
    // Whether to try next port (`port` + 1), if the `port` is not available
    tryNextPort: true,
    // Whether to print access log to console
    printAccessLog: false,
    // The options passed to express.static
    serveStaticOptions: null
}, function () {
    // console.log('server statred');
});

// You can define your extra routes here
app.get('/api/test', function (req, res) {
    res.send('This is response of /api/test');
});

Screenshot

Bash screenshot

Keywords

static

FAQs

Package last updated on 02 Feb 2019

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