Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
AydanPirani committed May 26, 2024
1 parent 89595e4 commit dd13539
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
10 changes: 5 additions & 5 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export const Config = {
// AUTH_CALLBACK_URI_BASE: "http://localhost:3000/auth/callback/",
AUTH_CALLBACK_URI_BASE:
"https://api.reflectionsprojections.org/auth/callback/",

AUTH_ADMIN_WHITELIST: new Set([
"[email protected]", // Aydan Pirani (Dev)
"[email protected]", // Divya Koya (Dev)
"[email protected]", // Ritika Vithani (Director)
"[email protected]", // Ojaswee Chaudhary (Director)
"[email protected]", // Aydan Pirani (Dev)
"[email protected]", // Divya Koya (Dev)
"[email protected]", // Ritika Vithani (Director)
"[email protected]", // Ojaswee Chaudhary (Director)
]),

JWT_SIGNING_SECRET: getEnv("JWT_SIGNING_SECRET"),
Expand Down
2 changes: 1 addition & 1 deletion src/services/auth/auth-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function createGoogleStrategy(device: string) {
const userId = `user${profile.id}`;
const name = profile.displayName;
const email = profile._json.email;

let roles = [];

Check failure on line 21 in src/services/auth/auth-utils.ts

View workflow job for this annotation

GitHub Actions / lint

'roles' is never reassigned. Use 'const' instead

Check failure on line 21 in src/services/auth/auth-utils.ts

View workflow job for this annotation

GitHub Actions / lint

'roles' is never reassigned. Use 'const' instead

if (Config.AUTH_ADMIN_WHITELIST.has(email ?? "")) {
Expand Down
50 changes: 35 additions & 15 deletions src/services/mail/templates/templates-subrouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import { Role } from "../../auth/auth-models";
import { Database } from "../../../database";
import { StatusCodes } from "http-status-codes";
import { TemplateValidator } from "./templates-schema";
import { z } from "zod";
import { Config } from "../../../config";

type TemplateData = z.infer<typeof TemplateValidator>;

const templatesSubRouter = Router();

templatesSubRouter.get(
Expand All @@ -27,10 +24,18 @@ templatesSubRouter.post(
async (req, res) => {
try {
let templateData = TemplateValidator.parse(req.body);

Check failure on line 26 in src/services/mail/templates/templates-subrouter.ts

View workflow job for this annotation

GitHub Actions / lint

'templateData' is never reassigned. Use 'const' instead

Check failure on line 26 in src/services/mail/templates/templates-subrouter.ts

View workflow job for this annotation

GitHub Actions / lint

'templateData' is never reassigned. Use 'const' instead
let substitutions = templateData.content.matchAll(Config.MAIL_TEMPLATE_REGEX)
const subVars = Array.from(substitutions, substitutions => substitutions[1]);
let substitutions = templateData.content.matchAll(

Check failure on line 27 in src/services/mail/templates/templates-subrouter.ts

View workflow job for this annotation

GitHub Actions / lint

'substitutions' is never reassigned. Use 'const' instead

Check failure on line 27 in src/services/mail/templates/templates-subrouter.ts

View workflow job for this annotation

GitHub Actions / lint

'substitutions' is never reassigned. Use 'const' instead
Config.MAIL_TEMPLATE_REGEX
);
const subVars = Array.from(
substitutions,
(substitutions) => substitutions[1]
);

await Database.TEMPLATES.create({...templateData, substitutions: subVars});
await Database.TEMPLATES.create({
...templateData,
substitutions: subVars,
});
return res.sendStatus(StatusCodes.CREATED);
} catch (error) {
return res.status(StatusCodes.BAD_REQUEST).send(error);
Expand All @@ -44,13 +49,23 @@ templatesSubRouter.put(
async (req, res) => {
try {
let templateData = TemplateValidator.parse(req.body);

Check failure on line 51 in src/services/mail/templates/templates-subrouter.ts

View workflow job for this annotation

GitHub Actions / lint

'templateData' is never reassigned. Use 'const' instead

Check failure on line 51 in src/services/mail/templates/templates-subrouter.ts

View workflow job for this annotation

GitHub Actions / lint

'templateData' is never reassigned. Use 'const' instead
let substitutions = templateData.content.matchAll(Config.MAIL_TEMPLATE_REGEX)
const subVars = Array.from(substitutions, substitutions => substitutions[1]);
let substitutions = templateData.content.matchAll(

Check failure on line 52 in src/services/mail/templates/templates-subrouter.ts

View workflow job for this annotation

GitHub Actions / lint

'substitutions' is never reassigned. Use 'const' instead

Check failure on line 52 in src/services/mail/templates/templates-subrouter.ts

View workflow job for this annotation

GitHub Actions / lint

'substitutions' is never reassigned. Use 'const' instead
Config.MAIL_TEMPLATE_REGEX
);
const subVars = Array.from(
substitutions,
(substitutions) => substitutions[1]
);

const updateResult = await Database.TEMPLATES.findOneAndUpdate(
{ templateId: templateData.templateId },
{ ...templateData, substitutions: subVars }
);

const updateResult = await Database.TEMPLATES.findOneAndUpdate({templateId: templateData.templateId}, {...templateData, substitutions: subVars});

if (!updateResult) {
return res.status(StatusCodes.NOT_FOUND).send({error: "NoSuchId"});
return res
.status(StatusCodes.NOT_FOUND)
.send({ error: "NoSuchId" });
}

return res.sendStatus(StatusCodes.OK);
Expand All @@ -65,9 +80,13 @@ templatesSubRouter.get(
RoleChecker([Role.Values.STAFF]),
async (req, res) => {
const templateId = req.params.TEMPLATEID;
const templateInfo = await Database.TEMPLATES.findOne({templateId: templateId});
const templateInfo = await Database.TEMPLATES.findOne({
templateId: templateId,
});
if (!templateInfo) {
return res.status(StatusCodes.NOT_FOUND).send({error: "NoSuchId"});
return res
.status(StatusCodes.NOT_FOUND)
.send({ error: "NoSuchId" });
}
return res.status(StatusCodes.OK).json(templateInfo?.toObject());
}
Expand All @@ -79,9 +98,10 @@ templatesSubRouter.delete(
async (req, res) => {
try {
const templateId = req.params.TEMPLATEID;
await Database.TEMPLATES.findOneAndDelete({templateId: templateId});
await Database.TEMPLATES.findOneAndDelete({
templateId: templateId,
});
return res.sendStatus(StatusCodes.NO_CONTENT);

} catch (error) {
return res.status(StatusCodes.BAD_REQUEST).send(error);
}
Expand Down

0 comments on commit dd13539

Please sign in to comment.