Last active
August 29, 2015 14:06
-
-
Save dwaligora/de92f1ee9375f8b809fe to your computer and use it in GitHub Desktop.
router.user require callback function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
module.exports = function(app) { | |
/* | |
* resources | |
*/ | |
app.use(require('./zip')(app)); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant@zipper:/var/www/zipper$ node runserver.js | |
/var/www/zipper/node_modules/express/lib/router/index.js:416 | |
throw new TypeError('Router.use() requires callback function'); | |
^ | |
TypeError: Router.use() requires callback function | |
at Function.use (/var/www/zipper/node_modules/express/lib/router/index.js:416:11) | |
at Function.use (/var/www/zipper/node_modules/express/lib/application.js:193:14) | |
at module.exports (/var/www/zipper/kernel/api/v1/index.js:7:9) | |
at module.exports (/var/www/zipper/kernel/api/index.js:41:41) | |
at Object.<anonymous> (/var/www/zipper/app.js:9:32) | |
at Module._compile (module.js:456:26) | |
at Object.Module._extensions..js (module.js:474:10) | |
at Module.load (module.js:356:32) | |
at Function.Module._load (module.js:312:12) | |
at Module.require (module.js:364:17) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var request = require('request'), | |
async = require('async'), | |
util = require('util'), | |
fs = require('fs'), | |
https = require('https'), | |
http = require('http'), | |
hash = require('object-hash'), | |
pkgcloud = require('pkgcloud'), | |
config = require('../../../config'), | |
session = require('../../../lib/session'), | |
archiver = require('archiver'), | |
formatterManager = require('../../../lib/formatter'), | |
settingsManager = require('../../../lib/settings'), | |
zipManager = require('../../../lib/zip/manager'); | |
module.exports = function(app) { | |
/** | |
* POST /zip - preparing archive token for easy downloading from browser (/GET method) | |
*/ | |
app.post( | |
'/zip', | |
require('../../../middleware/validator/zip').Create, | |
require('../../../middleware/validator/response/api'), | |
postZipHandler, | |
require('../../../middleware/http/response/json') | |
); | |
}; | |
/** | |
* @param {Request} req | |
* @param {Response} res | |
* @param {Function} next | |
*/ | |
function postZipHandler(req, res, next) { | |
zipManager.switchStorageDb(10); | |
res.locals.archiveHashString = hash(req.body); | |
// store data & set expiration time | |
zipManager.saveArchiveData( | |
formatterManager.get('redis.key').format([ | |
session.getClient(), | |
session.getProvider(), | |
'archive', | |
res.locals.archiveHashString | |
]), | |
req.body, | |
60 * 60 * 24 * 30 | |
); | |
next(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment