expressHandler.js 603 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. module.exports = function (core, app) {
  3. app.post('/login', function (user) {
  4. core.login(user, function (result) {
  5. res.send(JSON.stringify(result));
  6. });
  7. });
  8. app.post('/register', function (user) {
  9. core.register(user, function (result) {
  10. res.send(JSON.stringify(result));
  11. });
  12. });
  13. app.get('/rooms', function () {
  14. core.rooms(function (result) {
  15. res.send(JSON.stringify(result));
  16. });
  17. });
  18. app.get('/search/:query', function () {//TODO Replace search with a better name.
  19. core.search(query, function (result) {
  20. res.send(JSON.stringify(result));
  21. });
  22. });
  23. };