In the docs, it's written that you should write in the adpter the following code:
await mongoose.connect();
and this throws an error Error: await is not defined.
I tried to make a function called getAdapter() like this:
async function getAdpater() {
await mongoose.connect(uri);
const User = mongoose.model("User", userSchema);
const Session = mongoose.model("Session", sessionSchema);
return new MongodbAdapter(
mongoose.connection.collection("sessions"),
mongoose.connection.collection("users")
);
}
export { getAdpater };
and in lucia.ts file:
export const lucia = new Lucia(await getAdpater(), {
sessionCookie: {
attributes: {
// set to `true` when using HTTPS
secure: process.env.NODE_ENV === "production",
},
},
});
but this don't work, so I recommend making lucia gets a function that returns an adapter or something like that (new Lucia(async () => await getAdapter())), i don't know actually...
Package
lucia
Describe the bug
In the docs, it's written that you should write in the adpter the following code:
and this throws an error
Error: await is not defined
.I tried to make a function called
getAdapter()
like this:and in
lucia.ts
file:but this don't work, so I recommend making lucia gets a function that returns an adapter or something like that (
new Lucia(async () => await getAdapter())
), i don't know actually...btw I'm using
nextjs
and server actions