diff --git a/.env.example b/.env.example index f806a3fc5395d6925926a9eb2a24e2adebe3bdaa..6af8d1ca753f3ac1d9ed14e3c278677c081d4c68 100644 --- a/.env.example +++ b/.env.example @@ -6,7 +6,7 @@ DB_HOST=localhost DB_USER=postgres DB_PASSWORD=postgres DB_NAME=hono_db -DB_PORT=5433 +DB_PORT=5432 # Usually a URL is used for connections DB_URL=postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME} @@ -16,7 +16,7 @@ MAILER_HOST=smtp.c3sl.ufpr.br # Mailer service port MAILER_PORT=25 # URL used for email riderecting, this should be the frontend site name like "https://mecred.c3sl.ufpr.br" -URL=EmailURL +EMAIL_URL=EmailURL # secret used for JWT and crypt APP_SECRET=VeryLongUniqueSecret @@ -47,5 +47,6 @@ GOVBR_SECRET= GOVBR_AUTHORIZE_URL= GOVBR_TOKEN_URL= GOVBR_PUBLIC_KEY_URL= +GOVBR_SERVER_URL= FRONT_END_RETURN_URL= diff --git a/package.json b/package.json index d632f91e3051c3ed678f074473c627f60b622550..3f8ec9698c62e99db65e02d2af5f9629927f93e3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "hono-backend", "scripts": { - "dev": "bun run --port '3000' --hot --watch src/index.ts", + "dev": "bun run --hot --watch src/index.ts --port '4000'", "db:generate": "drizzle-kit generate", "db:migrate": "cross-env DB_MIGRATING=true bun run src/db/migrate.ts", "db:seed": "cross-env DB_SEEDING=true bun run src/db/seed.ts", diff --git a/src/db/index.ts b/src/db/index.ts index 67c0ca07d3793f0ea5a9f136a40912c206e1a44c..a94928454c62cfb3e1e8676c3a82fbc30d12d1a8 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -6,6 +6,7 @@ import env from '@/env' export const connection = postgres(env.DB_URL, { max: env.DB_MIGRATING || env.DB_SEEDING ? 1 : undefined, onnotice: env.DB_SEEDING ? () => {} : undefined, + ssl: env.NODE_ENV === 'production' ? true : false, }) export const db = drizzle(connection, { diff --git a/src/db/repo/auth.repo.ts b/src/db/repo/auth.repo.ts index d15a85bd17fee07ba6ca76b5ede8369241369d55..b765583601ccd00bd1d403e0ad4dc9b410a9040c 100644 --- a/src/db/repo/auth.repo.ts +++ b/src/db/repo/auth.repo.ts @@ -1,12 +1,12 @@ import type { z } from 'zod' import { userSchemas, type UserModel } from '../schema/user.schema' +import env from '@/env' export function hashPassword(pass: UserModel['password']) { if (pass !== null) return Bun.password.hashSync(pass, { - memoryCost: 4, - timeCost: 3, - algorithm: 'argon2id', + algorithm: 'bcrypt', + cost: env.NODE_ENV === 'production' ? 12 : 10 }) else return null; @@ -16,7 +16,7 @@ export function verifyPassword( pass: UserModel['password'], hash: UserModel['password'] ) { - return Bun.password.verifySync(pass, hash) + return Bun.password.verifySync(pass, hash, 'bcrypt') } export const authSchema = userSchemas.userModelSchema.pick({