Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    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
    Kyle Anthony Williams
    @SuperSonicHub1
    I have a very silly question. Is it possible to embed a Node HTTP server within an Express app? :)
    darkkilltec
    @darkkilltec
    you can tell express to use a static website with index.html or javascript, for example you could host an angular app within, i did not try it but why shouldn´t a node http server not work when set as static site
    Hagen DeRouen
    @hagenderouen
    How do I service static files in my public directory that's not at the root. My directory is structured as follows:
    -src
    --public
    ---images
    ---scripts
    ---views
    -app.js
    Vaibhav Arora
    @VaibhavArora19
    app.use(express.static(path.join(__dirname, 'src', 'public'))); might work
    simsalabim
    @simsalabimabri_twitter
    Hi, I'm new to ExpressJS and self-taught developer. I'm trying to browse about the difference between session https://www.npmjs.com/package/express-session vs session storage, but I don't find it yet. Anyone here wants to give me a bit about keywords or blog posts regarding that? Thank you! :)
    wingedrhino
    @wingedrhino:matrix.org
    [m]
    Ahoy! How usable is the 5.0 beta for a production app?
    wingedrhino
    @wingedrhino:matrix.org
    [m]
    I guess I can answer my own question: "it depends". I use TypeScript, and since Express doesn't maintain its own type definitions, the answer is "presently unusable". Since Express is written with JSDoc support, would the community consider auto-generating types from them? https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html
    jingmalan
    @jingmalan
    @simsalabimabri_twitter maybe you can find useful info on MDN?
    Csaba Horváth
    @HorCsa
    I am developing a nodejs express project and earlier when I was developing on Mac and Windows this worked for serving js files from public/js folder: app.use(express.static(__dirname + '/public')); Now I stardted to develop on Ubuntu and only public/js folder not served by the server. Other folders is ok for example images, css etc... What can be the proble and why is it works on other systems? I am developing and debugging the project using VS Code.
    Ryan Truran
    @RyanTruran
    What is the error message
    Ryan Truran
    @RyanTruran
    Also, You should be using path.join instead of string concatenation for paths.
    Csaba Horváth
    @HorCsa
    I tried that, but not works and I think not the js folder is problematic. I tried to rename files and resave files and some of them is ok now, but for example an external jquery.form.min.js.map file not getting ok. Maybe some file system problem is in the backgroud???
    Csaba Horváth
    @HorCsa
    I think the problem is that in the scripts src property url folder name is not starting with capital letter but the folder nam is capitalized. So the folder is 'Work' and the src is '/js/work/work.js'. If I change '/js/Work/work.js' it resolves that. Is this caused by different operating systems?
    Ryan Truran
    @RyanTruran
    Yes some systems have a case sensitive file system.
    Omar Dulaimi
    @omar-dulaimi

    Hey everyone,
    I would like to access the req route path(the regex) inside a middleware handler

    app.use((req, res, next) => { 
       console.log(req.route?.path);
       next(); 
    })

    But since req.route is undefined inside middleware handlers, I was looking for a workaround.

    The only one I found involved accessing the internal app router that is private, which is a bad idea of course:

    function getRoutePath(path) {
      var stack = app._router.stack;
      for (var i = 0; i < stack.length; i++) {
        if (stack[i].route && stack[i].match(path)) {
          return stack[i].route.path;
        }
      }
    }

    So what do you suggest?

    Bijan Parsiyar
    @bijanparsiyarr
    hi guys does anybody want to pair program? I am a CS student currently in Uni.
    Ronique Ricketts
    @RoniqueRicketts
    @bijanparsiyarr what are you working on ?
    Andrew Reid
    @manxbiker

    Hi everyone,
    I'm currently pulling my hair out trying to resolve an install problem and I don't appear to find any help with these error codes online.
    I have tried uninstalling and reinstalling node and npm several times but still get the same error.
    I'm using Windows 11 Pro.

    PS C:\_offline\NodeJs_Tutorial\tutpoint> npm install express
    npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
    npm ERR! code EBUSY
    npm ERR! syscall rename
    npm ERR! path C:\Users\educa\AppData\Local\npm-cache\_cacache\tmp\a48e6415
    npm ERR! dest C:\Users\educa\AppData\Local\npm-cache\_cacache\content-v2\sha512\0f\98\3eb786fdcfde4d0e7d392c801d220122a66d5d7f5fe56b081f53e11555eb0b3d518a42e2184ac577fd7499afde46354392ab219538eb08966873d42bb6c9
    npm ERR! errno EBUSY
    npm ERR! Invalid response body while trying to fetch https://registry.npmjs.org/body-parser: EBUSY: resource busy or locked, rename 'C:\Users\educa\AppData\Local\npm-cache\_cacache\tmp\a48e6415' -> 'C:\Users\educa\AppData\Local\npm-cache\_cacache\content-v2\sha512\0f\98\3eb786fdcfde4d0e7d392c801d220122a66d5d7f5fe56b081f53e11555eb0b3d518a42e2184ac577fd7499afde46354392ab219538eb08966873d42bb6c9'
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\educa\AppData\Local\npm-cache\_logs\2022-06-07T04_00_20_150Z-debug-0.log

    Also followed all the instructions to clear the cache, etc. but with no luck.
    Does anyone have any ideas? Thanks.

    1 reply
    Mauri
    @mlsalerno1_twitter
    Hi, i have this error when i try to run nodemon to get on the server

    path = ('^' + path + (strict ? '' : path[path.length - 1] === '/' ? '?' : '/?'))
    ^

    TypeError: Cannot read property 'length' of undefined

    image.png
    Bernard Kortor
    @kortor19
    Hello guys. I have challenge getting a single record from postgresql using expressjs. I'm new in nodejs pls help me out. below is code for my router; //Select campaign by Id
    router.get("/:id", (req, res) =>{
    getCampaignById().then((campaign) =>{
    res.send(campaign)
    }).catch((error) =>{
    res.send(error);
    })
    });

    see my controller; const getCampaignById = async() =>{
    //console.log('get by id')
    const id = parseInt(req.params.id)

    const results = await pool.query(queries.getCampaignById, [id]);
    console.log(results)
     return results.rows

    }

    bi1eygr
    @bi1eygr

    Hi I was hoping to get some help with this issue.
    I'm trying to print the database items in a ul and have each be iterated through. I've tried several things but am at a stand still.

    This is the git rep that I'm working with. It's from a tutorial. I'm wondering if anyone can guide me in trying to access the mysql elements. Ideally I'm going to make an mvc and instead of getting ALL results I'd like to have them listed individually.

    Thanks.

    https://github.com/atharvadeosthale/rest-api-mysql-article

    James Gardner
    @james-gardner
    Has anybody had any luck generating openAPI docs from their express code?
    3 replies
    Wesley
    @wesley974
    Hello
    I'm trying to add authentication in my express.js web app. I wish to store email and password using sqlite. What is best to use? JWT or Passport? Someone can advice me please?
    Andrei Lavrenov
    @elfensky

    what is the difference between these three?

    const app1: Application = express();
    const app2: Express = express();
    const app3 = express();

    All 3 will work, but is there a benefit to using one or the other?

    Taha Elkarroumy
    @t-el
    Hi guys I have an interview with a start up company and they gave me a kind of confusion question that said to make an api endpoints using express to GET POST DELETE and PATCH things from a MongodB data source, but they told me to make header Authorization using api keys
    even though there is no user schema in the scope
    No loging route , how can I generate api keys
    Any one know a way to deal with that