Extend Express Request object using Typescript

You want to create a custom definition, and use a feature in Typescript called Declaration Merging. This is commonly used, e.g. in method-override. Create a file custom.d.ts and make sure to include it in your tsconfig.json‘s files-section if any. The contents can look as follows: declare namespace Express { export interface Request { tenant?: string … Read more

Sending emails in Node.js? [closed]

Nodemailer is basically a module that gives you the ability to easily send emails when programming in Node.js. There are some great examples of how to use the Nodemailer module at http://www.nodemailer.com/. The full instructions about how to install and use the basic functionality of Nodemailer is included in this link. I personally had trouble … Read more

Why is Node.js single threaded? [closed]

Node.js was created explicitly as an experiment in async processing. The theory was that doing async processing on a single thread could provide more performance and scalability under typical web loads than the typical thread-based implementation. And you know what? In my opinion that theory’s been borne out. A node.js app that isn’t doing CPU … Read more

Push items into mongo array via mongoose

Assuming, var friend = { firstName: ‘Harry’, lastName: ‘Potter’ }; There are two options you have: Update the model in-memory, and save (plain javascript array.push): person.friends.push(friend); person.save(done); or PersonModel.update( { _id: person._id }, { $push: { friends: friend } }, done ); I always try and go for the first option when possible, because it’ll … Read more

What does -save-dev mean in npm install grunt –save-dev

–save-dev: Package will appear in your devDependencies. According to the npm install docs. If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use. In other words, when you run npm install, your … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)