All Projects → Alex-Levacher → Lumie

Alex-Levacher / Lumie

Licence: mit
✨ An opinionated way to keep your express API organized

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Lumie

Pure Http
✨ The simple web framework for Node.js with zero dependencies.
Stars: ✭ 139 (-49.82%)
Mutual labels:  api, framework, expressjs
Actionhero
Actionhero is a realtime multi-transport nodejs API Server with integrated cluster capabilities and delayed tasks
Stars: ✭ 2,280 (+723.1%)
Mutual labels:  api, framework
Autoserver
Create a full-featured REST/GraphQL API from a configuration file
Stars: ✭ 188 (-32.13%)
Mutual labels:  api, framework
Express Api Es6 Starter
Build APIs with Express.js in no time using ES6/ES7/ESNext goodness.
Stars: ✭ 212 (-23.47%)
Mutual labels:  api, expressjs
The Rest Architectural Style
An article on the REST architecture style.
Stars: ✭ 168 (-39.35%)
Mutual labels:  api, architecture
Lad
👦 Lad is the best Node.js framework. Made by a former Express TC and Koa team member.
Stars: ✭ 2,112 (+662.45%)
Mutual labels:  api, framework
Messenger4j
A Java library for building Chatbots on the Facebook Messenger Platform - easy and fast.
Stars: ✭ 199 (-28.16%)
Mutual labels:  api, framework
Vendure
A headless GraphQL ecommerce framework for the modern web
Stars: ✭ 2,961 (+968.95%)
Mutual labels:  api, framework
Ray
a framework that helps you to deliver well-designed python APIs
Stars: ✭ 215 (-22.38%)
Mutual labels:  api, framework
Bookmarks.dev
Bookmarks and Code Snippets Manager for Developers & Co
Stars: ✭ 218 (-21.3%)
Mutual labels:  api, expressjs
Opentest
Open source test automation tool for web applications, mobile apps and APIs
Stars: ✭ 246 (-11.19%)
Mutual labels:  api, framework
Express Graphql Typescript Boilerplate
A starter kit for building amazing GraphQL API's with TypeScript and express by @w3tecch
Stars: ✭ 163 (-41.16%)
Mutual labels:  api, expressjs
Mono
Minimalist Framework on top of Express.js
Stars: ✭ 163 (-41.16%)
Mutual labels:  api, framework
Supra Api Nodejs
❤️ Node.js REST API boilerplate
Stars: ✭ 182 (-34.3%)
Mutual labels:  api, architecture
Fastapi Crudrouter
A dynamic FastAPI router that automatically creates CRUD routes for your models
Stars: ✭ 159 (-42.6%)
Mutual labels:  api, framework
Component
🔥🔥🔥A powerful componentized framework.一个强大、100% 兼容、支持 AndroidX、支持 Kotlin并且灵活的组件化框架
Stars: ✭ 2,434 (+778.7%)
Mutual labels:  api, framework
Leaf
🍁 The easiest way to create clean, simple but powerful web apps and APIs quickly
Stars: ✭ 248 (-10.47%)
Mutual labels:  api, framework
Customstage
A JavaFX UI framework to create fully customized undecorated windows
Stars: ✭ 148 (-46.57%)
Mutual labels:  api, framework
Corporate Bs Generator Api
Corporate Bullshit(BuzzWord) Generator API
Stars: ✭ 155 (-44.04%)
Mutual labels:  api, expressjs
Magic
Create your .Net Core/Angular/Database CRUD Web apps by simply clicking a button
Stars: ✭ 214 (-22.74%)
Mutual labels:  api, framework

Twitter URL

Lumie Logo

🤔 DESCRIPTION

Lumie is a lightweight module that allows you to set up a scalable controllers architecture for your nodejs project.

✅ Maintainable
✅ Scalable
✅ Quick setup
✅ Easily testable

💾 INSTALLATION

npm install lumie

🔩 HOW IT WORKS

Lumie goes through the files and folders inside your controllers directory to find what we call "routing definitions".
Each controllers are defined in files, which export their routing definitions ( example )

By default, we use the name of the file that exports the routing definition to name the route

/ > controllers > cars.js will create the endpoints /cars/*
/ > controllers > admin > rules.js will create the endpoints /admin/rules/*
/ > controllers > users > users.routing.js will create the endpoints /users/*

⚙️ CONFIGURATION

const express = require("express");
const path = require("path");
const lumie = require("lumie");

const app = express();

lumie.load(app, {
  preURL: "api",
  verbose: true,
  ignore: ["*.spec", "*.action"],
  controllers_path: path.join(__dirname, "controllers")
});

const server = app.listen(3000, "127.0.0.1", () => {
  const { address, port } = server.address();
  console.log("Example app listening at http://%s:%s", address, port);
});

Options

Name type default value Description
verbose boolean false Will print or not the routes name in the console
preURL string / Prefix your route URLs
ignore string[] null Lumie will not try to find a routing definition in those files.
controllers_path string none, this option is required The path of your controllers folder.
routing_files string *.routing How you want to name routing files.
permissions function null A function that takes in parameter a level access and returns an express middleware. This is useful if you want to restrict access for some URLs. With this option enabled, you will be able to set in each route configuration an option level that will be passed to your permission function ( example )

🌲FILE STRUCTURE

project/
├── controllers/
│   ├── users/
│   │   ├── users.routing.js
│   │   ├── users.action.js
│   │   └── users.spec.js
│   ├── cars/
│   │   ├── cars.routing.js
│   │   ├── cars.spec.js
|   |   ├── cars-get.action.js
│   │   └── cars-post.action.js
│   └── simple-ctrl.js
├── core/
│   └── permissions.js
├── app.js
└── package.json

alt text

🎮 USAGE

Example: project/controllers/cars.js

const postCars = require("./cars-post.action");
const getCars = require("./cars-get.action");

module.exports = {
  path: "awesome-cars", // rename the path of the route (optional)
  '/': {
    post: {
      middlewares: postCars.middlewares,
      action: postCars.action,
      level: 'public'
    },
    get: {
      action: getCars.getAll,
      level: 'public'
    }
  },
  '/:id': {
    get: {
      action: getCars.getOne,
      level: 'public'
    }
  }
};
'/<name of your route>': {
        < get | put | delete | post >: {
            action: < function(req, res) >,
            level: < parameters of you permission function >, // Optional
            middlewares: < Array(function(req, res, next)) >// Optional
        }
    }

🌠 BEST PRACTICES

There is 2 common way to create a controller with Lumie, you can take a look here to learn how to implement them.

  • Minimal (sample): You only create one file which takes as name, the name of the controller you want to create. Then you define the routing definition and the functions. This method is recommended if you plan to have a small controller with few actions.
  • Structured (sample): You create a new directory with the name of the controller. Inside, you create:
    • [your-controller-name].routing.js which contains the routing definition
    • [your-controller-name].actions.js which contains the action functions of the controller.
    • [your-controller-name].spec.js This one is optional

If your controller is pretty heavy, with a lot of functions, we recommend to create one file per action (create-user.action.js, get-user.action.js, etc… ) (sample)

🤙 EXAMPLES

🚀 ROADMAP

Here are the next features planned, let me know if you have some ideas

  • Create a CLI to generate new controllers / projects

☕️ SUPPORT

You can support the project by

  • Star our GitHub repo ⭐️
  • Suggest ideas to help me promote Lumie 🌎

If you are struggling to setup Lumie, you found a bug or if you have some improvement ideas, feel free to create an issue

⚖️ LICENSE

This software is licensed under the MIT © Alex Levacher

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].