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.
Just keep following latest node.js version.
-
Create
get
,post
,put
ordelete
JavaScript files in directoryroutes
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
For further updates, please follow my blog and GitHub repository wejsserver.
Copyright (c) 2016 Nicolas Wan