finishing auth controller verification
This commit is contained in:
13
src/helpers/http/userHeader/cookies/getCookies.ts
Normal file
13
src/helpers/http/userHeader/cookies/getCookies.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { parse } from "cookie";
|
||||
import { Context } from "elysia";
|
||||
import { AppError } from "../../../error/instances/app";
|
||||
|
||||
export const getCookie = (ctx: Context) => {
|
||||
try {
|
||||
const cookiePayload = ctx.request.headers.get("Cookie");
|
||||
const cookies = parse(cookiePayload!);
|
||||
return cookies;
|
||||
} catch (error) {
|
||||
throw new AppError(401, "Cookie not found");
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user