expressHandler.js 684 B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. module.exports = function (base, io) {
  3. app.post('/login', function (user) {
  4. base.login(user, function (result) {
  5. res.send(JSON.stringify(result));
  6. });
  7. });
  8. app.post('/register', function (user) {
  9. base.register(user, function (result) {
  10. res.send(JSON.stringify(result));
  11. });
  12. });
  13. app.get('/rooms', function () {
  14. base.rooms(function (result) {
  15. res.send(JSON.stringify(result));
  16. });
  17. });
  18. app.get('/room/:id', function (id) {
  19. base.room(id, function (result) {
  20. res.send(JSON.stringify(result));
  21. });
  22. });
  23. app.get('/search/:query', function () {
  24. base.search(query, function (result) {
  25. res.send(JSON.stringify(result));
  26. });
  27. });
  28. };