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

servey

3.3.2 • Public • Published

Servey

Servey it up DOG!

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

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();

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

42

version

3.3.2

license

MPL-2.0

repository

githubgithub

last publish

collaborators

  • avatar