Skip to content

Commit

Permalink
refactor: move prisma to a package (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
lihebi authored Aug 28, 2023
1 parent d242c4d commit e1a7151
Show file tree
Hide file tree
Showing 32 changed files with 73 additions and 7 deletions.
1 change: 1 addition & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"@apollo/client": "^3.7.1",
"@codepod/prisma": "workspace:*",
"@kubernetes/client-node": "^0.17.1",
"@prisma/client": "4.3.1",
"apollo-server": "^3.5.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/resolver_repo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// nanoid v4 does not work with nodejs. https://github.com/ai/nanoid/issues/365
import { customAlphabet } from "nanoid/async";
import { lowercase, numbers } from "nanoid-dictionary";
import prisma from "./client";
import prisma from "@codepod/prisma";

const nanoid = customAlphabet(lowercase + numbers, 20);

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/resolver_user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { OAuth2Client } from "google-auth-library";
import { customAlphabet } from "nanoid/async";
import { lowercase, numbers } from "nanoid-dictionary";

import prisma from "./client";
import prisma from "@codepod/prisma";

const nanoid = customAlphabet(lowercase + numbers, 20);

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/yjs-blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Node as ReactflowNode, Edge as ReactflowEdge } from "reactflow";

import debounce from "lodash/debounce";

import prisma from "./client";
import prisma from "@codepod/prisma";
import { dbtype2nodetype, json2yxml } from "./yjs-utils";
import { setupObserversToRuntime } from "./yjs-runtime";

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/yjs-plain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Node as ReactflowNode, Edge as ReactflowEdge } from "reactflow";

import debounce from "lodash/debounce";

import prisma from "./client";
import prisma from "@codepod/prisma";
import {
dbtype2nodetype,
json2yxml,
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/yjs-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ApolloServerPluginLandingPageLocalDefault } from "apollo-server-core";

import { getYDoc, setupWSConnection } from "./yjs-setupWS";

import prisma from "./client";
import prisma from "@codepod/prisma";
import { connectSocket, runtime2socket } from "./yjs-runtime";

interface TokenInterface {
Expand Down
2 changes: 1 addition & 1 deletion compose/dev/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
# 2. it is mounted to all service containers, and will cache and speed up
# pnpm install and pnpm add/remove
- pnpm-store:/codepod/.pnpm-store
command: sh -c "corepack enable && pnpm install && cd apps/api && pnpm dlx prisma migrate dev"
command: sh -c "corepack enable && pnpm install && cd packages/prisma && pnpm dlx prisma migrate dev && pnpm build"
environment:
DATABASE_URL: "postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}?schema=public"

Expand Down
3 changes: 3 additions & 0 deletions packages/prisma/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
conns/conn-*.json
prisma/dev.db
16 changes: 16 additions & 0 deletions packages/prisma/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@codepod/prisma",
"version": "1.0.0",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "tsc"
},
"dependencies": {
"@prisma/client": "4.3.1"
},
"devDependencies": {
"typescript": "^5.2.2"
}
}
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions packages/prisma/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"module": "commonjs",
"outDir": "dist",
"target": "esnext",
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"lib": ["esnext"],
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"isolatedModules": true,
"noImplicitAny": false,
"declaration": true
},
"ts-node": {
// these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": {
"module": "commonjs"
}
},
"include": ["src"]
}
21 changes: 20 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e1a7151

Please sign in to comment.