Skip to content

Commit

Permalink
04 Setting up an API
Browse files Browse the repository at this point in the history
  • Loading branch information
alarner committed Jul 17, 2016
1 parent f0ff5c1 commit 4f54b5f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app.js
Expand Up @@ -57,6 +57,8 @@ app.use(localUser);
/* */ /* */
/*******************************/ /*******************************/


let bookshelfApi = require('bookshelf-api');
let apiMiddleware = bookshelfApi({ path: './models' });
/* 1. ROUTES are loaded here */ /* 1. ROUTES are loaded here */


// let api = require('./routes/api1'); // let api = require('./routes/api1');
Expand All @@ -68,6 +70,7 @@ let auth = require('./routes/auth');
// app.use('/api/v1/', api); // app.use('/api/v1/', api);
app.use('/auth', auth); app.use('/auth', auth);
app.use('/', index); app.use('/', index);
app.use('/api/v1', apiMiddleware);


// catch 404 and forward to error handler // catch 404 and forward to error handler
app.use(function(req, res, next) { app.use(function(req, res, next) {
Expand Down
4 changes: 4 additions & 0 deletions models/Image.js
@@ -0,0 +1,4 @@
module.exports = bookshelf.model('Image', {
tableName: 'images',
hasTimestamps: ['createdAt', 'updatedAt', 'deletedAt']
});
4 changes: 4 additions & 0 deletions models/Link.js
@@ -0,0 +1,4 @@
module.exports = bookshelf.model('Link', {
tableName: 'links',
hasTimestamps: ['createdAt', 'updatedAt', 'deletedAt']
});
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -13,6 +13,7 @@
"bcrypt": "^0.8.7", "bcrypt": "^0.8.7",
"body-parser": "~1.15.2", "body-parser": "~1.15.2",
"bookshelf": "^0.10.0", "bookshelf": "^0.10.0",
"bookshelf-api": "^1.6.0",
"browserify": "^13.0.1", "browserify": "^13.0.1",
"bunyan-prettystream": "^0.1.3", "bunyan-prettystream": "^0.1.3",
"chokidar": "^1.6.0", "chokidar": "^1.6.0",
Expand Down

0 comments on commit 4f54b5f

Please sign in to comment.