loopback-component-storage/example/app-asteroid.js

52 lines
1.4 KiB
JavaScript
Raw Normal View History

2013-07-03 01:10:23 +00:00
var asteroid = require('asteroid')
, app = module.exports = asteroid();
2013-07-03 23:58:20 +00:00
// var StorageService = require('../');
2013-07-03 01:10:23 +00:00
// expose a rest api
app.use(asteroid.rest());
app.configure(function () {
app.set('port', process.env.PORT || 3000);
});
2013-07-03 23:58:20 +00:00
var ds = asteroid.createDataSource({
connector: require('../lib/storage-connector'),
provider: 'filesystem',
root: '/tmp/storage'
});
var Container = ds.createModel('container', {name: String});
console.log(Container);
Container.getContainers(console.log);
console.log('shared', Container.getContainers.shared);
app.model(Container);
/*
2013-07-03 01:10:23 +00:00
var handler = new StorageService({provider: 'filesystem', root: '/tmp/storage'});
app.service('storage', handler);
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>" +
"Upload to container c1: <p>" +
"<form method='POST' enctype='multipart/form-data' action='/upload/c1'>"
+ "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();
});
2013-07-03 23:58:20 +00:00
*/
2013-07-03 01:10:23 +00:00
app.listen(app.get('port'));
console.log('http://127.0.0.1:' + app.get('port'));