mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-03 05:34:23 -04:00
Fix connection things
This commit is contained in:
parent
8acb1750b6
commit
da3a5181df
9
api/.env.example
Normal file
9
api/.env.example
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# vi: ft=sh
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
|
||||||
|
|
||||||
|
POSTGRES_USER=kyoo
|
||||||
|
POSTGRES_PASSWORD=password
|
||||||
|
POSTGRES_DB=kyooDB
|
||||||
|
POSTGRES_SERVER=postgres
|
||||||
|
POSTGRES_PORT=5432
|
@ -1,2 +1,4 @@
|
|||||||
|
import { Elysia } from "elysia";
|
||||||
|
|
||||||
export const EntriesController = new Elysia()
|
export const EntriesController = new Elysia()
|
||||||
.get('/entries', () => "hello");
|
.get('/entries', () => "hello");
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
import { drizzle } from "drizzle-orm/node-postgres";
|
import { drizzle } from "drizzle-orm/node-postgres";
|
||||||
|
|
||||||
const db = drizzle({
|
export const db = drizzle({
|
||||||
connection: {
|
connection: {
|
||||||
connectionString: process.env.DATABASE_URL!,
|
user: process.env.POSTGRES_USER ?? "kyoo",
|
||||||
|
password: process.env.POSTGRES_PASSWORD ?? "password",
|
||||||
|
database: process.env.POSTGRES_DB ?? "kyooDB",
|
||||||
|
host: process.env.POSTGRES_SERVER ?? "postgres",
|
||||||
|
port: Number(process.env.POSTGRES_PORT) || 5432,
|
||||||
ssl: true,
|
ssl: true,
|
||||||
},
|
},
|
||||||
casing: "snake_case",
|
casing: "snake_case",
|
||||||
|
@ -1,15 +1,8 @@
|
|||||||
import { Elysia } from "elysia";
|
import { Elysia } from "elysia";
|
||||||
import { swagger } from "@elysiajs/swagger";
|
import { swagger } from "@elysiajs/swagger";
|
||||||
import { drizzle } from "drizzle-orm/node-postgres";
|
import { db } from "./db";
|
||||||
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
||||||
|
|
||||||
if (!process.env.DATABASE_URL) {
|
|
||||||
console.error("Missing `DATABASE_URL` environment variable. Exiting");
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const db = drizzle(process.env.DATABASE_URL);
|
|
||||||
|
|
||||||
await migrate(db, { migrationsFolder: "" });
|
await migrate(db, { migrationsFolder: "" });
|
||||||
|
|
||||||
const app = new Elysia()
|
const app = new Elysia()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user