rares

Modern backend framework, inspired by Ruby on Rails

Usage no npm install needed!

<script type="module">
  import rares from 'https://cdn.skypack.dev/rares';
</script>

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

License

The project is licensed under the ISC license.