Skip to content

Commit ea33990

Browse files
authored
trpc-prisma-template
1 parent 2eaceac commit ea33990

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+6599
-0
lines changed

trpc-prisma-starter/.eslintrc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"parser": "@typescript-eslint/parser", // Specifies the ESLint parser
3+
"extends": [
4+
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
5+
"plugin:react/recommended",
6+
"plugin:react-hooks/recommended",
7+
"plugin:prettier/recommended"
8+
],
9+
"parserOptions": {
10+
"project": "tsconfig.json",
11+
"ecmaVersion": 2018, // Allows for the parsing of modern ECMAScript features
12+
"sourceType": "module" // Allows for the use of imports
13+
},
14+
"rules": {
15+
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
16+
"@typescript-eslint/explicit-function-return-type": "off",
17+
"@typescript-eslint/explicit-module-boundary-types": "off",
18+
"react/react-in-jsx-scope": "off",
19+
"react/prop-types": "off",
20+
"@typescript-eslint/no-explicit-any": "off"
21+
},
22+
// "overrides": [
23+
// {
24+
// "files": [],
25+
// "rules": {
26+
// "@typescript-eslint/no-unused-vars": "off"
27+
// }
28+
// }
29+
// ],
30+
"settings": {
31+
"react": {
32+
"version": "detect"
33+
}
34+
}
35+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: KATT
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: '/'
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 2
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: E2E-testing
2+
on: [push]
3+
jobs:
4+
e2e:
5+
env:
6+
DATABASE_URL: postgresql://postgres:@localhost:5432/trpcdb
7+
NODE_ENV: test
8+
NEXTAUTH_SECRET: supersecret
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
node: ['14.x']
13+
os: [ubuntu-latest]
14+
services:
15+
postgres:
16+
image: postgres:12.1
17+
env:
18+
POSTGRES_USER: postgres
19+
POSTGRES_DB: trpcdb
20+
ports:
21+
- 5432:5432
22+
steps:
23+
- name: Checkout repo
24+
uses: actions/checkout@v2
25+
26+
# - name: Install deps and build (with cache)
27+
# uses: bahmutov/npm-install@v1
28+
- run: yarn install
29+
30+
- name: Next.js cache
31+
uses: actions/cache@v2
32+
with:
33+
path: ${{ github.workspace }}/.next/cache
34+
key: ${{ runner.os }}-${{ runner.node }}-${{ hashFiles('**/yarn.lock') }}-nextjs
35+
36+
- run: yarn playwright install --with-deps
37+
- run: yarn lint
38+
- run: yarn build
39+
- run: yarn test-start
40+
- run: yarn test-dev
41+
42+
- name: Upload test results
43+
if: ${{ always() }}
44+
uses: actions/upload-artifact@v2
45+
with:
46+
name: test results
47+
path: |
48+
playwright/test-results

trpc-prisma-starter/.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel
35+
36+
*.db
37+
*.db-journal
38+
prisma/_sqlite/migrations
39+
40+
41+
# testing
42+
playwright/test-results
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"recommendations": [
3+
"esbenp.prettier-vscode",
4+
"dbaeumer.vscode-eslint",
5+
"prisma.prisma"
6+
]
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib"
3+
}

trpc-prisma-starter/README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Prisma + tRPC
2+
3+
## Features
4+
5+
- 🧙‍♂️ E2E typesafety with [tRPC](https://trpc.io)
6+
- ⚡ Full-stack React with Next.js
7+
- ⚡ Database with Prisma
8+
- ⚙️ VSCode extensions
9+
- 🎨 ESLint + Prettier
10+
- 💚 CI setup using GitHub Actions:
11+
- ✅ E2E testing with [Playwright](https://playwright.dev/)
12+
- ✅ Linting
13+
- 🔐 Validates your env vars on build and start
14+
15+
16+
## Setup
17+
18+
**yarn:**
19+
```bash
20+
yarn create next-app --example https://github.com/trpc/trpc --example-path examples/next-prisma-starter trpc-prisma-starter
21+
cd trpc-prisma-starter
22+
yarn
23+
yarn dx
24+
```
25+
26+
**npm:**
27+
```bash
28+
npx create-next-app --example https://github.com/trpc/trpc --example-path examples/next-prisma-starter trpc-prisma-starter
29+
cd trpc-prisma-starter
30+
yarn
31+
yarn dx
32+
```
33+
34+
35+
### Requirements
36+
37+
- Node >= 14
38+
- Docker (for running Postgres)
39+
40+
## Development
41+
42+
### Start project
43+
44+
```bash
45+
yarn create next-app --example https://github.com/trpc/trpc --example-path examples/next-prisma-starter trpc-prisma-starter
46+
cd trpc-prisma-starter
47+
yarn
48+
yarn dx
49+
```
50+
51+
### Commands
52+
53+
```bash
54+
yarn build # runs `prisma generate` + `prisma migrate` + `next build`
55+
yarn db-nuke # resets local db
56+
yarn dev # starts next.js
57+
yarn dx # starts postgres db + runs migrations + seeds + starts next.js
58+
yarn test-dev # runs e2e tests on dev
59+
yarn test-start # runs e2e tests on `next start` - build required before
60+
yarn test:unit # runs normal jest unit tests
61+
yarn test:e2e # runs e2e tests
62+
```
63+
64+
## Deployment
65+
66+
### Using [Render](https://render.com/)
67+
68+
The project contains a [`render.yaml`](./render.yaml) [*"Blueprint"*](https://render.com/docs/blueprint-spec) which makes the project easily deployable on [Render](https://render.com/).
69+
70+
Go to [dashboard.render.com/blueprints](https://dashboard.render.com/blueprints) and connect to this Blueprint and see how the app and database automatically gets deployed.
71+
72+
## Files of note
73+
74+
<table>
75+
<thead>
76+
<tr>
77+
<th>Path</th>
78+
<th>Description</th>
79+
</tr>
80+
</thead>
81+
<tbody>
82+
<tr>
83+
<td><a href="./prisma/schema.prisma"><code>./prisma/schema.prisma</code></a></td>
84+
<td>Prisma schema</td>
85+
</tr>
86+
<tr>
87+
<td><a href="./src/pages/api/trpc/[trpc].ts"><code>./src/pages/api/trpc/[trpc].ts</code></a></td>
88+
<td>tRPC response handler</td>
89+
</tr>
90+
<tr>
91+
<td><a href="./src/server/routers"><code>./src/server/routers</code></a></td>
92+
<td>Your app's different tRPC-routers</td>
93+
</tr>
94+
</tbody>
95+
</table>
96+
97+
---
98+
99+
Created by [@alexdotjs](https://twitter.com/alexdotjs).
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: '3.6'
2+
services:
3+
postgres:
4+
image: postgres:13
5+
ports:
6+
- '5832:5432' # expose pg on port 5832 to not collide with pg from elswhere
7+
restart: always
8+
volumes:
9+
- db_data:/var/lib/postgresql/data
10+
environment:
11+
POSTGRES_PASSWORD: ${PGPASSWORD}
12+
POSTGRES_HOST_AUTH_METHOD: trust
13+
volumes:
14+
db_data:

0 commit comments

Comments
 (0)