wejsserver

We (micro) JavaScript Written Server Based on Express And MongoDB


Keywords
toolkit, cli, server, express, mongodb
License
MIT
Install
npm install wejsserver@1.0.2

Documentation

Downloads Version License

WeJsServer

WeJsServer is a we (micro) JavaScript written server based on express and mongodb. Core features include:

  • Fast and simple routes deployment based on file structure
  • Simple mongodb CRUD API
  • Extensible configuration definitions and processors
  • Lean and extensible core

Note that WeJsServer will be intergrated into nicolas1.1.

Requires

Just keep following latest node.js version.

How to use

  • Create get, post, put or delete JavaScript files in directory routes like /routes/api/sample/post.js below:

    'use strict';
    
    module.exports = (req, res, db, idGenerator, shaGenerator) => {
    
        let data = req.body.data || {};
    
        db.insert({
    
            model: 'sample',
    
            data: {
                _id: idGenerator.id(),
                name: data.name || 'unknown'
            },
    
            callback: data => {
    
                res.send({
                    code: 0,
                    msg: 'success',
                    data: data[0]
                });
            }
        });
    };
    
  • Change directory to /bin, type the following command:

    node start
    

Stay in Touch

For further updates, please follow my blog and GitHub repository wejsserver.

License

MIT

Copyright (c) 2016 Nicolas Wan