Node.js - File System get file type, solution around year 2012
Have a look at the mmmagic module. It is a libmagic binding and seems to do exactly what you want.
There is a helper library for looking up mime types https://github.com/broofa/node-mime
var mime = require('mime');
mime.getType('/path/to/file.txt'); // => 'text/plain'
But it still uses the extension for lookup though