Upgrade deps
This commit is contained in:
parent
5b5eba359a
commit
523dc859ed
|
@ -14,3 +14,4 @@ results
|
|||
npm-debug.log
|
||||
.idea
|
||||
node_modules
|
||||
providers-private.json
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
providers-private.json
|
|
@ -3,17 +3,12 @@ var loopback = require('loopback')
|
|||
|
||||
var path = require('path');
|
||||
|
||||
app.use(app.router);
|
||||
|
||||
// expose a rest api
|
||||
app.use('/api', loopback.rest());
|
||||
|
||||
app.use(loopback.static(path.join(__dirname, 'public')));
|
||||
|
||||
|
||||
app.configure(function () {
|
||||
app.set('port', process.env.PORT || 3000);
|
||||
});
|
||||
app.set('port', process.env.PORT || 3000);
|
||||
|
||||
var ds = loopback.createDataSource({
|
||||
connector: require('../index'),
|
||||
|
@ -25,21 +20,5 @@ var container = ds.createModel('container');
|
|||
|
||||
app.model(container);
|
||||
|
||||
/*
|
||||
app.get('/', function (req, res, next) {
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
var form = "<html><body><h1>Storage Service Demo</h1>" +
|
||||
"<a href='/api/containers'>List all containers</a><p>" +
|
||||
"Upload to container c1: <p>" +
|
||||
"<form method='POST' enctype='multipart/form-data' action='/containers/container1/upload'>"
|
||||
+ "File to upload: <input type=file name=uploadedFiles multiple=true><br>"
|
||||
+ "Notes about the file: <input type=text name=note><br>"
|
||||
+ "<input type=submit value=Upload></form>" +
|
||||
"</body></html>";
|
||||
res.send(form);
|
||||
res.end();
|
||||
});
|
||||
*/
|
||||
|
||||
app.listen(app.get('port'));
|
||||
console.log('http://127.0.0.1:' + app.get('port'));
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
var StorageService = require('../').StorageService;
|
||||
var providers = require('./providers.json');
|
||||
var providers = null;
|
||||
try {
|
||||
providers = require('./providers-private.json');
|
||||
} catch(err) {
|
||||
providers = require('./providers.json');
|
||||
}
|
||||
var express = require('express');
|
||||
var app = express();
|
||||
|
||||
app.configure(function () {
|
||||
app.set('port', process.env.PORT || 3001);
|
||||
app.set('views', __dirname + '/views');
|
||||
app.set('view engine', 'ejs');
|
||||
app.use(express.favicon());
|
||||
// app.use(express.logger('dev'));
|
||||
app.use(express.methodOverride());
|
||||
app.use(app.router);
|
||||
});
|
||||
app.set('port', process.env.PORT || 3000);
|
||||
app.set('views', __dirname + '/views');
|
||||
app.set('view engine', 'ejs');
|
||||
|
||||
var handler = new StorageService(
|
||||
{
|
||||
|
@ -20,7 +19,7 @@ var handler = new StorageService(
|
|||
keyId: providers.amazon.keyId
|
||||
});
|
||||
|
||||
app.get('/', function (req, res, next) {
|
||||
app.get('/', function(req, res, next) {
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
var form = "<html><body><h1>Storage Service Demo</h1>" +
|
||||
"<a href='/download'>List all containers</a><p>" +
|
||||
|
@ -34,43 +33,43 @@ app.get('/', function (req, res, next) {
|
|||
res.end();
|
||||
});
|
||||
|
||||
app.post('/upload/:container', function (req, res, next) {
|
||||
handler.upload(req, res, function (err, result) {
|
||||
app.post('/upload/:container', function(req, res, next) {
|
||||
handler.upload(req, res, function(err, result) {
|
||||
if (!err) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(200, result);
|
||||
res.status(200).send(result);
|
||||
} else {
|
||||
res.send(500, err);
|
||||
res.status(500).send(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/download', function (req, res, next) {
|
||||
handler.getContainers(function (err, containers) {
|
||||
app.get('/download', function(req, res, next) {
|
||||
handler.getContainers(function(err, containers) {
|
||||
var html = "<html><body><h1>Containers</h1><ul>";
|
||||
containers.forEach(function (f) {
|
||||
containers.forEach(function(f) {
|
||||
html += "<li><a href='/download/" + f.name + "'>" + f.name + "</a></li>"
|
||||
});
|
||||
html += "</ul><p><a href='/'>Home</a></p></body></html>";
|
||||
res.send(200, html);
|
||||
res.status(200).send(html);
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/download/:container', function (req, res, next) {
|
||||
handler.getFiles(req.params.container, function (err, files) {
|
||||
app.get('/download/:container', function(req, res, next) {
|
||||
handler.getFiles(req.params.container, function(err, files) {
|
||||
var html = "<html><body><h1>Files in container " + req.params.container + "</h1><ul>";
|
||||
files.forEach(function (f) {
|
||||
files.forEach(function(f) {
|
||||
html += "<li><a href='/download/" + f.container + "/" + f.name + "'>" + f.container + "/" + f.name + "</a></li>"
|
||||
});
|
||||
html += "</ul><p><a href='/'>Home</a></p></body></html>";
|
||||
res.send(200, html);
|
||||
res.status(200).send(html);
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/download/:container/:file', function (req, res, next) {
|
||||
handler.download(req.params.container, req.params.file, res, function (err, result) {
|
||||
app.get('/download/:container/:file', function(req, res, next) {
|
||||
handler.download(req.params.container, req.params.file, res, function(err, result) {
|
||||
if (err) {
|
||||
res.send(500, err);
|
||||
res.status(500).send(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,15 +3,9 @@ var StorageService = require('../').StorageService;
|
|||
var express = require('express');
|
||||
var app = express();
|
||||
|
||||
app.configure(function () {
|
||||
app.set('port', process.env.PORT || 3001);
|
||||
app.set('views', __dirname + '/views');
|
||||
app.set('view engine', 'ejs');
|
||||
app.use(express.favicon());
|
||||
// app.use(express.logger('dev'));
|
||||
app.use(express.methodOverride());
|
||||
app.use(app.router);
|
||||
});
|
||||
app.set('port', process.env.PORT || 3000);
|
||||
app.set('views', __dirname + '/views');
|
||||
app.set('view engine', 'ejs');
|
||||
|
||||
// Create the container
|
||||
var mkdirp = require('mkdirp');
|
||||
|
@ -19,7 +13,7 @@ mkdirp.sync('/tmp/storage/con1');
|
|||
|
||||
var handler = new StorageService({provider: 'filesystem', root: '/tmp/storage'});
|
||||
|
||||
app.get('/', function (req, res, next) {
|
||||
app.get('/', function(req, res, next) {
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
var form = "<html><body><h1>Storage Service Demo</h1>" +
|
||||
"<a href='/download'>List all containers</a><p>" +
|
||||
|
@ -33,43 +27,43 @@ app.get('/', function (req, res, next) {
|
|||
res.end();
|
||||
});
|
||||
|
||||
app.post('/upload/:container', function (req, res, next) {
|
||||
handler.upload(req, res, function (err, result) {
|
||||
app.post('/upload/:container', function(req, res, next) {
|
||||
handler.upload(req, res, function(err, result) {
|
||||
if (!err) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.send(200, result);
|
||||
res.status(200).send(result);
|
||||
} else {
|
||||
res.send(500, err);
|
||||
res.status(500).send(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/download', function (req, res, next) {
|
||||
handler.getContainers(function (err, containers) {
|
||||
app.get('/download', function(req, res, next) {
|
||||
handler.getContainers(function(err, containers) {
|
||||
var html = "<html><body><h1>Containers</h1><ul>";
|
||||
containers.forEach(function (f) {
|
||||
containers.forEach(function(f) {
|
||||
html += "<li><a href='/download/" + f.name + "'>" + f.name + "</a></li>"
|
||||
});
|
||||
html += "</ul><p><a href='/'>Home</a></p></body></html>";
|
||||
res.send(200, html);
|
||||
res.status(200).send(html);
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/download/:container', function (req, res, next) {
|
||||
handler.getFiles(req.params.container, function (err, files) {
|
||||
app.get('/download/:container', function(req, res, next) {
|
||||
handler.getFiles(req.params.container, function(err, files) {
|
||||
var html = "<html><body><h1>Files in container " + req.params.container + "</h1><ul>";
|
||||
files.forEach(function (f) {
|
||||
files.forEach(function(f) {
|
||||
html += "<li><a href='/download/" + f.container + "/" + f.name + "'>" + f.container + "/" + f.name + "</a></li>"
|
||||
});
|
||||
html += "</ul><p><a href='/'>Home</a></p></body></html>";
|
||||
res.send(200, html);
|
||||
res.status(200).send(html);
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/download/:container/:file', function (req, res, next) {
|
||||
handler.download(req.params.container, req.params.file, res, function (err, result) {
|
||||
app.get('/download/:container/:file', function(req, res, next) {
|
||||
handler.download(req.params.container, req.params.file, res, function(err, result) {
|
||||
if (err) {
|
||||
res.send(500, err);
|
||||
res.status(500).send(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
16
package.json
16
package.json
|
@ -7,16 +7,16 @@
|
|||
"test": "./node_modules/.bin/mocha --timeout 30000 test/*test.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"pkgcloud": "~0.9.6",
|
||||
"async": "~0.9.0",
|
||||
"formidable": "~1.0.14"
|
||||
"pkgcloud": "^1.1.0",
|
||||
"async": "^0.9.0",
|
||||
"formidable": "^1.0.16"
|
||||
},
|
||||
"devDependencies": {
|
||||
"express": "~3.4.0",
|
||||
"loopback": "1.x.x",
|
||||
"mocha": "~1.18.2",
|
||||
"supertest": "~0.13.0",
|
||||
"mkdirp": "~0.5.0"
|
||||
"express": "^4.11.0",
|
||||
"loopback": "^2.10.0",
|
||||
"mocha": "^2.1.0",
|
||||
"supertest": "^0.15.0",
|
||||
"mkdirp": "^0.5.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
Loading…
Reference in New Issue