Neato Polyester Material
Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

servey

5.2.4 • Public • Published

Servey

A configuration based async/await server. Server module for building API, SPA, and WEB applications.

Overview

Single page application mode all request will check to see if the requested path exists on the file system. Otherwise it will serve the default file index.html. See the test directory for more advanced examples.

API

Api documentation can be found at API.md

Features

  • api
  • async/await
  • static files server
  • built in auth handling
  • no external dependencies
  • plugin/tool extend-ability
  • spa/single page application
    • redirects all urls with out extensions and wih .html to the root file

Install

npm i servey --save

Example

    const Servey = require('servey');
 
    const routes = [
        {
            path: '*',
            method: 'get',
            handler: async function (req, res) {
                return await this.plugin.static({
                    spa: true,
                    path: this.path,
                    folder: './test/static'
                });
            }
        }
    ];
 
    const options = {
        port: 8080,
        routes: routes,
        hostname: 'localhost',
    };
 
    const server = new Servey(options);
 
    server.on('error', function (error) {
        console.error(error);
    });
 
    server.on('request', function (req) {
        console.log(req.url);
    });
 
    server.on('open', function () {
        console.log('open');
    });
 
    server.on('close', function () {
        console.log('close');
    });
 
    await server.open();

Tools

Authors

AlexanderElias

License

Why You Should Choose MPL-2.0 This project is licensed under the MPL-2.0 License

install

npm i servey

Downloadsweekly downloads

154

version

5.2.4

license

MPL-2.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability