Sinatra inspired web development framework for node.js -- insanely fast, flexible, and simple
context
optional: context?
to get it work
Hey guys,
I'm trying to get the full URL of an endpoint, but I'm getting inconsistent results with req.originalUrl
, req.baseUrl
, and req.path
.
The full path has many subpaths, like http://92cca2557089.ngrok.io/org/us-central1/sms/test
sometimes originalUrl returns the whole thing: /org/us-central1/sms/test
, but often only test
This is the same behaviour for baseUrl
and path
What gives?
Hi, not sure if I am misunderstanding something. In the express docs it seems like in one place it says try/catch will not work for asynchronous error handling, but another says it will:
//http://expressjs.com/en/guide/error-handling.html
You must catch errors that occur in asynchronous code invoked by route handlers or middleware and pass them to Express for processing. For >example:
app.get('/', function (req, res, next) { setTimeout(function () { try { throw new Error('BROKEN') } catch (err) { next(err) } }, 100) })
The above example uses a try...catch block to catch errors in the asynchronous code and pass them to Express.
//http://expressjs.com/en/advanced/best-practice-performance.html#use-try-catch
Here is an example of using try-catch to handle a potential process-crashing exception. This middleware function accepts a query field parameter named “params” that is a JSON object.app.get('/search', function (req, res) { // Simulating async operation setImmediate(function () { var jsonStr = req.query.params try { var jsonObj = JSON.parse(jsonStr) res.send('Success') } catch (e) { res.status(400).send('Invalid JSON string') } }) })
However, try-catch works only for synchronous code. Because the Node platform is primarily asynchronous (particularly in a production environment), try-catch won’t catch a lot of exceptions.
Hello everyone,
I'm working on an open-source monitoring/tracing tool for JavaScript backends called recap.dev(https://recap.dev). Basically, it will record everything that happens while serving a request (API and database calls, logs, etc) and build a nice timeline so it's easy to find bottlenecks and debug. Think Sentry on steroids for the backend. We have an interactive demo if you'd like to know what it looks like (https://demo.recap.dev).
I wrote a post outlining the main benefits of using it here: https://recap.dev/blog/5-reasons-to-use-recap.dev
I'd love nothing more than your honest feedback. Please let me know if that sounds interesting to you. I can help you set it up for absolutely free. Thanks for your time.
Hi! I've been working on Expresso, a faster drop-in replacement for Express's default router. It also allows routes to be added in an order-independent manner.
https://www.npmjs.com/package/expresso-router
Feedback welcome!
hi, i faced a problem while hosting nodejs application in cPanel.
please suggest a solution
Error ID:
b4236a06
Details:
Web application could not be started by the Phusion Passenger application server.
Please read the Passenger log file (search for the Error ID) to find the details of the error.
You can also get a detailed report to appear directly on this page, but for security reasons it is only provided if Phusion Passenger is run with environment set to development and/or with the friendly error pages option set to on.
IndexRouter -> UserRouter -> IdRouter
UserRouter.use('/:id(\\d+)/', idRouter)
is what I'm using right now for this specific thing, but, everything under that isn't working at all.../users/:id/
, and if I make the endpoint through UserRouter.get('/:id(\\d+)/', (req, res) => {})
, it works, everything is executed etc, BUT if I use IdRouter.get('/', (req, res) => {})
, its a 404?!/users/ RegExp(/^\\/(?:(\\id+))\\/?(?=\\/|$)/i)
/foobar/:id(\\d+)/
String.prototype.toString
gives me \uXXXX
instead of the unicode characters in the string representation of a function? I tested this using node with no imports and it doesn't do that. It only happens in express. I'm not sure if express is to blame (could be any other module) but I wouldn't know what else could cause this. I'm using angular and when running it in a browser I don't have this problem. But when using a server to validate the data it does that. And it's not a display problem or something that happens later on when sending the data back to the client. The returned string contains "\u00e4" instead of "ä". I checked the specs for ES and it shouldn't do that.
Hello everyone,
This is Mayank Aggarwal, and I'm a pre-final year student at Manipal University Jaipur pursuing BTech in Information Technology.
Portfolio - https://mayank0255.github.io
GitHub - https://github.com/Mayank0255
Linkedin - https://www.linkedin.com/in/mayank-aggarwal-14301b168/