Giter Site home page Giter Site logo

express-routescan's People

Contributors

anotheri 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

Watchers

 avatar  avatar  avatar  avatar

express-routescan's Issues

Enhancement Request: Route function

Right now single route ("/api/abc") with more than one method ( GET, POST) can point to single function.

E. g.

module.exports = {
   '/api/abc' : {
        method: ['get','post'],
        fn: functionForBothGetAndPost
   }
}

It would be helpful if library provides a way to point to different function for different method.

E.g. Something like this:

module.exports = {
   '/api/abc' : {
        method: ['get','post'],
        fn: [functionForGet, functionForPost]
   }
}

Access Express App from within Route

Do you have any recommended ways to pass in parameters to the routes from the main express application. For example, if my route files need access to the http server object is there a good way to give the route files themselves access to that? Thanks!

Enhancement Request: Route prefix

Right now, the routes defined always start from the root. Would it be possible to add an option/parameter to set a custom prefix, which is then prefixed to every route (or every route in a specific routes directory)? (For example: /api)

Catching 404s and the like

Hi,

I've just started playing with this module, but I've been unable to recreate my previous fall-through route, where I would define app.use() with no route parameter and catch all invalid routes.

I can't seem to find a way of doing this using express-routescan, as if I use a blank route param it throws up an error.

Any ideas? Or am I missing something!

Many thanks
Matt

Ps, at the moment my only option is to define a /404 route using routescan, and then at the end of my app.js file, putting a redirect, but I want to keep the broken path rather than redirecting:

app.use(function (req, res) {
  res.redirect('/404');
});

fn should be optional

Maybe "fn" in the route hashtable should be optional. It is valid just to define a middleware.

My use case is to register passport.js routes:

module.exports = {
'/auth/twitter': {
method: 'GET',
middleware: [passport.authenticate('twitter')]
},
'/auth/twitter/callback': {
method: 'GET',
middleware: [passport.authenticate('twitter', {
successRedirect: '/',
failureRedirect: '/login'
})]
}
};

Problems with basic express app routing

This works... just needed a full setup example :)

Initialized routes:
 # GET /
 # POST /word2html

Statistic info:
[routed]:
1. C:\dev-projects\node-projects\word2html\routes\index.js       GET     /
Done.
Listening on port: 8080
App started

Simple setup:

http      = require 'http'
express   = require 'express'
routescan = require 'express-routescan'

app = express!
port = 8080
app.set 'port', port

# start express-routescan. 
routescan app, verbose: true

http.create-server(app).listen port, ->
  console.log 'App started'

console.log "Listening on port: #{port}" 
# routes/index.ls
'use strict'

module.exports =
  '/': (req, res) ->
    res.send "Hello World"

Add folder name to route

I realize theres been no code committed into this repo in the last couple of years. I really loved the way routescan handles the routes. I am just curios, if the routescan automatically picks up the folder name and adds it as a context to the routes defined in it? For example?

If the routes in routes/user.js are defined as '/signup' and '/signin'.... this will be treated as http://server/signup and http://server/signin ....... if the file user.js is put inside the folder security.... i.e. routes/security/user.js .... the new routes should automatically be http://server/security/signup and http://server/security/signin. The folder in which the route is defined gets treated as part of the route and sets the context to the routes.

For example: https://github.com/stonecircle/express-autoroute does this part of it... I just like routescan in terms of everything else... :)

No next parameter found

I haven't reviewed all of your code, can you please tell me if pass the next parameter to all routes. I need it for handling errors.

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.