Skip to content

Commit

Permalink
fix: env (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmbanan666 authored Feb 6, 2025
1 parent 8eb910d commit aa14776
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 17 deletions.
6 changes: 3 additions & 3 deletions apps/food/.env.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Channel ID from DB to access related entities
APP_CHANNEL_ID="burger"
NUXT_CHANNEL_ID="burger"

# Session password for Nuxt Auth Utils
APP_SESSION_PASSWORD=""
NUXT_SESSION_PASSWORD=""

# Locale for Nuxt I18n
APP_PUBLIC_LOCALE="en"
NUXT_PUBLIC_LOCALE="en"

# App version
VERSION=""
3 changes: 0 additions & 3 deletions apps/food/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ export default defineNuxtConfig({
},
css: ['~/assets/css/styles.css'],
runtimeConfig: {
nitro: {
envPrefix: 'APP_',
},
channelId: 'burger',
storageProductsDirectory: 'products',
public: {
Expand Down
9 changes: 4 additions & 5 deletions apps/food/server/plugins/01.database.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import process from 'node:process'
import { useCreateDatabase } from '@next-orders/database'

/**
* DB init
*/
export default defineNitroPlugin(async () => {
const runtimeConfig = useRuntimeConfig()

if (!runtimeConfig.databaseURL) {
throw new Error('APP_DATABASE_URL is not defined')
if (!process.env.DATABASE_URL) {
throw new Error('DATABASE_URL is not defined')
}

useCreateDatabase(runtimeConfig.databaseURL)
useCreateDatabase(process.env.DATABASE_URL)

// In dev mode we don't execute migrations, for this we use the command `pnpm db:migrate` in `@next-orders/database`
if (import.meta.dev) {
Expand Down
2 changes: 1 addition & 1 deletion packages/database/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
APP_DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres
DATABASE_URL="postgres://postgres:postgres@localhost:5432/postgres"
6 changes: 1 addition & 5 deletions packages/database/drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ import process from 'node:process'
import { defineConfig } from 'drizzle-kit'
import 'dotenv/config'

if (!process.env.APP_DATABASE_URL) {
throw new Error('APP_DATABASE_URL is not defined')
}

export default defineConfig({
dialect: 'postgresql',
schema: './src/tables.ts',
out: './migrations',
dbCredentials: {
url: process.env.APP_DATABASE_URL,
url: process.env.DATABASE_URL!,
},
})

0 comments on commit aa14776

Please sign in to comment.