1.0.2 • Published 8 years ago

wejsserver v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

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