Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8106073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:20:56+00:00 2026-06-06T00:20:56+00:00

In express, I have defined some routes app.post(/api/v1/client, Client.create); app.get(/api/v1/client, Client.get); … I have

  • 0

In express, I have defined some routes

app.post("/api/v1/client", Client.create);
app.get("/api/v1/client", Client.get);
...

I have defined how to handle requests inside a Client controller. Is there a way that I can do some pre-processing to the requests, before handling them in my controller? I specifically want to check if the API caller is authorized to access the route, using the notion of access levels. Any advice would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:20:59+00:00Added an answer on June 6, 2026 at 12:20 am

    You can do what you need in a couple of ways.

    This will place a middleware that will be used before hitting the router. Make sure the router is added with app.use() after. Middleware order is important.

    app.use(function(req, res, next) {
      // Put some preprocessing here.
      next();
    });
    app.use(app.router);
    

    You can also use a route middleware.

    var someFunction = function(req, res, next) {
      // Put the preprocessing here.
      next();
    };
    app.post("/api/v1/client", someFunction, Client.create);
    

    This will do a preprocessing step for that route.

    Note: Make sure your app.use() invokes are before your route definitions. Defining a route automatically adds app.router to the middleware chain, which may put it ahead of the user defined middleware.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following express node.js app. It's using the 'redis' npm package. app.get(/test,function(req,res){
In my NodeJS express application I have app.js that has a few common routes.
I have a route on my Express app that looks like this: app.get('/:id', function
I have a SQL2005 Express database that I would like to create a copy
Let's say I have the following app.js (obviously very simplified): var express = require('express'),
I have a navigation menu defined in visual web developer 2010 express using a
I have a web app where the client side stuff is written with coffeescript
I have an express server that has a button that issues a POST which
It is possible in SQL Server Express have a log of all operations SELECT
I'm using SQL Server 2005 express I have a datetime field in a table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.