Skip to content

Commit

Permalink
Db change (#93)
Browse files Browse the repository at this point in the history
* migrate to supa

* foreign key

* formatting
  • Loading branch information
armintalaie committed Apr 9, 2024
1 parent 2d0f331 commit 75fdfaa
Show file tree
Hide file tree
Showing 10 changed files with 410 additions and 154 deletions.
12 changes: 11 additions & 1 deletion config/database.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export interface IDatabaseConfig {
DATABASE_HOST: string;
DATABASE_USERNAME: string;
DATABASE_PASSWORD: string;
DATABASE_PORT: string;
DATABASE_NAME: string;
}

export class DATABASE_CONFIG {
Expand All @@ -14,19 +16,27 @@ export class DATABASE_CONFIG {
process.env.DATABASE_USERNAME;
public static readonly DB_PASSWORD: string | undefined =
process.env.DATABASE_PASSWORD;
public static readonly DB_PORT: string | undefined =
process.env.DATABASE_PORT || '5432';
public static readonly DB_NAME: string | undefined =
process.env.DATABASE_NAME;

public static getDBConfig(): IDatabaseConfig {
if (
!DATABASE_CONFIG.DB_HOST ||
!DATABASE_CONFIG.DB_USERNAME ||
!DATABASE_CONFIG.DB_PASSWORD
!DATABASE_CONFIG.DB_PASSWORD ||
!DATABASE_CONFIG.DB_PORT ||
!DATABASE_CONFIG.DB_NAME
) {
throw new Error('Database configuration not found');
}
return {
DATABASE_HOST: DATABASE_CONFIG.DB_HOST,
DATABASE_USERNAME: DATABASE_CONFIG.DB_USERNAME,
DATABASE_PASSWORD: DATABASE_CONFIG.DB_PASSWORD,
DATABASE_PORT: DATABASE_CONFIG.DB_PORT,
DATABASE_NAME: DATABASE_CONFIG.DB_NAME,
};
}
}
2 changes: 1 addition & 1 deletion lib/user.stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class UserStack extends LPStack {
environment: {
...databaseConfig,
mode: props.mode,
MAIN_DATABASE_URL: process.env.MAIN_DATABASE_URL || '',
...databaseConfig,
},
};

Expand Down
246 changes: 246 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
"jwt-decode": "^3.1.2",
"kysely": "^0.26.3",
"kysely-planetscale": "^1.4.0",
"kysely-postgres-js": "^2.0.0",
"mysql2": "^3.6.3",
"pg": "^8.11.5",
"undici": "^5.28.3",
"uuid": "^9.0.1"
},
Expand All @@ -49,6 +51,7 @@
"@types/aws-sdk": "^2.7.0",
"@types/jest": "^29.5.2",
"@types/node": "^18.14.6",
"@types/pg": "^8.11.5",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"aws-cdk": "2.70.0",
Expand Down
Loading

0 comments on commit 75fdfaa

Please sign in to comment.