An organic web framework for organized web servers.
Organiser is a web framework focused on provinding the best developing and maintenance experience, benefiting from Ecmascript's new definitions, with support from Babel.
Our goal is having an organized and organic server. But what does that mean?
It means that you can bring complex highly scalable systems to life, with easy maintaining, without having to learn hard syntaxes. It is organized because of its well-known syntax, used in Spring Boot, for example, and it is organic because Organise makes sense: it is just like telling the server what it should do, in almost natural-like language.
Organiser works with inversion of control principles, creating one of the most powerful environments for MVC development in Node.js, for example. Just tell what you want through its decorators and let the magic happen.
⚠️
Organiser is in beta stage. It's not recommended for production usage yet.
Install
This is a Node.js module. Therefore, beforehand, you need to download and install Node.js. Node.js 6.0.0 or higher is required.
Assuming that you have already used the npm init
command, run:
$ npm install organiser --save
Examples
A server with only a GET endpoint at localhost:3000
(default) that shows Hello, world!
as plain text.
@GET async { return Response } const server = // creates a new instance of Organiseserver // register controllers, passing their classes by referenceserver // start server
Virtual personal agenda, with notes and contacts, using NeDB.
const server = name: 'Agenda' internal: debug: true serverserverserver
Events
Work in progress...
Modules
You can use how many modules, before and/or after a request, as you wish. We support context
and connect
middlewares/modules styles.
Modules defined in server.modules(module1, module2, module3, ...)
will be executed before every controller, in a sequence order (module1 → module2 → module3 → ... → controller). When calling server.modules()
with parameters, it returns an object containing a function called after(...)
, that lets you register modules the same way, but they will run after every controler. Calling it without parameters will return an object with before(...)
and after(...)
.
When you register routes through server.routes(ControllerClass1, ControllerClass2, ControllerClass3, ...)
, it also returns an object with before(...)
and after
, letting you register modules only for the routes passed as parameters.
Using @ModuleBefore(module1, module2, module3, ...)
and @ModuleAfter(module4, module5, module6, ...)
above a class or function reproduces the same behavior.
Built-in modules
- ✔️ Body Parser
Modules.bodyParser(options)
- ✔️ Raw Body Parser
Modules.rawBodyParser(options)
Example
{ return { console console contextbye = 'See you!' contextluckNumber = Math + 1 }} { return { console contextexpectedResponse = Response }} @ @GET @ async { return Response } const server = serverserverserver
Work in progress...
@Arguments - Inversion of Control
Through the Arguments decorator, you can inject dependencies anywhere, anytime. Just use the class of the desired instance and Organised will take care of the rest.
When used above classes, the respective class' constructor will be called with the parameters passed through the Arguments decorator.
When used above functions, it only supports one parameters: the data model (object containing properties that Organiser should retrieve). The data model supports inner models (functions returning objects).
Example
|
|
- Contact is a function that returns an object. This is how you define a model in Organise.
- ContactsService is just a regular class, used as a service. You can also use Arguments to inject parameters in its constructor (calling other services instances, for example).
Read more about how the Arguments decorator works with functions here.
Documentation
Available decorators
- ✔️
Arguments
(accept parameters) - ✔️
Path
(accept parameters) - ✔️
ModulesAfter
(accept parameters) - ✔️
ModulesBefore
(accept parameters) - ✔️
GET
(functions only) - ✔️
HEAD
(functions only) - ✔️
POST
(functions only) - ✔️
PUT
(functions only) - ✔️
DELETE
(functions only) - ✔️
OPTIONS
(functions only) - ✔️
TRACE
(functions only) - ✔️
PATCH
(functions only)
Model property types
- ️️✔️
Types.UUID
:'uuid'
- ✔️
Types.STRING
:'string'
- ✔️
Types.BOOLEAN
:'boolean'
- ✔️
Types.INTEGER
:'integer'
- 🚧
Types.DOUBLE
:'double'
- 🚧
Types.FLOAT
:'float'
- 🚧
Types.DATE
:'date'
- 🚧
Types.FILE
:'file'
- ✔️
Types.CLIENT_REQUEST
:'clientRequest'
- ✔️
Types.SERVER_RESPONSE
:'serverResponse'
It is encouraged the usage of Types.*
instead of their respective string version, for versioning purposes.
Data models
Work in progress...
Team
Created and developed by Arthur Arioli Bergamaschi, supervised by the JavaScript Advanced Core (NAJaS - Núcleo Avançado de JavaScript) at Fatec Taquaritinga.
License
Licensed under MIT.
Disclaimer: Organiser is still a work in progress. Methods and behavior can change along the way.