How to access Google Chrome’s IndexedDB/LevelDB files?

Keys in leveldb are arbitrary binary sequences. Clients implement comparators to define ordering between keys. The default comparator for leveldb is something equivalent to strncmp. Chrome’s comparator for Indexed DB’s store is more complicated. If you try and use a leveldb instance with a different comparator than it was created with you’ll observe keys in … Read more

Go to the TypeScript source file instead of the type definition file in VS Code

Since Typescript 2.9 it is possible to compile your library with the declarationMap flag ./node_modules/typescript/bin/tsc -p . –declarationMap Doing so creates a declaration map file (dist/ActionApi.d.ts.map) and a link to the map at the bottom of the corresponding d.ts file //# sourceMappingURL=ActionApi.d.ts.map When VSCodes encounters such a declarationMap it knows where to go to and … Read more

How to connect two node.js servers with websockets?

For future people: Here is 2 very simple Node.js apps that use socket.io to connect, send and receive messages between each other. Required package is: npm install socket.io Node-App-1 server.js: var io = require(‘socket.io’).listen(3000); io.on(‘connection’, function (socket) { console.log(‘connected:’, socket.client.id); socket.on(‘serverEvent’, function (data) { console.log(‘new message from client:’, data); }); setInterval(function () { socket.emit(‘clientEvent’, Math.random()); … Read more

How to store a file with file extension with multer?

I have a workaround for the adding proper extension of files. If you use path node module var multer = require(‘multer’); var path = require(‘path’) var storage = multer.diskStorage({ destination: function (req, file, cb) { cb(null, ‘uploads/’) }, filename: function (req, file, cb) { cb(null, Date.now() + path.extname(file.originalname)) //Appending extension } }) var upload = … Read more