From ff371798a9c4758ca41c02232dffb77a3ae24a1d Mon Sep 17 00:00:00 2001 From: Nathan Rashleigh Date: Tue, 29 Apr 2025 18:52:36 +1000 Subject: [PATCH] back --- .gitignore | 2 ++ crates/api/pg.ts | 12 +++++-- crates/deno.jsonc | 5 +-- crates/prisma/schema.prisma | 4 +-- docker-compose.OLD.yaml | 63 +++++++++++++++++++++++++++++++++++++ docker-compose.yaml | 48 ---------------------------- 6 files changed, 80 insertions(+), 54 deletions(-) create mode 100644 docker-compose.OLD.yaml diff --git a/.gitignore b/.gitignore index 26bd9ba..ed28dc6 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ db/ *sql.gz crates/prisma/generated/client crates.sublime-workspace +crates/static/css +crates/prisma/generated diff --git a/crates/api/pg.ts b/crates/api/pg.ts index 853276d..6e20b72 100644 --- a/crates/api/pg.ts +++ b/crates/api/pg.ts @@ -1,12 +1,20 @@ import * as bcrypt from "https://deno.land/x/bcrypt@v0.4.1/mod.ts" import { load } from "$std/dotenv/mod.ts" -import { Prisma, PrismaClient } from "prisma/generated/client/deno/edge.ts"; +import { PrismaClient } from "prisma/generated/index.js"; // Load environment variables await load({ export: true }) // Create and export the Prisma client -export const prisma = new PrismaClient() +const DATABASE_URL = Deno.env.get("DATABASE_URL") +console.log("DATABASE_URL", { DATABASE_URL }) +export const prisma = new PrismaClient({ + datasources: { + db: { + url: DATABASE_URL, + }, + }, +}); export interface UserCreateParams { email: string diff --git a/crates/deno.jsonc b/crates/deno.jsonc index 4783064..5b488e2 100644 --- a/crates/deno.jsonc +++ b/crates/deno.jsonc @@ -4,10 +4,11 @@ "check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx", "cli": "echo \"import '\\$fresh/src/dev/cli.ts'\" | deno run --unstable -A -", "manifest": "deno task cli manifest $(pwd)", - "start": "deno run -A --watch=static/,routes/ dev.ts", + "start": "deno run --unstable-detect-cjs -A --watch=static/,routes/ dev.ts", "build": "deno run -A dev.ts build", "preview": "deno run -A main.ts", - "prisma-generate": "deno run -A --unstable-detect-cjs npm:prisma@latest generate --no-engine", + "prisma-generate": "deno run -A --env-file npm:prisma generate", + "prisma:migrate": "deno run -A --env-file npm:prisma migrate dev", "update": "deno run -A -r https://fresh.deno.dev/update ." }, diff --git a/crates/prisma/schema.prisma b/crates/prisma/schema.prisma index dbe16d3..3b790f2 100644 --- a/crates/prisma/schema.prisma +++ b/crates/prisma/schema.prisma @@ -1,7 +1,7 @@ generator client { provider = "prisma-client-js" - previewFeatures = ["deno"] - output = "./generated/client" + output = "./generated" + moduleFormat = "esm" } datasource db { diff --git a/docker-compose.OLD.yaml b/docker-compose.OLD.yaml new file mode 100644 index 0000000..532ca93 --- /dev/null +++ b/docker-compose.OLD.yaml @@ -0,0 +1,63 @@ +version: "3.3" + +services: + pg: + image: postgres:latest + environment: + POSTGRES_USER: '${POSTGRES_USER}' + POSTGRES_DB: '${POSTGRES_DB}' + POSTGRES_PASSWORD: '${POSTGRES_PASSWORD}' + volumes: + # so ez + # insane + - "./pg:/docker-entrypoint-initdb.d" + ports: + - '45432:5432' + + api: + image: crates/api + build: + context: ./api + dockerfile: ./api.Dockerfile + working_dir: /opt/crates/api + depends_on: + - 'pg' + command: npm start + environment: + DATABASE_URL: 'postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:5432/${POSTGRES_DB}?schema=public' + DISCORD_TOKEN: '${DISCORD_TOKEN}' + DISCOGS_TOKEN: '${DISCOGS_TOKEN}' + CHOKIDAR_USEPOLLING: 1 + volumes: + - "./api:/opt/crates/api" + - "/opt/crates/api/node_modules" + + migrate: + restart: on-failure:3 + extends: api + command: npm run migrate status + + client: + image: node:16 + working_dir: /opt/crates/client + build: + context: ./client + dockerfile: ./client.dev.Dockerfile + entrypoint: npm start + ports: + - '8080:8080' # fwd the hmr websocket + environment: + CHOKIDAR_USEPOLLING: 1 + volumes: + - "./client:/opt/crates/client" + - "./api:/opt/crates/api" + - "/opt/crates/client/node_modules" + + nginx: + image: nginx:latest + depends_on: + - 'api' + volumes: + - './nginx/localhost.nginx.conf:/etc/nginx/conf.d/default.conf' + ports: + - '80:80' diff --git a/docker-compose.yaml b/docker-compose.yaml index 532ca93..42565ba 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,51 +13,3 @@ services: - "./pg:/docker-entrypoint-initdb.d" ports: - '45432:5432' - - api: - image: crates/api - build: - context: ./api - dockerfile: ./api.Dockerfile - working_dir: /opt/crates/api - depends_on: - - 'pg' - command: npm start - environment: - DATABASE_URL: 'postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:5432/${POSTGRES_DB}?schema=public' - DISCORD_TOKEN: '${DISCORD_TOKEN}' - DISCOGS_TOKEN: '${DISCOGS_TOKEN}' - CHOKIDAR_USEPOLLING: 1 - volumes: - - "./api:/opt/crates/api" - - "/opt/crates/api/node_modules" - - migrate: - restart: on-failure:3 - extends: api - command: npm run migrate status - - client: - image: node:16 - working_dir: /opt/crates/client - build: - context: ./client - dockerfile: ./client.dev.Dockerfile - entrypoint: npm start - ports: - - '8080:8080' # fwd the hmr websocket - environment: - CHOKIDAR_USEPOLLING: 1 - volumes: - - "./client:/opt/crates/client" - - "./api:/opt/crates/api" - - "/opt/crates/client/node_modules" - - nginx: - image: nginx:latest - depends_on: - - 'api' - volumes: - - './nginx/localhost.nginx.conf:/etc/nginx/conf.d/default.conf' - ports: - - '80:80'