Modrinth OAuth support

This commit is contained in:
oitsjustjose 2024-12-31 16:19:05 -06:00
commit 52e28067d8
10 changed files with 125 additions and 66 deletions

View file

@ -16,7 +16,7 @@ const getNextQueuePlace = async () => {
export default async (req: Request, res: Response) => {
try {
if (
!req.body.githubPat ||
!req.body.oauthToken ||
!req.body.curseforgeSlug ||
!req.body.modrinthId
) {
@ -25,7 +25,7 @@ export default async (req: Request, res: Response) => {
.send(
[
"Missing a required parameter in the JSON body",
"Required params: githubPat: string, curseforgeSlug: string, modrinthId: string",
"Required params: oauthToken: string, curseforgeSlug: string, modrinthId: string",
].join(" ")
);
}
@ -33,7 +33,7 @@ export default async (req: Request, res: Response) => {
const fern = new Fernet(process.env.SECRET);
const newJob = new Job({
githubPat: fern.encrypt(req.body.githubPat),
oauthToken: fern.encrypt(req.body.oauthToken),
curseforgeSlug: req.body.curseforgeSlug,
modrinthId: req.body.modrinthId,
queuePlace: await getNextQueuePlace(),

View file

@ -4,7 +4,7 @@ import Status from "../status";
export type JobType = Document & {
jobId: string;
githubPat: string;
oauthToken: string;
curseforgeSlug: string;
modrinthId: string;
logs: string;
@ -18,7 +18,7 @@ const JobSchema = new Schema<JobType>({
default: shortid.generate,
required: true,
},
githubPat: {
oauthToken: {
type: String,
required: true,
},