Natural Preference for Minification
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

servey

4.0.2 • Public • Published

Servey

A configuration based async/await server.

Overview

Server module for building API and WEB applications. In 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.

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

101

version

4.0.2

license

MPL-2.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability