expring

1.0.4-alpha • Public • Published

expring

Example

SimpleService.js:

let expring = require('expring');
 
class SimpleService extends expring.Service {
    constructor() {
        super('SimpleService');
    }
}
 
let simpleService = new SimpleService();
 
simpleService.addMethods([{
    name: 'example',
    fn: () => 'Hello, Expring!'
}])
 
module.exports = simpleService;

SimpleController.js:

let expring = require('expring');
 
let SimpleService = require('SimpleService.js');
 
class SimpleController extends expring.Controller {
    constructor() {
        super('SimpleController');
    }
}
 
let simpleController = new SimpleController();
simpleController.setRequests([
    {
        url: '/',
        type: 'GET',
        fn: (req, res) => {
            res.send(SimpleService.example);
        }
    }
]);
 
module.exports = simpleController;

main.js:

let expring = require('expring');
 
let app = expring();
 
let SimpleController = require('SimpleController.js');
SimpleController.init(app);
 
app.listen(9001);

You can use built-in Services:

let LogService = expring.Services.LogService; // uses log4js
 
// TODO more built-in Services

Readme

Keywords

Package Sidebar

Install

npm i expring

Weekly Downloads

2

Version

1.0.4-alpha

License

ISC

Last publish

Collaborators

  • octav47