Skip to content

Commit

Permalink
style(src): 🎨 Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Nudelsuppe42 committed Aug 10, 2024
1 parent 0f93b00 commit 63b1f2e
Show file tree
Hide file tree
Showing 23 changed files with 268 additions and 272 deletions.
14 changes: 7 additions & 7 deletions src/Core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Core {
this,
process.env.DISCORD_WEBHOOK_URL,
process.env.DISCORD_BOT_URL,
process.env.DISCORD_BOT_SECRET
process.env.DISCORD_BOT_SECRET,
);
this.keycloak = new Keycloak(
{
Expand All @@ -48,7 +48,7 @@ class Core {
"ssl-required": "external",
resource: process.env.KEYCLOAK_CLIENTID,
"confidential-port": 0,
}
},
);
this.keycloakAdmin = new KeycloakAdmin(this);
this.keycloakAdmin.authKcClient().then(() => {
Expand Down Expand Up @@ -99,7 +99,7 @@ class Core {
level: process.env.LOGLEVEL,
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
winston.format.json(),
),
transports: [
new winston.transports.File({
Expand All @@ -114,17 +114,17 @@ class Core {
const consoleFormat = winston.format.printf(
({ level, message, timestamp }) => {
return `${timestamp} | ${level} » ${message}`;
}
},
);

logger.add(
new winston.transports.Console({
format: winston.format.combine(
winston.format.colorize(),
winston.format.simple(),
consoleFormat
consoleFormat,
),
})
}),
);
}
logger.info(
Expand All @@ -145,7 +145,7 @@ class Core {
"@&.,,,,,,,,,,,,,,,, ,,,,,,,,.&\n" +
"@&&&.,,,,,,,,,,,,,, ,,,,...&&&\n" +
"@&&&&&&.////..,,.. ,,,..&&&&&&\n" +
"[0m"
"[0m",
);

this.logger = logger;
Expand Down
14 changes: 7 additions & 7 deletions src/controllers/AdminController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AdminController {
running: job.running,
cronTime: job.cronTime.source,
};
})
}),
);
}

Expand All @@ -58,7 +58,7 @@ class AdminController {
req,
res,
409,
"Recalculations are already ongoing."
"Recalculations are already ongoing.",
);
}

Expand Down Expand Up @@ -99,7 +99,7 @@ class AdminController {
req,
res,
409,
"Recalculations are already ongoing."
"Recalculations are already ongoing.",
);
}

Expand Down Expand Up @@ -145,7 +145,7 @@ class AdminController {
req,
res,
409,
"Recalculations are already ongoing."
"Recalculations are already ongoing.",
);
}

Expand Down Expand Up @@ -193,8 +193,8 @@ class AdminController {

const hashes = await Promise.all(
images.map((image) =>
getHash(`https://cdn.buildtheearth.net/uploads/${image.name}`)
)
getHash(`https://cdn.buildtheearth.net/uploads/${image.name}`),
),
);

for (const [i, image] of images.entries()) {
Expand All @@ -217,7 +217,7 @@ class AdminController {
async function getHash(src: string) {
try {
const buffer = await fetch(src).then(async (res) =>
Buffer.from(await res.arrayBuffer())
Buffer.from(await res.arrayBuffer()),
);

const { base64 } = await getPlaiceholder(buffer);
Expand Down
50 changes: 25 additions & 25 deletions src/controllers/ApplicationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class ApplicationController {
applications = applications.filter(
(a) =>
a.status == ApplicationStatus.REVIEWING ||
a.status == ApplicationStatus.SEND
a.status == ApplicationStatus.SEND,
);
}

Expand All @@ -97,7 +97,7 @@ class ApplicationController {
this.core.getPrisma(),
req.kauth.grant.access_token.content.sub,
["team.application.list"],
req.query.id as string
req.query.id as string,
)
) {
res.send(applications);
Expand Down Expand Up @@ -234,10 +234,10 @@ class ApplicationController {
application.buildteam.acceptionMessage,
application,
user,
application.buildteam
application.buildteam,
),
[user.discordId],
(e) => ERROR_GENERIC(req, res, 500, e)
(e) => ERROR_GENERIC(req, res, 500, e),
);

// Update builder role on discord
Expand All @@ -256,10 +256,10 @@ class ApplicationController {
application.buildteam.trialMessage,
application,
user,
application.buildteam
application.buildteam,
),
[user.discordId],
(e) => ERROR_GENERIC(req, res, 500, e)
(e) => ERROR_GENERIC(req, res, 500, e),
);
} else {
// Remove user from team (-> application was reviewed again)
Expand All @@ -284,18 +284,18 @@ class ApplicationController {
application.buildteam.rejectionMessage,
application,
user,
application.buildteam
application.buildteam,
),
[user.discordId],
(e) => ERROR_GENERIC(req, res, 500, e)
(e) => ERROR_GENERIC(req, res, 500, e),
);

// Remove builder role if user isnt in any team
if (user._count.joinedBuildTeams < 1) {
await this.core
.getDiscord()
.updateBuilderRole(user.discordId, false, (e) =>
ERROR_GENERIC(req, res, 500, e)
ERROR_GENERIC(req, res, 500, e),
);
}
}
Expand All @@ -309,7 +309,7 @@ class ApplicationController {
this.core,
application.buildteam.webhook,
WebhookType.APPLICATION,
application
application,
);
}

Expand All @@ -334,7 +334,7 @@ class ApplicationController {
req,
res,
428,
"Please join the BuildTheEarth.net Discord Server"
"Please join the BuildTheEarth.net Discord Server",
);
return;
}
Expand Down Expand Up @@ -372,21 +372,21 @@ class ApplicationController {
req,
res,
409,
"You are already a builder of this BuildTeam."
"You are already a builder of this BuildTeam.",
);
} else if (
// User already applied, waiting for review
pastApplications.some(
(a) =>
a.status == ApplicationStatus.REVIEWING ||
a.status == ApplicationStatus.SEND
a.status == ApplicationStatus.SEND,
)
) {
return ERROR_GENERIC(
req,
res,
409,
"You already have an pending application for this BuildTeam."
"You already have an pending application for this BuildTeam.",
);
}

Expand All @@ -396,7 +396,7 @@ class ApplicationController {
req,
res,
403,
"BuildTeam has disabled applications."
"BuildTeam has disabled applications.",
);
}

Expand All @@ -421,10 +421,10 @@ class ApplicationController {
buildteam.acceptionMessage,
application,
req.user,
buildteam
buildteam,
),
[req.user.discordId],
(e) => ERROR_GENERIC(req, res, 500, e)
(e) => ERROR_GENERIC(req, res, 500, e),
);
}

Expand Down Expand Up @@ -455,7 +455,7 @@ class ApplicationController {
req,
res,
400,
"Minecraft username is not equal to verified username on profile."
"Minecraft username is not equal to verified username on profile.",
);
}
} else {
Expand All @@ -469,7 +469,7 @@ class ApplicationController {
minecraft: answer,
minecraftVerified: false,
},
}
},
);
req.kcUser = {
...req.kcUser,
Expand All @@ -485,7 +485,7 @@ class ApplicationController {
req,
res,
400,
"Required Questions are missing."
"Required Questions are missing.",
);
}
}
Expand Down Expand Up @@ -529,7 +529,7 @@ class ApplicationController {
await this.core.getDiscord().sendBotMessage(
`**${buildteam.name}** \\nNew Application from <@${req.user.discordId}> (${req.kcUser.username}). Review it [here](${process.env.FRONTEND_URL}/teams/${buildteam.slug}/manage/review/${application.id})`,
reviewers.map((r) => r.user.discordId),
(e) => ERROR_GENERIC(req, res, 500, e)
(e) => ERROR_GENERIC(req, res, 500, e),
);

// Send Webhook to BuildTeam
Expand All @@ -538,7 +538,7 @@ class ApplicationController {
this.core,
application.buildteam.webhook,
WebhookType.APPLICATION_SEND,
application
application,
);
}

Expand All @@ -563,7 +563,7 @@ class ApplicationController {
message: string,
application: Application,
user: { discordId: string },
team: { slug: string; name: string }
team: { slug: string; name: string },
): string {
return message
.replace("{user}", `<@${user.discordId}>`)
Expand All @@ -576,15 +576,15 @@ class ApplicationController {
year: "numeric",
month: "numeric",
day: "numeric",
})
}),
)
.replace(
"{createdAt}",
new Date(application.createdAt).toLocaleDateString("en-GB", {
year: "numeric",
month: "numeric",
day: "numeric",
})
}),
)
.replace("{id}", application.id.toString().split("-")[0]);
}
Expand Down
18 changes: 9 additions & 9 deletions src/controllers/BuildTeamController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class BuildTeamController {
},
});
res.send(
buildteams.map((b) => ({ ...b, token: undefined, webhook: undefined }))
buildteams.map((b) => ({ ...b, token: undefined, webhook: undefined })),
);
}

Expand Down Expand Up @@ -137,7 +137,7 @@ class BuildTeamController {
*/
public async updateBuildTeamApplicationQuestions(
req: Request,
res: Response
res: Response,
) {
const errors = validationResult(req);
if (!errors.isEmpty()) {
Expand All @@ -164,7 +164,7 @@ class BuildTeamController {
icon: yup.string(),
sort: yup.number(),
type: yup.mixed().oneOf(Object.keys(ApplicationQuestionType)),
})
}),
);

schema
Expand Down Expand Up @@ -244,7 +244,7 @@ class BuildTeamController {
name: yup.string(),
icon: yup.string(),
url: yup.string(),
})
}),
);

schema
Expand Down Expand Up @@ -423,13 +423,13 @@ class BuildTeamController {
emailVerified: kcMember?.emailVerified,
avatar: member.avatar,
};
})
}),
);

res.send(
req.query.page
? { pages: Math.ceil(count / 100), data: kcMembers }
: kcMembers
: kcMembers,
);
}

Expand Down Expand Up @@ -508,7 +508,7 @@ class BuildTeamController {
emailVerified: kcMember?.emailVerified || false,
permissions: member.permissions,
};
})
}),
);
res.send(kcMembers);
}
Expand Down Expand Up @@ -626,7 +626,7 @@ class BuildTeamController {
req,
res,
403,
"You are not the Creator of this BuildTeam."
"You are not the Creator of this BuildTeam.",
);
}
const token = crypto.randomBytes(21).toString("hex");
Expand All @@ -641,7 +641,7 @@ class BuildTeamController {
.getDiscord()
.sendBotMessage(
`**${buildteam.name}** \\nGenerated new API Token: ||${token}|| \\nPlease save it somewhere secure.`,
[buildteam.creator.discordId]
[buildteam.creator.discordId],
);

res.send({ message: "Token generated, check your Discord DMs" });
Expand Down
Loading

0 comments on commit 63b1f2e

Please sign in to comment.