fix: typescript sux
This commit is contained in:
parent
cc100d632c
commit
cd04773504
@ -1,13 +1,13 @@
|
||||
// SHUT THE FUCK UP
|
||||
// deno-lint-ignore-file no-explicit-any
|
||||
import JWT from "../../utils/JWT.ts";
|
||||
import HttpError from "../HttpError.ts";
|
||||
import Router, { makeParameterModifier } from "../Router.ts";
|
||||
|
||||
// SHUT THE FUCK UP
|
||||
// deno-lint-ignore no-explicit-any
|
||||
export default function jwt<T extends Router = any>(salt: ((self: T) => string) | keyof T, required = false) {
|
||||
export default function jwt<T extends Router = any>(salt: ((self: T) => string) | string, required = false) {
|
||||
return makeParameterModifier<T>(function (_req, val?: string) {
|
||||
if (val === undefined) return undefined;
|
||||
const s = typeof salt === 'function' ? salt(this) : this[salt] as string;
|
||||
const s = typeof salt === 'function' ? salt(this) : (this as any)[salt] as string;
|
||||
try {
|
||||
const res = JWT.decode(val, s);
|
||||
if (required && res === undefined) throw new HttpError('You are not logged in.');
|
||||
|
Loading…
Reference in New Issue
Block a user