diff options
| author | Jules Laplace <jules@okfoc.us> | 2017-04-21 16:03:11 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2017-04-21 16:03:11 -0400 |
| commit | ef83dba4a83e23e38b67ee31b79e79c9e25a003d (patch) | |
| tree | be0e65ee556d215796f6c64e3df7d8adb5c51554 /index.js | |
| parent | 5028ad81845308f3b1954dcc1fde664077fa0fa9 (diff) | |
display orders per product, download as csv
Diffstat (limited to 'index.js')
| -rw-r--r-- | index.js | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -15,6 +15,8 @@ var basic = auth.basic({ } ) +var db = require('./db') + var server, app var site = {} @@ -25,7 +27,8 @@ site.init = function(){ app.use(express.static('views')) app.use(auth.connect(basic)) - // app.get('/admin', auth.connect(basic), site.admin) + app.get('/api/products', site.json(db.products)) + app.get('/api/orders', site.json(db.ordersBySku)) var server = http.createServer(app).listen(process.env.PORT, function () { var port = server.address().port @@ -33,6 +36,14 @@ site.init = function(){ }) } +site.json = function(method){ + return function(req, res){ + method(req.query.id).then(function(data){ + res.json(data) + }) + } +} + site.init() |
