You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
751 B
JavaScript
20 lines
751 B
JavaScript
9 months ago
|
const { domain } = require('../../config').server;
|
||
|
const { isEmpty } = require('../../utils/commons.util');
|
||
|
const { getConnection } = require('../../services/connections.service');
|
||
|
const axios = require('axios');
|
||
|
|
||
|
module.exports = async (ctx, next) => {
|
||
|
try {
|
||
|
console.log('forward start ---------------');
|
||
|
// console.log(/^\/wai-server\/v\d{1}\/(?!channels|messages)/.test(ctx.path));
|
||
|
const { waisession } = ctx.headers;
|
||
|
const findSession = await getConnection({ sesson_id: waisession, status: 'open' });
|
||
|
if (!isEmpty(findSession) && findSession.connect_domain === domain) {
|
||
|
await next();
|
||
|
}
|
||
|
// todo: forward to target server
|
||
|
|
||
|
console.log('forward End ---------------');
|
||
|
} catch (err) {}
|
||
|
};
|