Skip to content
Advertisement

Tag: node.js

Node + Passport, Error: Authentication strategies must have a name

I’m trying to initialize a SAML strategy during the require line. Something like this: but am getting the error: or TypeError: Cannot read property ‘name’ of undefined at Authenticator.use if a custom strategy name is not defined: passport.use(myStrat); . I’ve had it like this (which works): but I wish to change it because I need to call passport-saml’s Stragety.generateServiceProviderMetadata() function

chain promises in javascript

I’ve created many promises like that, in order to create object in my database. At the end, I want call all my promises in the order I want. (because somes object depend of other, so I need to keep that order) So I expect to see : Unfortunately, this messages are shuffled and I don’t understand what. Thanks Answer Looks

Express.Static not working for subdirectory

Express.static is working great for any view in root directory, but it breaks when I add a subdirectory. Works: Doesn’t Work: I’m guessing __dirname is changed to whatever directory the get request is made from, but I just want to use the root (/public) directory for all static requests. Answer Use it this way:

How to use XHR API in Node.js?

This is a follow-up to my previous question Suppose I’ve some javascript code, which runs fine on client (in a browser). This code makes a lot of XHR calls using the browser API. Now I would like to run this code in node.js. Does node.js provide the XHR API as in browser ? Answer Natively Node.js does not provide the

Running npm globally installed packages

Can someone please explain how do node’s globally installed behave. It is really confusing me. If I install a package (with executables) such as http-serverglobally I can run it with: But if I do I get I suspect my ternpackage in emacs is trying to run it with node hence breaking. Why is this happening? Why can’t node find the

Sequelize: Cannot set a new unique constraint message

I am trying to setup a validation message for unique constraint violation for the fields username and email. However, whenever an already taken username is entered, it shows the message defined for the email property, but shows the input for the username property and also says that this input is for the username property. How would I fix this? Here

In Express.js, should I return response or not?

For Express.js 4.x I can’t find wether I should return the response (or next function) or not, so: This: Or this: And what is the difference? Answer You don’t. The (req, res) signature tells express this is the last function in the chain, and it does not expect a return value from this function. You can add a return statement,

Advertisement