Hi, I'm looking to use session recipe or email pas...
# share-your-work
b
Hi, I'm looking to use session recipe or email password recipe with nestjs and prisma, - for email, password, there are already default middleware routes, since I'm setting up a swagger doc and I want to be able to manage/see the schema in prisma studio as well, I can't see the auth endpoints in swagger and there isn't a model for prisma as well, do you have any suggestion/guide/sample_code ? - for session recipe, I'm thinking if the above is complicated to do I'll use only the session recipe but when I tried
createSession(res,userId)
as per the doc userId is from db, would I be able to intergrate a table with prisma for this function ?
r
I can't see the auth endpoints in swagger https://app.swaggerhub.com/apis/supertokens/FDI -> there is an emailpassword section there isn't a model for prisma as well https://supertokens.com/docs/emailpassword/quick-setup/database-setup/mysql
> would I be able to intergrate a table with prisma for this function ? What do you mean? So you do not need to bother with integrating supertokens with prisma cause the core already talks to the db for you.
b
basically, I want to try out if I'm able to just call the function to create session and passing my own userId instead of having using supertokens user's schema.
r
you can pass your own user ID.. yea
b
if I passed my own user Id, how does the function check the database ? do I need to create it with a specific table_name ?
r
you don't. It allows you to pass any user ID
since the session recipe is made in an indepedant way
b
I've tried the bellow code according the doc https://supertokens.com/docs/session/common-customizations/sessions/new-session#how-to-create-a-new-session, but the request was always loading.
Copy code
js
@Post('login')
  async postLogin(@Res() res: Response): Promise<{ message: string }> {
    const userId = 'xxx-xxx-xxx'

    await createNewSession(res, userId)

    return { message: 'User logged in!' }
  }
r
What do you mean by always loading? Did createNewSession function throw an exception?
b
it didn't throw an exception, the api was just loading forever without response
r
so the
createNewSession
function does not return?
b
seem like it's related to the @Res, in nestjs if the response object is passed to the handler we need to handle the response ourselves
r
hmm. So instead of return {..}, you have to send the response using res.something(...)?
b
yes
r
ah right
3 Views