rares
v0.2.0-alpha.7
Published
Modern backend framework, inspired by Ruby on Rails
Downloads
12
Maintainers
Readme
Rares
Rares helps you build API backend faster.
Why yet another framework?
TL;DR: because convention is better than bikeshedding.
Despite their claims, express and hapi are not application frameworks, but rather http frameworks. They liberally avoid you application code, providing you with flexibility, but wasting human resources on hidden costs.
Rares is a proper application framework. It gives your application code the foundation and structure, leaving less room for opinion.
Getting started
Install:
npm install rares
Simple app:
// config/routes.js
module.exports = App => {
const { resource } = App.Router;
return [
resource('memory', { only: ['show', 'update'] }),
];
};
// controllers/memory.js
module.exports = App => {
let value = null; // @NOTE: in the real world you would have a data store
return class MemoryController extends App.Controller {
async show() {
return { value };
}
async update() {
value = this.$params.value;
return { value };
}
};
};
Run the app in development mode:
npx rares dev
> Server running at: http://localhost:3000
Use the app:
curl http://localhost:3000/memory
> { "value": null }
curl -X PUT http://localhost:3000/memory?value=hello
> { "value": "hello" }
curl http://localhost:3000/memory
> { "value": "hello" }
Contribute
- Issue Tracker: GitHub Issues
- Source Code:
- Core: rares
- Bindings for Hapi: hapi-rares
- Bindings for Express: express-rares
License
The project is licensed under the ISC license.