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

Merge branch 'issue-71/production-env' into 'develop'

Issue #71: ADD production envs

See merge request !72
parents 1fb77d4e 549c7397
No related branches found
No related tags found
1 merge request!72Issue #71: ADD production envs
...@@ -6,7 +6,7 @@ DB_HOST=localhost ...@@ -6,7 +6,7 @@ DB_HOST=localhost
DB_USER=postgres DB_USER=postgres
DB_PASSWORD=postgres DB_PASSWORD=postgres
DB_NAME=hono_db DB_NAME=hono_db
DB_PORT=5433 DB_PORT=5432
# Usually a URL is used for connections # Usually a URL is used for connections
DB_URL=postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME} DB_URL=postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}
...@@ -16,7 +16,7 @@ MAILER_HOST=smtp.c3sl.ufpr.br ...@@ -16,7 +16,7 @@ MAILER_HOST=smtp.c3sl.ufpr.br
# Mailer service port # Mailer service port
MAILER_PORT=25 MAILER_PORT=25
# URL used for email riderecting, this should be the frontend site name like "https://mecred.c3sl.ufpr.br" # 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 # secret used for JWT and crypt
APP_SECRET=VeryLongUniqueSecret APP_SECRET=VeryLongUniqueSecret
...@@ -47,5 +47,6 @@ GOVBR_SECRET= ...@@ -47,5 +47,6 @@ GOVBR_SECRET=
GOVBR_AUTHORIZE_URL= GOVBR_AUTHORIZE_URL=
GOVBR_TOKEN_URL= GOVBR_TOKEN_URL=
GOVBR_PUBLIC_KEY_URL= GOVBR_PUBLIC_KEY_URL=
GOVBR_SERVER_URL=
FRONT_END_RETURN_URL= FRONT_END_RETURN_URL=
{ {
"name": "hono-backend", "name": "hono-backend",
"scripts": { "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:generate": "drizzle-kit generate",
"db:migrate": "cross-env DB_MIGRATING=true bun run src/db/migrate.ts", "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", "db:seed": "cross-env DB_SEEDING=true bun run src/db/seed.ts",
......
...@@ -6,6 +6,7 @@ import env from '@/env' ...@@ -6,6 +6,7 @@ import env from '@/env'
export const connection = postgres(env.DB_URL, { export const connection = postgres(env.DB_URL, {
max: env.DB_MIGRATING || env.DB_SEEDING ? 1 : undefined, max: env.DB_MIGRATING || env.DB_SEEDING ? 1 : undefined,
onnotice: env.DB_SEEDING ? () => {} : undefined, onnotice: env.DB_SEEDING ? () => {} : undefined,
ssl: env.NODE_ENV === 'production' ? true : false,
}) })
export const db = drizzle(connection, { export const db = drizzle(connection, {
......
import type { z } from 'zod' import type { z } from 'zod'
import { userSchemas, type UserModel } from '../schema/user.schema' import { userSchemas, type UserModel } from '../schema/user.schema'
import env from '@/env'
export function hashPassword(pass: UserModel['password']) { export function hashPassword(pass: UserModel['password']) {
if (pass !== null) if (pass !== null)
return Bun.password.hashSync(pass, { return Bun.password.hashSync(pass, {
memoryCost: 4, algorithm: 'bcrypt',
timeCost: 3, cost: env.NODE_ENV === 'production' ? 12 : 10
algorithm: 'argon2id',
}) })
else else
return null; return null;
...@@ -16,7 +16,7 @@ export function verifyPassword( ...@@ -16,7 +16,7 @@ export function verifyPassword(
pass: UserModel['password'], pass: UserModel['password'],
hash: UserModel['password'] hash: UserModel['password']
) { ) {
return Bun.password.verifySync(pass, hash) return Bun.password.verifySync(pass, hash, 'bcrypt')
} }
export const authSchema = userSchemas.userModelSchema.pick({ 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