Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    James Pickard
    @euoia
    you can set arbitrary values on the request object which are then accessible to later routes and middleware
    A pattern I sometimes use is to attach a log object with info, debug, etc functions to the request object, that logs whatever you give it prefixed with a request ID
    Jim H
    @luckyl2000:matrix.org
    [m]
    don't have any experience in any sort of online/web development. I came up with an idea that I personally think is great in regard to the target audience it serves. I don't know if I should vividly share it on here but I would like to discuss the possibility of this online tool or service. I am looking to discuss this with someone familiar with the pharmaceutical world.
    can someone help or point me in the correct direction?
    James Pickard
    @euoia
    @luckyl2000:matrix.org it's always a tricky one when you have a good idea, of course you're not sure how much to share. Are you looking to discuss the technical feasibility of it with someone? I could possibly help you with that if you like
    efhan-the-unorthodox
    @efhan-the-unorthodox

    Hi I am working on an Express App with TypeScript
    I am trying to configure CSRF Tokens with the CSURF Library. I followed the documentation accordingly and I when I ran my app, there was no problem. However, upon trying to make a POST request, I get a 403 error saying ForbiddenError : invalid csrf token

    The following is the code in my main express app called app.ts

    import express, { request, Request, Response } from 'express'
    import 'dotenv/config'
    import passport from 'passport';
    import session from 'express-session';
    import clientController from './client/client';
    import cors from 'cors';
    import csurf from 'csurf';
    import cookieParser from 'cookie-parser';
    import bodyParser from 'body-parser';
    
    const app = express();
    app.use(cookieParser())
    app.use(bodyParser.urlencoded({ extended: true }))
    app.use(express.json())
    app.use(cors({
        credentials: true,
        origin: ['http://localhost:3000']
    }));
    
    const csrfMiddleware = csurf({ cookie: true })
    
    const port = process.env.PORT
    const sessionSecret = process.env.SESSION_SECRET
    
    app.use(session({
        secret: sessionSecret!.toString(),
        resave: true,
        saveUninitialized: false,
        cookie: {
            httpOnly: true
        }
    }))
    app.use(csrfMiddleware)
    
    app.use(passport.initialize());
    app.use(passport.session());
    
    passport.serializeUser((user: Object, done) => {
        console.log(user)
        done(null, user)
    })
    
    passport.deserializeUser((user: Object, done) => {
        done(null, user);
    })
    
    //Authentication route
    const authRoute = authController
    app.use('/auth', authRoute);

    I hope someone can assist me with this because I've spent a day or so trying to troubleshoot as to why I can't get csrf working

    Justice Lu
    @codingjlu
    The problem originated from the client side... how are you sending a request? You need to send the CSRF token with the request, probably including it with SSR (ejs or such).
    2 replies
    vincenzoml
    @vincenzoml
    Hello, question 0 for me about express.js: is there a simple way to map all the methods and fields of an objects to a route, with parameters where appropriate?
    1 reply
    I am thinking of writing something myself
    James Pickard
    @euoia
    @vincenzoml sure it's possible
    James Pickard
    @euoia
    @StephenLynx I can't speak for the Express team or on the matter you're discussing, but I can tell you that there's only a very small number of people working on Express at the moment, and most likely the website simply hasn't been updated for a long time
    Momoh Tyler
    @tylerjusfly
    is Express Open source?
    James Pickard
    @euoia
    Yep
    Momoh Tyler
    @tylerjusfly
    ok, thank you.
    Ali Ahsan
    @ALIAHSANRST
    hello everyone , i am using oauth2.0 in my app and i want to allow only people with university account (want to allow only specific domain) to visit my app. Anyone knows how to do it ?
    Ronique Ricketts
    @RoniqueRicketts
    You may have to create a list of domains then use cors to whitelist those domains
    Dina Berry
    @diberry
    Naming conventions question: if I have an Express.js app using views and I want to separate out View routes from Apis routes, what is the naming convention for these two routes? I'm used to Apis having /api/ in the route, but is there a corresponding route for views?
    James Pickard
    @euoia
    @dougwilson announced Express 5.0 beta.1 yesterday! 6 years in the making...
    Vineet Dixit
    @vineetdigit
    I'm wondering why does Express call router.param after router.use here?
    outer.param("logNumber", (req, res, next, value) => {
      console.log("1 Called at", Date.now());
      next();
    });
    
    router.use((req, res, next) => {
      console.log("2 Called at", Date.now());
      next();
    });
    Console output
    2 Called at 1645747636698
    1 Called at 1645747636707
    dan-cotruta
    @dan-cotruta
    hi all
    dan-cotruta
    @dan-cotruta
    i'm having trouble working out how to access query parameters in a POST endpoint
    no matter what I try, it yields an empty object
    James Pickard
    @euoia
    @dan-cotruta did you figure it out? What are you trying?
    Matthieu Napoli
    @mnapoli

    Hey @euoia & @dougwilson, I see that activity is picking up again on GitHub 🎉
    I'm a maintainer of Serverless Framework (https://github.com/serverless/serverless). We have more than 8,000 users/month deploying Express to AWS.
    We want to build first-class integration between Express and AWS, and make it extremely easy for Express users.

    We have some ideas we want to share with you, would you be interested to discuss it? Should we contact anyone else?

    Kal Sze
    @ksze
    I'm confused. Is the error handling middleware supposed to go before my routes or after my routes? The documentation isn't clear about this: https://expressjs.com/en/guide/error-handling.html
    Matt Voboril
    @TobiTenno
    @ksze for errors thrown in code, the handler should be before routes. for a catch-all route to give a generic error, you'd want that after all the other routes.
    1 reply
    Douglas Wilson
    @dougwilson
    Hi @mnapoli yes, I would be certainly interested! You're welcome to share where ever you like, the issue tracker, here, or DM me directly if you want. Happy to hear the ideas around that and what changes could be made.
    1 reply
    Shreyash Pingle
    @shrey802
    Hey I just joined this. This is for express framework right
    MattChale123
    @MattChale123
    Hi all! I'm having some difficulty with default engine not being specified. I'm using React, so I'm using sendFile to send to a static bin file (some middleware). Do I still need to specify a default engine in my app.js file?
    Biswajit Sharma
    @biswajitatgithub
    Hi guys, I am stuck in a place where I am performing http GET request when a button is clicked, as a response I am getting a html page as a response. I am not able to redirect to that html page. For example I am in home page i.e localhost:4000 and performed a GET request localhost:4000/login, here i am getting the login html page from the server but not able to redirect it.
    sqllyw
    @sqllyw
    hi, app.set('etag', false) will set all the response status to 200, how to limit this to only a particular router, say routes/users.js
    Eltik
    @Eltik
    How do I convert a torrent into a readable stream? I'm using NodeJS, Express (for a web server), and Browserify (for WebTorrent), but since WebTorrent only works for WebRTC I can't use WebTorrent.
    Seif Eddine Slimene
    @SeifESlimene
    @Eltik You can use Browserify
    Md. Touhidur Rahman
    @touhidurrr
    This message was deleted
    This message was deleted
    Hi
    I have a problem!!!
    Why this custom Payload too Large limitter not working?
    Can anybody say?
    // Limit, 3 MegaBytes
    // 1 << 10 = 1024 << 10 = 1024 * 1024
    const limit = 3 << 20;
    
    // Text Body Parser
    server.use(function (req, res, next) {
      let ln = req.get('content-length');
      if (ln && ln > limit) {
        res.sendStatus(413);
        return;
      }
      req.body = '';
      let overLimit = false;
      req.on('data', chunk => {
        if (overLimit) return;
        req.body += chunk;
        if (req.body.length > limit) {
          overLimit = true;
          res.sendStatus(413);
          return;
        }
      });
      req.on('end', () => {
        if (!overLimit) next();
      });
    });
    Even if payload exceeds the limit, the request is still processed.
    darkkilltec
    @darkkilltec
    Hello everyone, what db would you use if you had entries that you wanna lookup via location, like when you give your location info to the server and get back the locations sorted by closest to you, and does it make sense to keep the entries in express memory then to retrieve it with every call. because the entries will not change often?
    1 reply
    Robyn Drake
    @robindrake
    I try and start the express server side of this basic web application and I get this error: TypeError: Router.use() requires a middleware function but got a string codes is at https://github.com/robindrake/starter-express-api the answers I'm finding, I've already done what was said.
    The "/" route works just fine
    I need to leave to wait for transport to dialysis in 15 minutes.
    Robyn Drake
    @robindrake
    Oh well.
    Robyn Drake
    @robindrake
    joy.
    Lucas Marra
    @lucaspmarra
    Hello hello... anyone here using 'mongoose-unique-validator' uniqueValidator?
    Need help with error message...
    7 replies