expressHandler.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. });
  11. });
  12. app.post('/users/register', function (req, res) {
  13. core['/users/register'](req.body.user, (result) => {
  14. res.send(JSON.stringify(result));
  15. });
  16. console.log('posted');
  17. });
  18. app.get('/stations', function (req, res) {
  19. core['/stations'](function (result) {
  20. res.send(JSON.stringify(result));
  21. });
  22. });
  23. app.get('/stations/join/:id', function (req, res) {
  24. core['/stations/join/:id'](req.params.id, function (result) {
  25. res.send(JSON.stringify(result));
  26. });
  27. });
  28. app.get('/stations/search/:query', function (req, res) {
  29. core['/stations/search/:query'](req.params.query, function (result) {
  30. res.send(JSON.stringify(result));
  31. });
  32. });
  33. };