Skip to content

Repository files navigation

EvaEngine for Node.js

NPM version CI codecov npm License

EvaEngine is a lightweight Node.js microservice development engine. It gives you dependency injection, middleware, CLI commands, scheduled jobs, session and auth helpers, cache support, Swagger generation, and a simple way to structure services.

Requirements

  • Node.js 24 or newer
  • npm

Install

For a new project:

npm install evaengine

For local development of this repository:

git clone https://github.com/EvaEngine/EvaEngine.js.git
cd EvaEngine.js
npm install

Quick Start

Run as a web server

import { EvaEngine } from 'evaengine';

const engine = new EvaEngine({
  projectRoot: process.cwd(),
  port: 3000
});

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

Then open http://localhost:3000.

Run as a CLI app

import { EvaEngine } from 'evaengine';
import * as UserCommands from './commands/user.js';

const engine = new EvaEngine({
  projectRoot: process.cwd()
}, 'cli');

engine.registerCommands(UserCommands);

await engine.runCLI();

Run as a cron job

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

const engine = new EvaEngine({
  projectRoot: process.cwd()
}, 'cli');

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

Common Commands

npm run lint
npm run build
npm test

Environment Variables

Common variables include:

  • NODE_ENV
  • PORT
  • LOG_LEVEL
  • CLI_NAME
  • MAX_REQUEST_DEBUG_BODY
  • SEQUELIZE_REPLICATION_CONFIG_KEY

Generate entities

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

Start from a skeleton project

If you want a ready-made starting point, use the skeleton repository:

For project conventions and setup guidance, see docs/new_project_guide.md.

Releases

Packages

Used by

Contributors

Languages