fix compile errors

This commit is contained in:
Nawaz Dhandala 2022-04-22 15:33:21 +01:00
parent f08cbf0568
commit 9269606c76
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
2 changed files with 17 additions and 14 deletions

View File

@ -7,6 +7,7 @@ import {
import { sendErrorResponse } from '../Utils/Response';
import BadDataException from 'Common/Types/Exception/BadDataException';
import ObjectID from 'Common/Types/ObjectID';
export default class ClusterKeyAuthorization {
public static async isAuthorizedService(
@ -14,22 +15,17 @@ export default class ClusterKeyAuthorization {
res: ExpressResponse,
next: NextFunction
): Promise<void> {
let clusterKey: string;
let clusterKey: ObjectID;
if (req.params && req.params['clusterKey']) {
clusterKey = req.params['clusterKey'];
clusterKey = new ObjectID(req.params['clusterKey']);
} else if (req.query && req.query['clusterKey']) {
clusterKey = req.query['clusterKey'] as string;
} else if (
req.headers &&
(req.headers['clusterkey'] || req.headers['clusterkey'])
) {
clusterKey = new ObjectID(req.query['clusterKey'] as string);
} else if (req.headers && req.headers['clusterkey']) {
// Header keys are automatically transformed to lowercase
clusterKey =
(req.headers['clusterkey'] as string) ||
(req.headers['clusterkey'] as string);
clusterKey = new ObjectID(req.headers['clusterkey'] as string);
} else if (req.body && req.body.clusterKey) {
clusterKey = req.body.clusterKey;
clusterKey = new ObjectID(req.body.clusterKey);
} else {
return sendErrorResponse(
req,

View File

@ -137,8 +137,11 @@ export default class MailService {
// Localcache templates, so we dont read from disk all the time.
let templateData: string;
if (LocalCache.hasValue(emailTemplateType)) {
templateData = LocalCache.get(emailTemplateType);
if (LocalCache.hasValue('email-templates', emailTemplateType)) {
templateData = LocalCache.get(
'email-templates',
emailTemplateType
) as string;
} else {
templateData = await fsp.readFile(
Path.resolve(
@ -148,7 +151,11 @@ export default class MailService {
),
{ encoding: 'utf8', flag: 'r' }
);
LocalCache.set(emailTemplateType, templateData);
LocalCache.set(
'email-templates',
emailTemplateType,
templateData as string
);
}
const emailBody: Handlebars.TemplateDelegate =