'use strict';

const main = require('../app/controllers/main');
const api = require('../app/controllers/api');
const auth = require('../app/controllers/auth');

/**
 * Expose routes
 */

module.exports = function applyRoutes(app) {
  app.get('/', main.index);
  app.post('/auth/token', auth.token);
  app.get('/:type(orders|accounts|portions|vendors)', api);
  app.get('/:type(orders|accounts|portions|vendors)/:id', api);
  app.post('/:type(orders|accounts|portions|vendors)', api);
};

'use strict';

const passport = require('passport');
const main = require('../app/controllers/main');
const api = require('../app/controllers/api');
const auth = require('../app/controllers/auth');

/**
 * Expose routes
 */

module.exports = function applyRoutes(app) {
  app.get('/', main.index);
  app.post('/auth/token', auth.token);
  app.get('/me', passport.authenticate('jwt'), function(req, res) {
    res.send(req.user);
  });
  app.get('/:type(orders|accounts|portions|vendors)', api);
  app.get('/:type(orders|accounts|portions|vendors)/:id', api);
  app.post('/:type(orders|accounts|portions|vendors)', api);
};

Add API endpoint to get current user info
Add API endpoint to get current user info
