Skip to content

Tag: node.js

Rest with Express.js nested router

Suppose I want to have REST endpoints which look roughly like this: CRUD on each if makes sense. For example, /user POST creates a new user, GET fetches all users. /user/user_id GET fetches just that one user. Items are user specific so I put them under user_id, which is a particular user. Now to make Express…

How to read and save attachments using node-imap

I’m using node-imap and I can’t find a straightforward code example of how to save attachments from emails fetched using node-imap to disk using fs. I’ve read the documentation a couple of times. It appears to me I should do another fetch with a reference to the specific part of a message be…

Socket.io error hooking into express.js

I’m trying to hook socket.io and express.js together: At the line: var io = require(‘socket.io’).listen(app); I’m getting an error: There doesn’t seem to be anything on SO/google about this error… Answer You can do it without using http module app.listen return a server ins…

How to set cell width when export .xlsx files with js-xlsx

I am trying to set a fixed column/cell width to my exported excel files with js-xlsx. EDIT: Here is the source of js-xlsx: https://github.com/SheetJS/js-xlsx Answer I found a snippet the the write test here https://github.com/SheetJS/js-xlsx/blob/master/tests/write.js#L14-L19 For quick reference, where ws is …

Express Node.js doesn’t work

I installed express 4 along with node.js,npm and express-generator on my ubuntu 12.04 and created an app using the following commands: Now what I should get is “Express server running on port 3000” but instead the command simply executes and doesn’t leave any message or error. So I have no i…