-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from huv1k/feat/pothos
👋 Hey strangers, this PR updates this template with a couple of changes. ## Schema builder I decided to switch to [Pothos GraphQL](https://github.com/hayes/pothos) instead of Nexus, because there is [no future](graphql-nexus/nexus-plugin-prisma#1039 (comment)) for `nexus-prisma`, so it doesn't make sense to keep it inside this template. @hayes is doing a great job with Pothos and everything about it is good 🙌 ## Move to JWT I moved the session strategy to `JWT` so it's prepared for edge computing and Next.js middleware. ## New database I decided to move to [PlanetScale](https://planetscale.com), they provide really generous free tier. They are a new cool kid in the block with database branching which is a perfect feature. If this doesn't suit, you can still you another database that Prisma supports. ## Fixes I fixed some problems with types and now it should work as expected. When `JWT` token is not presented, there is a fallback to `userId` and `userRole`. Fixes huv1k/nextjs-auth-prisma#29
- Loading branch information
Showing
34 changed files
with
2,924 additions
and
4,706 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
DATABASE_URL="postgresql://" | ||
GITHUB_ID="" | ||
GITHUB_SECRET="" | ||
NEXTAUTH_URL="http://localhost:3000/api/auth" | ||
JWT_SECRET="" | ||
DATABASE_URL=postgresql:// | ||
GITHUB_ID= | ||
GITHUB_SECRET= | ||
NEXTAUTH_URL=http://localhost:3000/api/auth | ||
NEXTAUTH_SECRET= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.graphql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx pretty-quick --staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
save-exact=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { UserRole, User } from '@prisma/client' | ||
import { JWT, DefaultJWT } from 'next-auth/jwt' | ||
|
||
declare module 'next-auth/jwt' { | ||
interface JWT extends DefaultJWT { | ||
role: UserRole | ||
id: User['id'] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/types/global" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// @ts-check | ||
|
||
/** | ||
* @type {import('next').NextConfig} | ||
**/ | ||
module.exports = { | ||
reactStrictMode: true, | ||
images: { | ||
domains: ['avatars.githubusercontent.com'], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,55 @@ | ||
{ | ||
"name": "next-auth-prisma-template", | ||
"version": "0.0.1", | ||
"name": "nextjs-auth-prisma-template", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"author": { | ||
"name": "Lukáš Huvar", | ||
"email": "[email protected]", | ||
"url": "https://huvik.dev/" | ||
}, | ||
"scripts": { | ||
"build": "yarn generate:nexus && next build", | ||
"build": "yarn schema:generate && yarn hooks:generate && next build", | ||
"dev": "next", | ||
"start": "next start", | ||
"hooks:generate": "graphql-codegen --config .graphqlrc.yaml", | ||
"lint": "next lint", | ||
"postinstall": "yarn prisma generate && yarn generate:nexus", | ||
"generate:hooks": "graphql-codegen --config .graphqlrc.yaml", | ||
"generate:nexus": "ts-node --skip-project --transpile-only src/lib/nexus/schema --nexus-exit" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "pretty-quick --staged" | ||
} | ||
"postinstall": "yarn prisma generate", | ||
"schema:generate": "tsx src/lib/utils/build-schema.ts", | ||
"start": "next start", | ||
"prepare": "husky install" | ||
}, | ||
"dependencies": { | ||
"@next-auth/prisma-adapter": "^0.4.4-canary.64", | ||
"@prisma/client": "2.24", | ||
"graphql": "^15.5.0", | ||
"graphql-helix": "1.6.1", | ||
"next": "^11.0.0", | ||
"next-auth": "^3.27.0", | ||
"next-urql": "3.0.0", | ||
"nexus": "1.0.0", | ||
"nexus-prisma": "^0.28.0", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"react-is": "17.0.2", | ||
"urql": "2.0.2" | ||
"@graphql-yoga/node": "2.13.3", | ||
"@next-auth/prisma-adapter": "1.0.3", | ||
"@pothos/core": "3.13.0", | ||
"@pothos/plugin-prisma": "3.14.0", | ||
"@pothos/plugin-scope-auth": "3.11.0", | ||
"@prisma/client": "4.0.0", | ||
"graphql": "16.5.0", | ||
"next": "12.2.3", | ||
"next-auth": "4.10.0", | ||
"next-urql": "3.3.3", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"react-is": "18.2.0", | ||
"urql": "2.2.2" | ||
}, | ||
"devDependencies": { | ||
"@graphql-codegen/cli": "1.21.4", | ||
"@graphql-codegen/near-operation-file-preset": "^1.18.0", | ||
"@graphql-codegen/typed-document-node": "1.18.8", | ||
"@graphql-codegen/typescript": "1.21.0", | ||
"@graphql-codegen/typescript-operations": "1.17.15", | ||
"@graphql-codegen/typescript-urql": "2.0.3", | ||
"@graphql-typed-document-node/core": "3.1.0", | ||
"@types/next-auth": "3.1.26", | ||
"eslint": "^7.28.0", | ||
"eslint-config-next": "^11.0.0", | ||
"graphql-playground-html": "^1.6.29", | ||
"husky": "4.3.8", | ||
"prettier": "2.2.1", | ||
"pretty-quick": "3.1.0", | ||
"prisma": "2.24", | ||
"ts-node": "9.1.1", | ||
"typescript": "^4.3.4" | ||
"@graphql-codegen/cli": "^2.11.3", | ||
"@graphql-codegen/near-operation-file-preset": "2.4.0", | ||
"@graphql-codegen/typed-document-node": "2.3.2", | ||
"@graphql-codegen/typescript": "2.7.2", | ||
"@graphql-codegen/typescript-operations": "2.5.2", | ||
"@graphql-codegen/typescript-urql": "3.6.3", | ||
"@graphql-typed-document-node/core": "3.1.1", | ||
"@types/node": "18.6.3", | ||
"@types/react": "18.0.15", | ||
"eslint": "8.20.0", | ||
"eslint-config-next": "12.2.2", | ||
"husky": "^8.0.0", | ||
"prettier": "2.7.1", | ||
"pretty-quick": "3.1.3", | ||
"prisma": "4.0.0", | ||
"tsx": "3.8.0", | ||
"typescript": "4.7.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.