Skip to content

EvaEngine/EvaEngine.js

Repository files navigation

EvaEngine For NodeJS

NPM version Build Status Dependencies Status codecov npm License

A micro service development engine for NodeJS.

  • Full DI support (Injected by ES7 decorators as well)
  • ES7 async & await support
  • CLI mode support (easily convert to schedules)
  • Better exceptions design
  • ORM support (Based on Sequelize)
  • Quick test by mocking request & response
  • Builtin cache layer
  • Builtin session / token authentications
  • Http client with fully debugging log
  • Distributed tracing log support (Zipkin compatible)
  • API document generator

Quick Start

Clone this skeleton project to quick start:

EvaSkeleton.js

Run as web server

import { EvaEngine } from 'evaengine';

const engine = new EvaEngine({
  projectRoot: `${__dirname}/..`,
  port: 3000
});

engine.bootstrap();
engine.use('/', (req, res) => {
  res.json({ hello: 'world' });
});
engine.run();

Then visit http://localhost:3000 to view API.

Run as CLI

import { EvaEngine } from 'evaengine';
import * as UserCommands from './commands/user';
const engine = new EvaEngine({
  projectRoot: `${__dirname}/..`
}, 'cli');
engine.registerCommands(UserCommands);
(async() => {
    await engine.runCLI();
})();

Run as Cron Job

import { EvaEngine } from 'evaengine';
import * as HelloWorldCommands from './commands/hello_world';

const engine = new EvaEngine({
  projectRoot: `${__dirname}/..`
}, 'cli');
engine.registerCommands([
  HelloWorldCommands
]);

engine.runCrontab('0/10 * * * * *', 'hello:world --id=EvaEngine');

Swagger Support

Process as follow:

  • ES7 Files =(Babel)=>
  • ES5 Files =(acorn)=>
  • AST =(filter)=>
  • Annotations =(doctrine)=>
  • JsDocs =(convert)=>
  • Fragments + EvaEngine Exceptions + Sequelize Models =(Merge & Compile)=>
  • Swagger Specification JSON File

Debug with Projects

cd EvaNode
npm link
cd your_project
npm link evaengine

Global Environment Variables

  • NODE_ENV
  • PORT
  • LOG_LEVEL
  • CLI_NAME
  • MAX_REQUEST_DEBUG_BODY
  • SEQUELIZE_REPLICATION_CONFIG_KEY : change sequelize replication config key

Generate Entities

./node_modules/.bin/engine make:entity
./node_modules/.bin/engine make:dbview

Import eslint with airbnb code standard for Webstorm

WebStorm > Preferences > Editor > Code Style > JavaScript > Scheme > Import Scheme > Choose airbnb_code_style.xml under this project