Permalink
Browse files

04 Setting up an API

  • Loading branch information...
alarner committed Jul 17, 2016
1 parent f0ff5c1 commit 4f54b5fe47f1455f1c97975a9c505a36fd9a7c09
Showing with 12 additions and 0 deletions.
  1. +3 −0 app.js
  2. +4 −0 models/Image.js
  3. +4 −0 models/Link.js
  4. +1 −0 package.json
View
3 app.js
@@ -57,6 +57,8 @@ app.use(localUser);
/* */
/*******************************/
let bookshelfApi = require('bookshelf-api');
let apiMiddleware = bookshelfApi({ path: './models' });
/* 1. ROUTES are loaded here */
// let api = require('./routes/api1');
@@ -68,6 +70,7 @@ let auth = require('./routes/auth');
// app.use('/api/v1/', api);
app.use('/auth', auth);
app.use('/', index);
app.use('/api/v1', apiMiddleware);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
View
@@ -0,0 +1,4 @@
module.exports = bookshelf.model('Image', {
tableName: 'images',
hasTimestamps: ['createdAt', 'updatedAt', 'deletedAt']
});
View
@@ -0,0 +1,4 @@
module.exports = bookshelf.model('Link', {
tableName: 'links',
hasTimestamps: ['createdAt', 'updatedAt', 'deletedAt']
});
View
@@ -13,6 +13,7 @@
"bcrypt": "^0.8.7",
"body-parser": "~1.15.2",
"bookshelf": "^0.10.0",
"bookshelf-api": "^1.6.0",
"browserify": "^13.0.1",
"bunyan-prettystream": "^0.1.3",
"chokidar": "^1.6.0",

0 comments on commit 4f54b5f

Please sign in to comment.