From eed1117ebe5d72c9ac326f84ee0bfcdaedf7ad95 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Sat, 11 Nov 2023 00:06:59 +0800 Subject: [PATCH] update env --- .env.example | 10 +++++----- src/database.ts | 28 ++++++++++++++-------------- src/index.ts | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.env.example b/.env.example index 851871b..ddc116d 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,6 @@ -host=0.0.0.0 -user=postgres -password=password -port=5432 -database=railway +PGHOST=0.0.0.0 +PGPORT=5432 +PGUSER=postgres +PGPASSWORD=password +PGDATABASE=link-shortener FALLBACK_URL=https://shortener-svelte.tzgyn.com diff --git a/src/database.ts b/src/database.ts index 183ee21..42fbb08 100644 --- a/src/database.ts +++ b/src/database.ts @@ -1,18 +1,18 @@ -import { Database } from "./types"; -import { Pool } from "pg"; -import { Kysely, PostgresDialect } from "kysely"; +import { Database } from './types' +import { Pool } from 'pg' +import { Kysely, PostgresDialect } from 'kysely' const dialect = new PostgresDialect({ - pool: new Pool({ - database: Bun.env.database ?? "link-shortener", - host: Bun.env.host ?? "0.0.0.0", - user: Bun.env.user ?? "postgres", - password: Bun.env.password ?? "password", - port: parseInt(Bun.env.port ?? "") ?? 5432, - max: 10, - }), -}); + pool: new Pool({ + database: Bun.env.PGDATABASE ?? 'link-shortener', + host: Bun.env.PGHOST ?? '0.0.0.0', + user: Bun.env.PGUSER ?? 'postgres', + password: Bun.env.PGPASSWORD ?? 'password', + port: parseInt(Bun.env.PGPORT ?? '') ?? 5432, + max: 10, + }), +}) export const db = new Kysely({ - dialect, -}); + dialect, +}) diff --git a/src/index.ts b/src/index.ts index 42092f1..0c60960 100644 --- a/src/index.ts +++ b/src/index.ts @@ -55,7 +55,7 @@ app.listen(3000) console.log( `🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`, - `${Bun.env.database}` + `${Bun.env.PGDATABASE}` ) export type App = typeof app