expressHandler.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use strict';
  2. module.exports = function (core, app) {
  3. app.post('/users/login', function (req, res) {
  4. // TODO: Give this a better error message
  5. if (!req.body.user) {
  6. return res.send(JSON.stringify({ 'status': 'error', 'message': 'invalid request' }));
  7. }
  8. core['/users/login'](req.body.user, function (result) {
  9. res.send(JSON.stringify(result));
  10. console.log(JSON.stringify(result));
  11. });
  12. });
  13. app.post('/users/register', function (req, res) {
  14. core['/users/register'](req.body.user, function (result) {
  15. res.send(JSON.stringify(result));
  16. });
  17. console.log('posted');
  18. });
  19. app.get('/stations', function (req, res) {
  20. core['/stations'](function (result) {
  21. res.send(JSON.stringify(result));
  22. });
  23. });
  24. app.get('/stations/join/:id', function (req, res) {
  25. core['/stations/join/:id'](req.params.id, function (result) {
  26. res.send(JSON.stringify(result));
  27. });
  28. });
  29. app.get('/stations/search/:query', function (req, res) {
  30. core['/stations/search/:query'](req.params.query, function (result) {
  31. res.send(JSON.stringify(result));
  32. });
  33. });
  34. };