Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add prisma #4

Merged
merged 9 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ node_modules
.env.test.local
.env.production.local

# env symlinks
!apps/**/.env
!packages/**/.env

# Testing
coverage

Expand Down
1 change: 1 addition & 0 deletions packages/database/.env
8 changes: 8 additions & 0 deletions packages/database/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ['@repo/eslint-config/base.js'],
env: {
node: true,
},
}
29 changes: 29 additions & 0 deletions packages/database/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@repo/database",
"version": "0.0.0",
"private": true,
"volta": {
"extends": "../../package.json"
},
"scripts": {
"dev": "prisma generate --watch & tsup --watch",
"build": "prisma generate && tsup",
"db:migrate:create": "prisma migrate dev --create-only",
"db:migrate:deploy": "prisma migrate deploy",
"db:migrate:status": "prisma migrate status",
"lint": "eslint --max-warnings=0",
"lint:fix": "eslint --fix",
"format": "prisma format",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@prisma/client": "5.19.0"
},
"devDependencies": {
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"prisma": "5.19.0",
"tsup": "8.1.0",
"typescript": "5.5.2"
}
}
15 changes: 15 additions & 0 deletions packages/database/prisma/schema/config.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
4 changes: 4 additions & 0 deletions packages/database/prisma/schema/model.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
model User {
id Int @id @default(autoincrement())
email String @unique
}
1 change: 1 addition & 0 deletions packages/database/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@prisma/client'
8 changes: 8 additions & 0 deletions packages/database/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@repo/typescript-config/base.json",
"compilerOptions": {
"skipLibCheck": true
},
"include": ["src"],
"exclude": ["dist", "node_modules", "src/**/*.test.ts"]
}
8 changes: 8 additions & 0 deletions packages/database/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'tsup'

export default defineConfig({
entry: ['src/index.ts'],
format: ['esm'],
minify: true,
sourcemap: true,
})
Loading