🎨 Run updated prettier

This commit is contained in:
2023-08-25 14:42:38 +02:00
parent 57807e7ce0
commit 70238b4151
19 changed files with 77 additions and 71 deletions

View File

@ -30,7 +30,7 @@ async function listTimetables(_, res) {
source: true,
trusted: true,
},
})
}),
);
}

View File

@ -140,16 +140,19 @@ export default {
};
// Clean up expired sessions every hour
setInterval(async () => {
const sessions = await prisma.session.findMany();
for (const session of sessions) {
if (session.validUntil < new Date()) {
log("API / Auth", `Removed expired session: ${session.token}`);
await prisma.session.delete({
where: {
token: session.token,
},
});
setInterval(
async () => {
const sessions = await prisma.session.findMany();
for (const session of sessions) {
if (session.validUntil < new Date()) {
log("API / Auth", `Removed expired session: ${session.token}`);
await prisma.session.delete({
where: {
token: session.token,
},
});
}
}
}
}, 1000 * 60 * 60);
},
1000 * 60 * 60,
);

View File

@ -87,21 +87,24 @@ export async function revokeKey(sessionToken, key) {
}
// Clean up expired keys every hour
setInterval(async () => {
const keys = await prisma.key.findMany();
for (const key of keys) {
if (key.validUntil && key.validUntil < new Date()) {
log(
"API / Permissions",
`Removed expired key: ${key.key}; Permissions: ${key.permissions.join(
", "
)}`
);
await prisma.key.delete({
where: {
key: key.key,
},
});
setInterval(
async () => {
const keys = await prisma.key.findMany();
for (const key of keys) {
if (key.validUntil && key.validUntil < new Date()) {
log(
"API / Permissions",
`Removed expired key: ${key.key}; Permissions: ${key.permissions.join(
", ",
)}`,
);
await prisma.key.delete({
where: {
key: key.key,
},
});
}
}
}
}, 1000 * 60 * 60);
},
1000 * 60 * 60,
);

View File

@ -44,10 +44,10 @@ new Parser(
new BolleClient(
process.env.BOLLE_URL,
process.env.BOLLE_USER,
process.env.BOLLE_KEY
process.env.BOLLE_KEY,
),
parseSubstitutionPlan,
process.env.UPDATE_INTERVAL || 1 * 60 * 1000 // Default to 1 minute
process.env.UPDATE_INTERVAL || 1 * 60 * 1000, // Default to 1 minute
);
// Create new Auth class to store sessions

View File

@ -5,7 +5,7 @@ const baseUrl = "https://mobileapi.dsbcontrol.de";
export async function getAuthtoken(username, password) {
const response = await axios.get(
`${baseUrl}/authid?user=${username}&password=${password}&bundleid&appversion&osversion&pushid`
`${baseUrl}/authid?user=${username}&password=${password}&bundleid&appversion&osversion&pushid`,
);
if (response.data == "") throw "Wrong DSB username or password";
return response.data;
@ -13,7 +13,7 @@ export async function getAuthtoken(username, password) {
export async function getTimetables(authtoken) {
const response = await axios.get(
`${baseUrl}/dsbtimetables?authid=${authtoken}`
`${baseUrl}/dsbtimetables?authid=${authtoken}`,
);
const timetables = response.data;

View File

@ -105,7 +105,7 @@ export class Parser {
substitution.class.sort().join(",") &&
substitution.changedSubject == change.subject &&
substitution.teacher == (change.teacher || "");
}
},
);
const matchingSubstitution = knownSubstitutions[matchingSubstitutionId];
@ -148,7 +148,7 @@ export class Parser {
});
log(
"Insert / DB",
`Created new substitution: S:${newSubstitution.id} C:${substitutionChange.id}`
`Created new substitution: S:${newSubstitution.id} C:${substitutionChange.id}`,
);
} else {
// If the entry was updated, find the differences
@ -178,7 +178,7 @@ export class Parser {
});
log(
"Insert / DB",
`Found changed substitution: S:${matchingSubstitution.id} C:${substitutionChange.id}`
`Found changed substitution: S:${matchingSubstitution.id} C:${substitutionChange.id}`,
);
}
// Remove the substitution from the array to later know the
@ -219,7 +219,7 @@ export class Parser {
});
log(
"Insert / DB",
`Deleted removed substitution: S:${remainingSubstitution.id} C:${substitutionChange.id}`
`Deleted removed substitution: S:${remainingSubstitution.id} C:${substitutionChange.id}`,
);
}
}