-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC v1-using factory 2.js
43 lines (35 loc) · 1.23 KB
/
C v1-using factory 2.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { factoryControllerA } from './B v1-factory';
import { factoryControllerB } from './B v1-factory';
import dep1 from '../xx/xx/'
import dep2 from '../xx/xx/'
const controllerA = factoryControllerA(dep2(dep1, {
configParam: true,
}));
const controllerB = factoryControllerB(dep2(dep1, {
configParam: false,
}));
// se o numero de controllers aumentam aqui... bom, ja vira uma bagunca
function handlerA(event, context, callback) {
if (isProtected() && event.headers.authorization) {
return callback(null, JSON.stringify({
message: 'You are not authorized! Please refresh your credentials'
}))
}
const response = controllerA(event, context);
return callback(null, JSON.stringify({
message: 'You are authorized',
payload: response
}));
}
function handl erB(event, context, callback) {
if (isProtected() && event.headers.authorization) {
return callback(null, JSON.stringify({
message: 'You are not authorized! Please refresh your credentials'
}))
}
const response = controllerB(event, context);
return callback(null, JSON.stringify({
message: 'You are authorized',
payload: response
}));
}