Skip to content

Commit

Permalink
Fix envar
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Jul 26, 2024
1 parent 62bf4d3 commit 78f1b2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default defineConfig({
dbCredentials: {
user: process.env.DB_USERNAME || 'root',
password: process.env.DB_PASSWORD || '',
host: process.env.DB_HOST || '127.0.0.1' || 'localhost',
host: process.env.DB_HOST || '127.0.0.1',
port: parseInt(process.env.DB_PORT || '3306'),
database: process.env.DB_NAME || 'oneform_db',
},
Expand Down
12 changes: 7 additions & 5 deletions src/lib/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import {migrate} from 'drizzle-orm/mysql2/migrator';

import * as schema from '@/db/schema';
import mysql from 'mysql2/promise';

// import.meta.env saves envar at build time
const mySqlConfig = {
host: process.env.DB_HOST || '127.0.0.1' || 'localhost',
user: process.env.DB_USER || 'root',
password: process.env.DB_PASSWORD || '',
database: process.env.DB_NAME || 'oneform_db',
port: parseInt(process.env.DB_PORT || '3306'),
host: import.meta.env.DB_HOST || '127.0.0.1',
user: import.meta.env.DB_USER || 'root',
password: import.meta.env.DB_PASSWORD || '',
database: import.meta.env.DB_NAME || 'oneform_db',
port: parseInt(import.meta.env.DB_PORT || '3306'),
};

const sql = mysql.createPool(mySqlConfig);
Expand Down

0 comments on commit 78f1b2f

Please sign in to comment.