Skip to content

Commit

Permalink
feat: prisma
Browse files Browse the repository at this point in the history
  • Loading branch information
rharkor committed Jul 21, 2023
1 parent 3dc3177 commit cdc3a7b
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 16 deletions.
76 changes: 73 additions & 3 deletions package-lock.json

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

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "next-enterprise",
"name": "next-boilerplate",
"version": "0.0.0",
"private": true,
"scripts": {
Expand All @@ -25,6 +25,7 @@
},
"dependencies": {
"@next/bundle-analyzer": "^13.3.0",
"@prisma/client": "^5.0.0",
"@radix-ui/react-accordion": "^1.1.1",
"@radix-ui/react-checkbox": "^1.0.3",
"@radix-ui/react-dialog": "^1.0.3",
Expand All @@ -47,6 +48,7 @@
"@semantic-release/npm": "^10.0.3",
"@semantic-release/release-notes-generator": "^11.0.1",
"@t3-oss/env-nextjs": "^0.6.0",
"@tanstack/react-query": "^4.32.0",
"@vercel/otel": "^0.3.0",
"class-variance-authority": "^0.6.1",
"clsx": "^2.0.0",
Expand Down Expand Up @@ -106,10 +108,12 @@
"tailwindcss": "^3.2.7",
"ts-jest": "^29.1.0",
"tsc": "^2.0.4",
"typescript": "5.1.6",
"vitest": "^0.33.0"
},
"engines": {
"node": ">=18.15.0"
},
"prisma": {
"schema": "src/prisma/schema.prisma"
}
}
4 changes: 1 addition & 3 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from "react"

export default function Home() {
return <h1>Home</h1>
return "Hello world!"
}
3 changes: 3 additions & 0 deletions src/lib/prisma.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { PrismaClient } from "@prisma/client"

export const prisma = new PrismaClient()
17 changes: 17 additions & 0 deletions src/prisma/migrations/20230721160351_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"username" TEXT NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
3 changes: 3 additions & 0 deletions src/prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
9 changes: 9 additions & 0 deletions src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
8 changes: 0 additions & 8 deletions src/prisma/user.prisma

This file was deleted.

19 changes: 19 additions & 0 deletions src/server/routers/_app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { z } from "zod"
import { procedure, router } from "../trpc"

export const appRouter = router({
hello: procedure
.input(
z.object({
text: z.string(),
})
)
.query((opts) => {
return {
greeting: `hello ${opts.input.text}`,
}
}),
})

// export type definition of API
export type AppRouter = typeof appRouter
11 changes: 11 additions & 0 deletions src/server/trpc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { initTRPC } from "@trpc/server"

// Avoid exporting the entire t-object
// since it's not very descriptive.
// For instance, the use of a t variable
// is common in i18n libraries.
const t = initTRPC.create()

// Base router and procedure helpers
export const router = t.router
export const procedure = t.procedure
1 change: 1 addition & 0 deletions tsconfig.tsbuildinfo

Large diffs are not rendered by default.

0 comments on commit cdc3a7b

Please sign in to comment.