Giter VIP home page Giter VIP logo

lumie's People

Contributors

alex-levacher avatar bernardjeremy avatar lukeschlangen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lumie's Issues

How to integrerat permissions with express-jwt?

First, I just wanna say, I love Lumie, really great work.

I m a bit confused with the permissions. I want member to go through my JWT express middleware. Could you add an example of how to do this?

I don't want to add middleware on each route, I just want set level to member and it should be handled by itself. Is this possible?

Passport Parameters

How should I use passport authenticate function with lumie?

This is my original route:

router.get(
  "/discord/callback",
  passport.authenticate("discord"),
  (req, res) => res.redirect("/")
);

The converted function that doesn't work:

const callback = (req, res) => {
  passport.authenticate("discord");
  res.redirect("/");
};

module.exports = {
  "/discord/callback": {
    get: {
      action: callback,
      level: "public"
    }
  }
};

How can I promote Lumie?

Hi everyone,
I'm looking for new ideas to promote Lumie. If you have some, don't hesitate to list them below.
I'll share with you the results of the different suggested actions by updating this post with the statistics.
Thanks ✌🏼

  • Post on Indie Hacker ( link ) 11 votes / 88 visits
  • Post on EchoJS ( link ) 6 votes / 117 visits

Root dynamic routes

I could not find anything about this in the documentation so I'm guessing this is not thought of yet.

So I have my /api/path which is the "root", and then I wanted to listen to a parameter right after like this: /api/:project. To create this you could prefix the filename with an underscore.
The naming structure would be _project-get.js
Which would generate:

public      get      /api/:project

Could this be something to implement, or is this already possible?

EDIT**
I noticed that you could name it project.routing.js and it would give you the result I wanted. But I think it creates confusion of where the action is placed since its in a routing named file. Best way to solve this solution?

Can't use express-validator as middlewares

Express validator doesn't work as intended.

routing.js:

const post = require("./post.action")

module.exports = {
    '/': {
        post: {
            action: post.createUser,
            middlewares: post.middlewares,
            level: 'public'
        }
    }
}

action.js:

const { body } = require('express-validator/check');

/**
 * Middlewares
 */
module.exports.middlewares = [
    body('email', 'Invalid email').isEmail(),
    body('password', 'username invalid').exists()
]

module.exports.createUser = (req, res) => {
    // Get triggered even if 'email' and 'password' body's fields are empty/not valid
    res.status(201).send("test")
}

But, if I do this:

module.exports.middlewares = [
   (req, res, next) => {
       console.log("Middleware is working!")
       next()
   }
]

The middleware get triggered as expected

Can't pass error to middleware handler when using async functions in controller

A controller with an async function that throws an error, that error doesn't reach the error handler middleware.

cars-get.action.js

module.exports.getAll = async (req, res) => {
  throw new Error('async error');
};

express.js

const express = require('express');
const Lumie = require('lumie');
const app = express();

Lumie.load(app, {
  verbose: process.env.NODE_ENV !== 'test',
  preURL: 'api',
  ignore: ['*.spec', '*.action'],
  controllers_path: path.join(__dirname, '../api/controllers')
});

//error handler middleware
app.use((err, req, res, next) => {
  return res.status(500).json({ message: 'error' });
});

module.exports = app;
(node:3690) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3690) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Sugestion

Use a function to wrap the controller action that resolve the promise, in case of error, catch that and pass it to next middleware

https://stackoverflow.com/questions/51391080/handling-errors-in-express-async-middleware

Question about level access

I saw level access triggers before middlewares.

How i can attach current user on api call, an then call the permission middleware using the level?

Ability to get JSON of route definitions

It would be interesting being able to programmatically access the detected routes, e.g the data used to generate this:

> node index.js

======== ROUTES ========

[Battery]
	public	get	[/api/battery/]

[Consumption]
	public	get	[/api/consumption/]

[Production]
	public	get	[/api/production/]
	public	get	[/api/production/solar]
	public	get	[/api/production/wind]

========================
Example app listening at http://127.0.0.1:3000

It would allow automatic API discovery and -why not- the creation of a client SDK

Controller for root path?

Every controller defines his own route over own name, for example:

controllers/project.js

[Project]
        public  get     [/project/]
        member  get     [/project/number/:value]

project-ctrl.js

module.exports = {
    '/': {
        get: {
            action: index,
            level: 'public'
        }
    },

...

This creates a path for listen over project/. If do i want to listen over root path?

For example:

  • My preURL is /.
  • I want to listen a request over / without another parameter, specific controllers over this clean path. Is It neccesary do it outside Lumie config?

How to configure Lumie to work with Webpack/babel builds?

So I inherited a project that is using lumie but the webpack/babel production builds do not work. Ended up tracing down the error to a path resolution issue with Lumie when it tries to load the controller paths but I'm not sure how to handle this (part of the problem is definitely my very limited knowledge of webpack/bable configs).

Has anybody successfully configured webpack builds for a lumie/express app? Any examples or just general idea on how to configure this properly would be greatly appreciated (sorry I know this is pretty vague, really just looking for where to get started and I can do my own research from there).

Thanks for any help!

Express dependency

Hi, I think you can remove express js as dependency or declared as peer dependency. Don't you think ?

preUrl option on lumie load

Don't know if it's a bug or not.

If you use single quotes on preUrl lumie don't recognize the option only with double quotes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.