feat: stub code for v3 chats api
parent
a115b771f0
commit
02e878be72
@ -0,0 +1,49 @@
|
||||
/* eslint-disable */
|
||||
'use strict';
|
||||
|
||||
const api = require('../../api');
|
||||
|
||||
const helpers = require('../helpers');
|
||||
|
||||
const Chats = module.exports;
|
||||
|
||||
Chats.list = async (req, res) => {
|
||||
// ...
|
||||
};
|
||||
|
||||
Chats.create = async (req, res) => {
|
||||
// ...
|
||||
};
|
||||
|
||||
Chats.exists = async (req, res) => {
|
||||
helpers.formatApiResponse(200, res);
|
||||
};
|
||||
|
||||
Chats.get = async (req, res) => {
|
||||
// ...
|
||||
};
|
||||
|
||||
Chats.post = async (req, res) => {
|
||||
// ...
|
||||
};
|
||||
|
||||
Chats.users = async (req, res) => {
|
||||
// ...
|
||||
};
|
||||
|
||||
Chats.invite = async (req, res) => {
|
||||
// ...
|
||||
};
|
||||
|
||||
Chats.kick = async (req, res) => {
|
||||
// ...
|
||||
};
|
||||
|
||||
Chats.message = {};
|
||||
Chats.messages.edit = async (req, res) => {
|
||||
// ...
|
||||
};
|
||||
|
||||
Chats.messages.delete = async (req, res) => {
|
||||
// ...
|
||||
};
|
@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
const router = require('express').Router();
|
||||
const middleware = require('../../middleware');
|
||||
const controllers = require('../../controllers');
|
||||
const routeHelpers = require('../helpers');
|
||||
|
||||
const { setupApiRoute } = routeHelpers;
|
||||
|
||||
module.exports = function () {
|
||||
const middlewares = [middleware.ensureLoggedIn, middleware.canChat];
|
||||
|
||||
setupApiRoute(router, 'get', '/', [...middlewares], controllers.write.chats.list);
|
||||
setupApiRoute(router, 'post', '/', [...middlewares, middleware.checkRequired.bind(null, ['uids'])], controllers.write.chats.create);
|
||||
|
||||
setupApiRoute(router, 'head', '/:roomId', [...middlewares, middleware.assert.room], controllers.write.chats.exists);
|
||||
setupApiRoute(router, 'get', '/:roomId', [...middlewares, middleware.assert.room], controllers.write.chats.get);
|
||||
setupApiRoute(router, 'post', '/:roomId', [...middlewares, middleware.assert.room], controllers.write.chats.post);
|
||||
// no route for room deletion, reserved just in case...
|
||||
|
||||
setupApiRoute(router, 'get', '/:roomId/users', [...middlewares, middleware.assert.room], controllers.write.chats.users);
|
||||
setupApiRoute(router, 'put', '/:roomId/users', [...middlewares, middleware.assert.room, middleware.checkRequired.bind(null, ['uids'])], controllers.write.chats.invite);
|
||||
setupApiRoute(router, 'delete', '/:roomId/users', [...middlewares, middleware.assert.room, middleware.checkRequired.bind(null, ['uids'])], controllers.write.chats.kick);
|
||||
|
||||
setupApiRoute(router, 'put', '/:roomId/:mid', [...middlewares, middleware.assert.room], controllers.write.chats.messages.edit);
|
||||
setupApiRoute(router, 'delete', '/:roomId/:mid', [...middlewares, middleware.assert.room], controllers.write.chats.messages.delete);
|
||||
|
||||
return router;
|
||||
};
|
Loading…
Reference in New Issue