Skip to content
Snippets Groups Projects
Commit 549c7397 authored by Richard Fernando Heise Ferreira's avatar Richard Fernando Heise Ferreira
Browse files

Issue #71: ADD production envs

parent 1fb77d4e
No related branches found
No related tags found
1 merge request!72Issue #71: ADD production envs
......@@ -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=
{
"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",
......
......@@ -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, {
......
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({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment