summaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rw-r--r--index.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/index.js b/index.js
index 5f5f45c..f174bbe 100644
--- a/index.js
+++ b/index.js
@@ -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()