How does one debug NextJS React apps with WebStorm?

The following steps work for me: start the app with next (npm run dev or whatever your start script looks like) add breakpoints, create JavaScript Debug run configuration, specify http://localhost:3000 URL debug If you like to debug the code that is executed on the server side, I’d suggest using the Node.js run configuration with node_modules\next\dist\bin\next … Read more

MongoDB on with Docker “failed to connect to server [localhost:27017] on first connect “

By default Compose sets up a single network for your app. Each container for a service joins the default network and is both reachable by other containers on that network, and discoverable by them at a hostname identical to the container name. According to your docker-compose.yaml file you can access you mongo container on 127.0.0.1:27017 … Read more

req.session is undefined using express-session

Once you mount a router onto an Express app, any subsequently declared middleware on that app won’t get called for any requests that target the router. So if you have this: app.use(router) app.use(session(…)); The session middleware won’t get called for any requests that get handled by router (even if you declare the routes that the … Read more

How to properly return a result from mysql with Node?

You’re going to need to get your head around asynchronous calls and callbacks with javascript, this isn’t C#, PHP, etc… Here’s an example using your code: function get_info(data, callback){ var sql = “SELECT a from b where info = data”; connection.query(sql, function(err, results){ if (err){ throw err; } console.log(results[0].objid); // good stuff_i_want = results[0].objid; // … Read more

Class constructor cannot be invoked without ‘new’ – typescript with commonjs

TypeScript transpiles a class to its ES5 counterpart, but this way it’s necessary that entire class hierarchy is transpiled to ES5. In case parent class is untranspiled (native class or imported ES6 class, including the ones that were transpiled with Babel), this won’t work, because TypeScript relies on var instance = Parent.call(this, …) || this … Read more

Winston logging object

You are trying to insert a JSON object directly into the string, so it will print [Object Object] without the JSON.stringify. This is not fixable by configuring Winston, as this problem happens while the string is generated (before the logger.debug function actually reads it), so a console.log call would print the same thing. The first … Read more