Skip to content

Commit

Permalink
Fixed lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
f2reninj5 committed Jul 2, 2024
1 parent 86f74d1 commit deda382
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
18 changes: 11 additions & 7 deletions server/src/routes/qr_codes/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Router as ExpressRouter } from "express"

import handlers from "./qr_code_handlers"
import QRHandlers from "./qr_code_handlers"
import { handleFailedAuthentication, handleMethodNotAllowed, parseRouteId } from "@server/common/middleware"

const qr_codes_router = ExpressRouter()
const handlers = new QRHandlers()

qr_codes_router
.route("/")
.get(handlers.getQRCodeList, handleFailedAuthentication)
.post(handlers.createQRCode, handleFailedAuthentication)
.get(handlers.getQRCodeList.bind(handlers), handleFailedAuthentication)
.post(handlers.createQRCode.bind(handlers), handleFailedAuthentication)
.all(handleMethodNotAllowed)

qr_codes_router
Expand All @@ -20,7 +20,7 @@ qr_codes_router
qr_codes_router
.route("/presets/:preset_id")
.get(handlers.getPresetDetails, handleFailedAuthentication)
.post(handlers.usePreset, handleFailedAuthentication)
.post(handlers.usePreset.bind(handlers), handleFailedAuthentication)
.delete(handlers.deletePreset, handleFailedAuthentication)
.all(handleMethodNotAllowed)

Expand All @@ -33,15 +33,19 @@ qr_codes_router

qr_codes_router
.route("/challenges")
.get(handlers.getChallengeListAdmin, handlers.getChallengeListAsAnonymous, handleFailedAuthentication)
.get(
handlers.getChallengeListAdmin.bind(handlers),
handlers.getChallengeListAsAnonymous.bind(handlers),
handleFailedAuthentication,
)
.post(handlers.createChallenge, handleFailedAuthentication)
.all(handleMethodNotAllowed)

qr_codes_router
.route("/:qr_code_id")
.all(parseRouteId("qr_code_id"))
.get(handlers.getQRCodeDetails, handleFailedAuthentication)
.patch(handlers.patchQRCodeDetails, handleFailedAuthentication)
.patch(handlers.patchQRCodeDetails.bind(handlers), handleFailedAuthentication)
.delete(handlers.deleteQRCode, handleFailedAuthentication)
.all(handleMethodNotAllowed)

Expand Down
5 changes: 1 addition & 4 deletions server/src/routes/qr_codes/qr_code_handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const presets = new Map<string, z.infer<typeof qr_preset_schema>>(

const patch_fields = new Set(["state", "publicised"])

class QRHandlers {
export default class QRHandlers {
constructor() {
Object.getOwnPropertyNames(QRHandlers.prototype).forEach(key => {
if (key !== "constructor") {
Expand Down Expand Up @@ -372,6 +372,3 @@ class QRHandlers {
throw new createHttpError.NotImplemented()
}
}

const handlersInstance = new QRHandlers()
export default handlersInstance

0 comments on commit deda382

Please sign in to comment.