GridFS file server for Connect.
npm install connect-gridfs
db
— previously opened MongoDB Db instancegzip
—object
with gzip compression settings ortrue
for default gzip settings, defaulting tofalse
(gzipping disable)
chunkSize
windowBits
level
memLevel
strategy
dictionary
Additional gzip options:
minLength
— sets the minimum length of a response that will be gzipped, all responses gzipping by defaultmimeTypes
— enables gzipping of responses for the specified MIME types, all responses gzipping by default
var http = require('http');
var mongodb = require('mongodb');
var connect = require('connect');
var connectGridfs = require('connect-gridfs');
var app = connect();
var server = http.createServer(app);
var db = new mongodb.Db('test', new mongodb.Server('127.0.0.1', 27017, { auto_reconnect: true }), { w: 1 });
db.open(function(err) {
app.use('/public/', connectGridfs({ db : db, gzip : { level : 4, minLength : 1024 * 16, mimeTypes : ['text/css', 'text/html', 'application/x-javascript'] } }));
server.listen(3000);
});