NodeFlare
A framework built on Express with built in JWT authentication, Dependency Injection, and Eventing.
Getting Started
There are only a few steps to getting NodeFlare up and running.
Install
npm install --save nodeflare sequelize sqlite3
Run It!
; let config = hostname: 'http://localhost' port: 61370 tokenkey: '12345';let app = configstart; ;
Features
By default, NodeFlare starts up as an empty application listening on the port you configured. You can enable additional features prior to calling .start() on the NodeFlare object.
Auth Services
To enable the authentication services you can call .withAuthServices()
let app = config start;
App Settings
You can configure application settings with .appSet(setting, value). You can set existing Express Settings
let app = config start;
Middleware
You can pass an optional path and function to .appUse(path, function) to add middleware to your application. You can pass in a Router as a function. This will allow you to more easily encapsulate Routers into their own classes.
; let router = ;router; let app = config start;
This will create path /api/fun and will execute the router function.
If you turn on the Authentication Services, by default all new services you create are protected and you must preset a valid auth token. If you wish to allow (whitelist) certain services, you can call .whitelist(string|array).
let app = config start;
Dependency Injection
When you call start on a NodeFlare object, this creates the Application Context. This is available as global.ctx. You can register your own classes prior to calling start().
let app = config start;
let app = config start;
let app = config start;
Onces you have started your application, you can call ctx.get('Name') to get the instance of the class you registered.
Event Hub
You can get a reference to the EventHub from the application context
let eventHub = ctx;
Subscriptions
You can subscribe to events with the key and channel and provide an event handler. Currently only unsubscribing from a key is supported.
let eventHub = ctx; eventHub; eventHub;
Publish
You can publish events to any channel.
let eventHub = ctx; eventHub; // Channel & Payload. Payload is optional
Configuration
Below is the configuration that is available. The following properties are required, everything else is optional depending on your environment.
- hostname
- port
- tokenkey
Database
NodeFlare uses Sqlite by default to store users. Through configuration you can specify PostgreSQL or MySQL which are both supported.
Built in User & Authentication Services
Authentication Service
/auth/login -> Method: Post
Request Object
Json Response
/auth/passwordreset -> Method: Post
Request Object
Json Response
The My Service
/my/user -> Method: Get
Json Response
In addition to the above properties, all the properties you specify in the details of the create will be included.
/my/user/create -> Method: Post
Request Object
Json Response
/my/user/edit -> Method: Post
Request Object
Json Response
Who do I talk to?
Contact chrisjasp@gmail.com