patryk
patryk
DTDrizzle Team
Created by patryk on 9/8/2024 in #help
Error: The edge runtime does not support Node.js 'crypto' module.
I dont know what i'm doing wrong during the setup of next auth
import type { NextAuthConfig } from "next-auth"
import Credentials from "next-auth/providers/credentials";
import { LoginSchema } from "@/schemas";
import { getUserByEmail } from "@/data/user";

import bcrypt from "bcryptjs";

export default {
providers: [
Credentials({
async authorize(credentials) {
if(!credentials) return null;

const validatedFields = LoginSchema.safeParse(credentials);

if(validatedFields.success) {
const {email, password} = validatedFields.data;

const user = await getUserByEmail(email);

if(!user || !user.password) return null;

const passwordsMatch = await bcrypt.compare(
password,
user.password,
);

if(passwordsMatch) return {
...user,
id: String(user.id),
};
}

return null;
}
})
],
} satisfies NextAuthConfig
import type { NextAuthConfig } from "next-auth"
import Credentials from "next-auth/providers/credentials";
import { LoginSchema } from "@/schemas";
import { getUserByEmail } from "@/data/user";

import bcrypt from "bcryptjs";

export default {
providers: [
Credentials({
async authorize(credentials) {
if(!credentials) return null;

const validatedFields = LoginSchema.safeParse(credentials);

if(validatedFields.success) {
const {email, password} = validatedFields.data;

const user = await getUserByEmail(email);

if(!user || !user.password) return null;

const passwordsMatch = await bcrypt.compare(
password,
user.password,
);

if(passwordsMatch) return {
...user,
id: String(user.id),
};
}

return null;
}
})
],
} satisfies NextAuthConfig
import NextAuth from "next-auth"
import { DrizzleAdapter } from "@auth/drizzle-adapter"
import { db } from "@/lib/db";
import authConfig from "@/auth.config"

export const { handlers, auth, signIn, signOut } = NextAuth({
adapter: DrizzleAdapter(db),
session: {strategy: "jwt"},
...authConfig,
})
import NextAuth from "next-auth"
import { DrizzleAdapter } from "@auth/drizzle-adapter"
import { db } from "@/lib/db";
import authConfig from "@/auth.config"

export const { handlers, auth, signIn, signOut } = NextAuth({
adapter: DrizzleAdapter(db),
session: {strategy: "jwt"},
...authConfig,
})
```
3 replies
DTDrizzle Team
Created by patryk on 2/4/2024 in #help
Troubles during migrations using drizzle and a neon serverless database
Hello im really new to drizzle and i already learned how to setup a scheme but im having troubles when i want to migrate it to the neon postgressql database. Error: No database connection string was provided to neon(). Perhaps an environment variable has not been set? This is how my migration file looks like:
import { migrate } from 'drizzle-orm/neon-http/migrator';
import { drizzle, NeonHttpDatabase } from 'drizzle-orm/neon-http'
import { neon } from '@neondatabase/serverless';


async function main() {
const sql = neon(process.env.DATABASE_URL as string)
const db: NeonHttpDatabase = drizzle(sql);

console.log("[migrate] Running migrations ...");

await migrate(db, {migrationsFolder: "lib/db/migrations" });

console.log("[migrate] All migrations have been ran, exiting ...");
}

main();
import { migrate } from 'drizzle-orm/neon-http/migrator';
import { drizzle, NeonHttpDatabase } from 'drizzle-orm/neon-http'
import { neon } from '@neondatabase/serverless';


async function main() {
const sql = neon(process.env.DATABASE_URL as string)
const db: NeonHttpDatabase = drizzle(sql);

console.log("[migrate] Running migrations ...");

await migrate(db, {migrationsFolder: "lib/db/migrations" });

console.log("[migrate] All migrations have been ran, exiting ...");
}

main();
6 replies