-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathsessions.mjs
More file actions
28 lines (24 loc) · 913 Bytes
/
sessions.mjs
File metadata and controls
28 lines (24 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import chista from '../../chista.mjs';
import SessionsCreate from '../../../../use-cases/main/sessions/Create.mjs';
import SessionsCheck from '../../../../use-cases/main/sessions/Check.mjs';
export default {
create : chista.makeUseCaseRunner(SessionsCreate, req => req.body),
async check(req, res) {
const promise = chista.runUseCase(SessionsCheck, {
params : { token: req.headers.authorization }
});
try {
const userData = await promise;
/* eslint no-param-reassign: 0 */
// eslint-disable-next-line require-atomic-updates
return req.session = {
context : {
userId : userData.id
// userStatus : userData.status
}
};
} catch (e) {
return chista.renderPromiseAsJson(req, res, promise);
}
}
};