From 26080dced05175dda6fbdc35ab773b42877b82e9 Mon Sep 17 00:00:00 2001 From: Aiji Uejima Date: Tue, 5 Jul 2022 00:48:36 +0900 Subject: [PATCH] feat: make `PRSIMA_SCHAMA_PATH` unnecessary --- README.md | 4 ---- docker-compose.yml | 1 - src/server.ts | 9 +-------- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/README.md b/README.md index 3108cb7..5bbdef4 100644 --- a/README.md +++ b/README.md @@ -139,9 +139,6 @@ FROM base COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package.json ./package.json -COPY --from=builder /app/prisma/schema.prisma ./prisma/schema.prisma - -ENV PRISMA_SCHEMA_PATH=/app/prisma/schema.prisma USER node @@ -225,7 +222,6 @@ Then set the `DATABASE_URL` and `DATA_PROXY_API_KEY` as environment variables an ![](./images/vercel.png) -- `PRISMA_SCHEMA_PATH`: TODO - `DATABASE_URL`: Connection URL to your data source (mysql, postgres, etc...) - `DATA_PROXY_API_KEY`: Arbitrary string to be used when connecting data proxy. e.g. `prisma://your.deployed.domain?api_key={DATA_PROXY_API_KEY}` (do not divulge it to outside parties) diff --git a/docker-compose.yml b/docker-compose.yml index fea8dbd..b604964 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,6 @@ services: entrypoint: /app/entrypoint.sh command: ./wait-for-it.sh https-portal3000:443 --timeout=120 --strict -- yarn dev:server environment: - PRISMA_SCHEMA_PATH: /app/prisma/schema.prisma DATABASE_URL: postgresql://postgres:pass@db:5432/postgres?schema=public DATA_PROXY_API_KEY: custometoken MIGRATE: "true" diff --git a/src/server.ts b/src/server.ts index 5d15686..325bd5f 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,19 +1,12 @@ #! /usr/bin/env node import { PrismaClient } from "@prisma/client"; import { getDMMF, getSchemaSync } from "@prisma/sdk"; -import * as path from "path"; import express from "express"; import { ApolloServer } from "apollo-server-express"; import { afterMiddleware, makeServerConfig, beforeMiddleware } from "./"; import { config } from "dotenv"; config(); -const schemaPath = - process.env.PRISMA_SCHEMA_PATH ?? path.join(__dirname, "./schema.prisma"); -const schema = getSchemaSync( - schemaPath.startsWith("/") ? schemaPath : path.join(__dirname, schemaPath) -); - const db = new PrismaClient( process.env.NODE_ENV === "production" ? undefined @@ -32,7 +25,7 @@ app.use(afterMiddleware()); (async () => { const dmmf = await getDMMF({ - datamodel: schema, + datamodel: getSchemaSync(), }); const server = new ApolloServer({ ...makeServerConfig(dmmf, db),