forked from plouc/cloud-pie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (26 loc) · 792 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
var express = require('express');
var app = express();
var router = express.Router();
var fs = require('fs');
var stack = require('./server/lib/aws/stack');
var awsFilePath = 'dist/aws.json';
router.use(function (req, res, next) {
console.log('%s %s %s', req.method, req.url, req.path);
next();
});
router.get('/fetch', function (req, res) {
stack.fetch()
.then(function (data) {
fs.writeFile(awsFilePath, JSON.stringify(data, null, ' '), function (err) {
if (err) { throw err; }
res.send(data);
});
})
;
});
app.use('/', router);
app.use(express.static(__dirname + '/dist'));
app.listen(3000, function () {
console.log('application listening on port 3000');
});