pangea-server 1.0.42 → 1.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -11,15 +11,15 @@ const authentication_1 = require("../authentication");
|
|
|
11
11
|
// validator
|
|
12
12
|
const validate_request_1 = require("../validator/validate-request");
|
|
13
13
|
function callController(controller, validate, authConfig) {
|
|
14
|
+
const { authMap, authCtor, accessToken } = authConfig;
|
|
14
15
|
return async function (req, res) {
|
|
16
|
+
const headers = req.headers;
|
|
15
17
|
const inputs = (0, validate_request_1.validateRequest)(validate, req);
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const ctx = { headers, file: req.file, files: req.files, ...inputs };
|
|
18
|
+
const businessId = headers['x-business'] ? Number(headers['x-business']) : undefined;
|
|
19
|
+
const ctx = { headers, ...inputs, file: req.file, files: req.files, businessId };
|
|
19
20
|
const tx = await (0, database_1.getDbClient)().transaction();
|
|
20
21
|
const db = new database_1.Db(tx);
|
|
21
22
|
try {
|
|
22
|
-
const { authMap, authCtor, accessToken } = authConfig;
|
|
23
23
|
const authUsers = await (0, authentication_1.getUsersFromToken)(headers.authorization, db, accessToken, authMap);
|
|
24
24
|
const auth = new authCtor(authUsers);
|
|
25
25
|
const result = await controller(ctx, db, auth);
|
|
@@ -8,7 +8,6 @@ declare global {
|
|
|
8
8
|
type Next = NextFunction;
|
|
9
9
|
type ReqHeaders = Record<string, string | undefined> & {
|
|
10
10
|
'x-language': string;
|
|
11
|
-
'x-business'?: ModelId;
|
|
12
11
|
};
|
|
13
12
|
interface Ctx<V extends RouteValidator> {
|
|
14
13
|
headers: ReqHeaders;
|
|
@@ -17,6 +16,7 @@ declare global {
|
|
|
17
16
|
body: V['body'];
|
|
18
17
|
file?: MulterFile;
|
|
19
18
|
files?: MulterFile[];
|
|
19
|
+
businessId?: ModelId;
|
|
20
20
|
}
|
|
21
21
|
type MulterFile = Express.Multer.File;
|
|
22
22
|
type UploadableImage = string | MulterFile;
|