You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
why is the uuid static? I don't get how to apply this to a real app
This is the same but using drizzle instead, where are you supposed to get the id from?
importoauth2,{github}from"@bogeychan/elysia-oauth2";import{randomBytes}from"crypto";import{and,eq}from"drizzle-orm";import{Elysia}from"elysia";import{db}from"./db";import{storage}from"./db/schema";conststates=newSet();constauth=oauth2({profiles: {github: {provider: github(),scope: ["user"],},},state: {generate(req,name){console.log("generate name",name);conststate=randomBytes(8).toString("hex");// ???states.add(state);returnstate;},check(req,name,state){console.log("check state",name,state);if(states.has(state)){states.delete(state);returntrue;}returnfalse;},},storage: {asyncget(req,name){console.log(`get token: ${name}`);consttoken=db.select().from(storage).where(and(eq(storage.name,name),eq(storage.id,id)));// -> where do I pull this ID from?if(!token){return;}returnJSON.parse(token);},asyncset(req,name,token){console.log(`new token: ${name}`);db.insert(storage).values({
id,// -> where do I pull this ID from?
name,token: JSON.stringify(token),}).onConflictDoUpdate({set: {token: JSON.stringify(token),},target: storage.id,});},asyncdelete(req,name){console.log(`delete token: ${name}`);db.delete(storage).where(and(eq(storage.name,name),eq(storage.id,id))// -> where do I pull this ID from?);},},});newElysia().use(auth).group("/auth",(authRouter)=>{returnauthRouter.get("/protected",({ headers })=>{return{foo: "bar"};});}).listen(3000);
The text was updated successfully, but these errors were encountered:
source
why is the uuid static? I don't get how to apply this to a real app
This is the same but using drizzle instead, where are you supposed to get the id from?
The text was updated successfully, but these errors were encountered: