From fa784ef69bb4a12b94545e9634a0367177a182eb Mon Sep 17 00:00:00 2001 From: ruslan zapevalov Date: Wed, 25 Oct 2023 15:51:13 +0400 Subject: [PATCH] fix comments --- src/controllers/token.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/controllers/token.ts b/src/controllers/token.ts index c2e3b16..b6b033e 100644 --- a/src/controllers/token.ts +++ b/src/controllers/token.ts @@ -37,24 +37,21 @@ export default class TokenController { @Ctx() ctx: Context ) { const { token } = body + if (!token) return ctx.throw(badRequest('No token')) const existingToken = await TokenModel.findOne({ token }) if (existingToken) { existingToken.waitlist = true await existingToken.save() return { success: true } } - if (!token) return ctx.throw(badRequest('No token')) const newToken = new TokenModel({ token, waitlist: true }) await newToken.save() return { success: true } } @Put('/waitlist/:token') - async markAsReceived( - @Params('token') notificationToken: string, - @Ctx() ctx: Context - ) { - const tokenDoc = await TokenModel.findOne({ token: notificationToken }) + async markAsReceived(@Params('token') token: string, @Ctx() ctx: Context) { + const tokenDoc = await TokenModel.findOne({ token }) if (!tokenDoc) return ctx.throw(badRequest('Token not found')) tokenDoc.waitlist = undefined await tokenDoc.save()