How to Import Intellisense files into vsCode (Visual Studio Code)

UPDATE: August 2016: TSD is now depreciated. instead use https://www.npmjs.com/package/typings npm install typings –global OR If using VS2015 NodeJS v1.2 released 29th July 2016 then [email protected] is installed automatically for you during first use: Executing command ‘npm install “C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\MICROSOFT\NODE.JS TOOLS FOR VISUAL STUDIO\1.2\TypingsAcquisitionTool” [email protected] ..\..\..\..\..\node_modules\ntvs-typings-acquisition-tool ├── [email protected] └── [email protected] ([email protected], … Read more

NodeJS + Express: How to secure a URL

Yep, middleware is exactly what you want. A middleware function is just a function that works just like any other Express route handler, expept it gets run before your actual route handler. You could, for example, do something like this: function requireLogin(req, res, next) { if (req.session.loggedIn) { next(); // allow the next route to … Read more

Express 4.14 – How to send 200 status with a custom message?

You can use: res.status(200).send(‘some text’); if you want to pass number to the send method, convert it to string first to avoid deprecation error message. the deprecation is for sending status directly inside send. res.send(200) // <- is deprecated BTW – the default status is 200, so you can simply use res.send(‘Success 1’). Use .status() … Read more

Express.js hbs module – register partials from .hbs file

For convenience, registerPartials provides a quick way to load all partials from a specific directory: var hbs = require(‘hbs’); hbs.registerPartials(__dirname + ‘/views/partials’); Partials that are loaded from a directory are named based on their filename, where spaces and hyphens are replaced with an underscore character: template.html -> {{> template}} template 2.html -> {{> template_2}} login … Read more