Skip to content

Commit

Permalink
feat(server): test database connection
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Jan 15, 2024
1 parent 57a573e commit 1f67e20
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Dockerfile.Server
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ COPY . .

RUN pnpm build:server

RUN pnpm animegarden migrate --uri ${POSTGRES_URI}

CMD node packages/server/dist/index.mjs
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"animegarden": "tsx packages/cli/src/cli.ts",
"build": "turbo run build",
"build:app": "turbo run build --filter @animegarden/app...",
"build:cli": "turbo run build --filter @animegarden/cli...",
"build:server": "turbo run build --filter @animegarden/server...",
"dev": "turbo run dev --parallel",
"dev:app": "pnpm -C packages/app dev",
Expand Down
11 changes: 11 additions & 0 deletions packages/server/src/database.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { connectDatabase } from '@animegarden/database';

const DATABASE_URI = process.env.POSTGRES_URI ?? process.env.DATABASE_URI;
if (!DATABASE_URI) {
console.log(`Can not find database connection string`);
process.exit(1);
}

const { database, connection } = connectDatabase(DATABASE_URI);

export { database, connection };

0 comments on commit 1f67e20

Please sign in to comment.