1
0
mirror of synced 2026-02-07 03:00:10 -05:00

Compare commits

..

5 Commits

Author SHA1 Message Date
Brandon Bayer
ef38a4008a ah, there it is 2022-04-26 14:04:02 -04:00
Brandon Bayer
a9a3167a0f fix more 2022-04-26 11:38:52 -04:00
Brandon Bayer
64c75087dc fix 2022-04-26 11:29:22 -04:00
Brandon Bayer
257b1e8b27 remove db 2022-04-26 11:23:30 -04:00
Brandon Bayer
2fc9ceeed7 make it work 2022-04-26 11:22:17 -04:00
322 changed files with 2499 additions and 11851 deletions

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/next": patch
"@blitzjs/generator": patch
---
add mounted check inside withBlitz

View File

@@ -1,7 +0,0 @@
---
"blitz": patch
"@blitzjs/next": patch
"@blitzjs/generator": patch
---
Fix codegen and postinstall to make work with pnpm

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/rpc": patch
---
Add queryClient to RPC Plugin exports

View File

@@ -7,5 +7,5 @@
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["web", "test-*", "toolkit-app"]
"ignore": ["web", "test-*"]
}

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/rpc": patch
---
Add invokeWithCtx function

View File

@@ -1,6 +0,0 @@
---
"blitz": patch
"@blitzjs/generator": patch
---
Use alpha version for blitz dependency, fix package manager selection

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/codemod": patch
"@blitzjs/generator": patch
---
codemod fixes

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/generator": patch
---
fix app generator for pnpm unmet dependency

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/next": patch
---
Use `useRouter` from next/router in useParams function

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/next": patch
---
added superjson

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/generator": patch
---
updated nextjs version in generator & npmrc file

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
Export Zod utils from blitz core package

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
set default enviornment variable to development unless build and start command

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/auth": patch
"@blitzjs/next": patch
---
Add missing RouteUrlObject on Page.authenticate.redirectTo

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/next": patch
---
export BlitzPage & BlitzLayout types from @blitzjs/next

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/codemod": patch
---
fix codemod for wrapping \_app arrow function & fix codemod for nested pages directory

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/codemod": patch
---
Update queryClient import in codemod

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/next": patch
---
Allow passing optional type argument for ParamsType in GSSP

View File

@@ -1,9 +0,0 @@
---
"blitz": patch
"@blitzjs/next": patch
"@blitzjs/auth": patch
"@blitzjs/rpc": patch
"@blitzjs/generator": patch
---
fix route manifest codegen

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/generator": patch
---
Update codemod and template with a new queryClient import location

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
detailed print env info

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/next": patch
"@blitzjs/generator": patch
---
Upgrade @types/react, fix typings inside @blitzjs/next

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/next": patch
"@blitzjs/rpc": patch
---
Support RPC error middleware

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/rpc": patch
"@blitzjs/generator": patch
---
Update Next.js version and addBasePath location

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
fix broken cli versioning

View File

@@ -1,7 +0,0 @@
---
"blitz": patch
"@blitzjs/auth": patch
"@blitzjs/next": patch
---
rename middleware type for blitz server plugin

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/next": patch
---
Support `prefetchBlitzQuery` in gSSP and gSP

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
test automated publish

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/next": patch
---
useParam & useParams functions now accessible from @blitzjs/next

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/codemod": patch
---
Move middlewares from blitz config to blitz server with codemod

View File

@@ -1,6 +0,0 @@
---
"blitz": patch
"@blitzjs/codemod": patch
---
Handle duplicate imports with Blitz upgrade-legacy codemod

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/generator": patch
---
add mounted check to app generator template

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/codemod": patch
---
Fix templates source in RPC codemod step

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/codemod": patch
---
Add codemod to upgrade from legacy framework to the Blitz Toolkit

View File

@@ -1,11 +0,0 @@
---
"blitz": patch
"@blitzjs/next": patch
"@blitzjs/generator": patch
---
- Add mounted check to withBlitz
- Upgrade @types/react, fix typings inside @blitzjs/next
- Support prefetchBlitzQuery in gSP and gSSP
- Add db seed cli command
- Add try/catch to changePassword mutation

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
add `db seed` cli command

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/next": patch
---
Setup SuperJson for GSSP and GSP

View File

@@ -12,84 +12,14 @@
"@blitzjs/rpc": "2.0.0-alpha.0",
"@blitzjs/config": "0.0.0",
"@blitzjs/generator": "2.0.0-alpha.0",
"@blitzjs/codemod": "2.0.0-alpha.0",
"template": "0.0.0",
"toolkit-app": "1.0.0",
"test-qm": "0.0.0",
"test-no-suspense": "0.0.0",
"test-trailing-slash": "0.0.0",
"test-middleware": "0.0.0"
"toolkit-app": "1.0.0"
},
"changesets": [
"big-phones-bow",
"breezy-cameras-double",
"bright-mangos-run",
"cool-doors-invent",
"dirty-monkeys-greet",
"eleven-humans-sort",
"empty-berries-rule",
"empty-turkeys-wave",
"fair-wombats-sneeze",
"famous-kings-explain",
"fast-trainers-kneel",
"flat-bees-approve",
"four-brooms-juggle",
"four-meals-fry",
"fuzzy-jars-admire",
"gentle-dogs-reply",
"good-insects-wink",
"great-months-train",
"green-papayas-do",
"healthy-rice-shout",
"hot-drinks-approve",
"late-steaks-give",
"lemon-games-press",
"lovely-colts-share",
"lucky-cows-try",
"modern-cameras-pull",
"moody-squids-cheer",
"nervous-beds-travel",
"nervous-dolls-rule",
"new-coats-turn",
"nice-starfishes-live",
"nine-onions-admire",
"ninety-pets-heal",
"olive-bees-buy",
"olive-feet-rhyme",
"plenty-bottles-swim",
"poor-peas-lick",
"poor-penguins-look",
"poor-shrimps-think",
"purple-singers-greet",
"quiet-feet-travel",
"quiet-pans-hunt",
"quiet-sloths-rule",
"rich-chairs-invent",
"rich-queens-travel",
"sharp-falcons-begin",
"shy-olives-hang",
"silent-colts-reply",
"slow-walls-poke",
"small-socks-confess",
"smooth-planets-admire",
"strong-apes-reply",
"stupid-walls-sell",
"swift-drinks-dress",
"tame-keys-reply",
"tasty-news-collect",
"ten-hairs-listen",
"ten-rivers-burn",
"tender-pianos-check",
"thick-parrots-float",
"thirty-countries-build",
"twenty-beans-pump",
"two-kiwis-help",
"two-tigers-type",
"unlucky-papayas-sleep",
"violet-bags-leave",
"violet-lions-help",
"weak-suns-shave",
"wicked-ghosts-cough",
"wise-frogs-give"
"twenty-beans-pump"
]
}

View File

@@ -1,7 +0,0 @@
---
"@blitzjs/rpc": patch
"@blitzjs/codemod": patch
"@blitzjs/generator": patch
---
getQueryClient function & queryClient codemod updates & shared plugin config

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/generator": patch
---
fix source path for templates

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/next": patch
---
Removes the suspense wrapper from withBlitz since it's not needed

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/next": patch
---
Removes the check for when withBlitz is mounted before rendering the users app. We had this previously to avoid the react 18 suspense error being showin in development with nextjs.

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/next": patch
---
Rename prefetchBlitzQuery to prefetchQuery, add prefetchInfiniteQuery

View File

@@ -1,8 +0,0 @@
---
"blitz": patch
"@blitzjs/auth": patch
"@blitzjs/next": patch
"@blitzjs/rpc": patch
---
Remove references to the logging package

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/generator": patch
---
Use routes manifest in template app

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/rpc": patch
"@blitzjs/generator": patch
---
Update RPC plugin setup in templates

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
added index.cjs to blitz externals

View File

@@ -1,6 +0,0 @@
---
"@blitzjs/next": patch
"@blitzjs/rpc": patch
---
Allow resolverPath to be a function which is ran for every file path that is converted to RPC Route

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/auth": patch
---
Add passport adapter to @blitzjs/auth

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/generator": patch
---
Add missing \_document.tsx and 404.tsx pages to the new app templates

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/generator": patch
---
Remove as any assertion for the PrismaStorage argument

View File

@@ -1,8 +0,0 @@
---
"blitz": patch
"@blitzjs/auth": patch
"@blitzjs/next": patch
"@blitzjs/rpc": patch
---
testing set dist-tag

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/next": patch
---
Fix postinstall script not being found

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
Add aliases for Blitz CLI commands

View File

@@ -1,6 +0,0 @@
---
"blitz": patch
"@blitzjs/codemod": patch
---
init codemod generator

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/next": patch
---
Allow customizing PreviewData in gSSP

View File

@@ -1,7 +0,0 @@
---
"blitz": patch
"@blitzjs/next": patch
"@blitzjs/generator": patch
---
various improvements and fixes

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/codemod": patch
---
allow extension catch in getAllFiles codemod util

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
add @blitzjs/generator as external

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
fix generate cli command

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
Fix running bin commands with Blitz CLI

View File

@@ -1,5 +0,0 @@
---
"blitz": patch
---
remove console logs inside onPostInstall in the new cli command

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/codemod": patch
---
Update templates directory for codemod

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/rpc": patch
---
Add resolverBasePath to Blitz config to change the way rpc routes are generated

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/next": patch
---
Move blitz config to next.config.js

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/generator": patch
---
fix template sourcepath because of new env variable

View File

@@ -1,5 +0,0 @@
---
"@blitzjs/generator": patch
---
use latest tag for generator template on rpc & auth packages

2
.github/CODEOWNERS vendored
View File

@@ -1,5 +1,5 @@
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
* @flybayer @beerose @dillonraphael
* @flybayer @beerose
packages/generator/templates**/* @flybayer

View File

@@ -1,58 +0,0 @@
name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: read
jobs:
release:
name: Release
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Creating .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Pre-publish
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
with:
version: 6.32.6
- run: pnpm install --no-frozen-lockfile
- run: pnpm build
- name: Create Release Pull Request
uses: blitz-js/changesets-action@main
with:
publish: pnpm release
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# - name: Github Release
# uses: release-drafter/release-drafter@v5.19.0
# with:
# config-name: release-drafter.yml
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2
.gitignore vendored
View File

@@ -62,10 +62,10 @@ examples/auth2
.idea
.ultra.cache.json
db.sqlite-journal
**/db/db.sqlite
test/integration/**/db.json
test/**/*/out
test/**/blitz-env.d.ts
examples/**/blitz-env.d.ts
.blitz**
*.sqlite

2
.npmrc
View File

@@ -1,9 +1,7 @@
save-exact=true
strict-peer-dependencies=false
public-hoist-pattern[]=secure-password
public-hoist-pattern[]=*types*
public-hoist-pattern[]=*eslint*
public-hoist-pattern[]=@prettier/plugin-*
public-hoist-pattern[]=*prettier-plugin-*
strict-peer-dependencies=false

View File

@@ -174,7 +174,6 @@ Your financial contributions help ensure Blitz continues to be developed and mai
<tr>
<td align="center"><a href="https://twitter.com/flybayer"><img src="https://avatars3.githubusercontent.com/u/8813276?v=4" width="100px;" alt=""/><br /><sub><b>Brandon Bayer</b></sub></a><br />Creator</td>
<td align="center"><a href="http://aleksandra.codes"><img src="https://avatars.githubusercontent.com/u/9019397?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aleksandra Sikora</b></sub></a><br />Lead Maintainer</td>
<td align="center"><a href="http://twitter.com/dillonraphael"><img src="https://avatars.githubusercontent.com/u/3496193?v=4" width="100px;" alt=""/><br /><sub><b>Dillon Raphael</b></sub></a><br />Senior Maintainer</td>
</tr>
</table>

View File

@@ -1 +1 @@
module.exports = require("@blitzjs/next/eslint")
module.exports = require("@blitzjs/config/eslint")

View File

@@ -1,178 +1,5 @@
# toolkit-app
## 1.0.1-alpha.16
### Patch Changes
- blitz@2.0.0-alpha.21
- @blitzjs/auth@2.0.0-alpha.21
- @blitzjs/next@2.0.0-alpha.21
- @blitzjs/rpc@2.0.0-alpha.21
- @blitzjs/config@2.0.0-alpha.21
## 1.0.1-alpha.15
### Patch Changes
- Updated dependencies
- blitz@2.0.0-alpha.20
- @blitzjs/auth@2.0.0-alpha.20
- @blitzjs/next@2.0.0-alpha.20
- @blitzjs/rpc@2.0.0-alpha.20
- @blitzjs/config@2.0.0-alpha.20
## 1.0.1-alpha.14
### Patch Changes
- Updated dependencies
- Updated dependencies [2150dcc3]
- @blitzjs/next@2.0.0-alpha.19
- blitz@2.0.0-alpha.19
- @blitzjs/auth@2.0.0-alpha.19
- @blitzjs/rpc@2.0.0-alpha.19
- @blitzjs/config@2.0.0-alpha.19
## 1.0.1-alpha.13
### Patch Changes
- Updated dependencies
- blitz@2.0.0-alpha.18
- @blitzjs/auth@2.0.0-alpha.18
- @blitzjs/next@2.0.0-alpha.18
- @blitzjs/rpc@2.0.0-alpha.18
- @blitzjs/config@2.0.0-alpha.18
## 1.0.1-alpha.12
### Patch Changes
- blitz@2.0.0-alpha.17
- @blitzjs/auth@2.0.0-alpha.17
- @blitzjs/next@2.0.0-alpha.17
- @blitzjs/rpc@2.0.0-alpha.17
- @blitzjs/config@2.0.0-alpha.17
## 1.0.1-alpha.11
### Patch Changes
- Updated dependencies
- blitz@2.0.0-alpha.16
- @blitzjs/auth@2.0.0-alpha.16
- @blitzjs/next@2.0.0-alpha.16
- @blitzjs/rpc@2.0.0-alpha.16
- @blitzjs/config@2.0.0-alpha.16
## 1.0.1-alpha.10
### Patch Changes
- blitz@2.0.0-alpha.15
- @blitzjs/auth@2.0.0-alpha.15
- @blitzjs/next@2.0.0-alpha.15
- @blitzjs/rpc@2.0.0-alpha.15
- @blitzjs/config@2.0.0-alpha.15
## 1.0.1-alpha.9
### Patch Changes
- Updated dependencies
- blitz@2.0.0-alpha.14
- @blitzjs/auth@2.0.0-alpha.14
- @blitzjs/next@2.0.0-alpha.14
- @blitzjs/rpc@2.0.0-alpha.14
- @blitzjs/config@2.0.0-alpha.14
## 1.0.1-alpha.8
### Patch Changes
- Updated dependencies
- blitz@2.0.0-alpha.13
- @blitzjs/next@2.0.0-alpha.13
- @blitzjs/auth@2.0.0-alpha.13
- @blitzjs/rpc@2.0.0-alpha.13
- @blitzjs/config@2.0.0-alpha.13
## 1.0.1-alpha.7
### Patch Changes
- Updated dependencies
- blitz@2.0.0-alpha.12
- @blitzjs/auth@2.0.0-alpha.12
- @blitzjs/next@2.0.0-alpha.12
- @blitzjs/rpc@2.0.0-alpha.12
- @blitzjs/config@2.0.0-alpha.12
## 1.0.1-alpha.6
### Patch Changes
- Updated dependencies
- @blitzjs/next@2.0.0-alpha.11
- @blitzjs/auth@2.0.0-alpha.11
- @blitzjs/rpc@2.0.0-alpha.11
- @blitzjs/config@2.0.0-alpha.11
- blitz@2.0.0-alpha.11
## 1.0.1-alpha.5
### Patch Changes
- blitz@2.0.0-alpha.10
- @blitzjs/auth@2.0.0-alpha.10
- @blitzjs/next@2.0.0-alpha.10
- @blitzjs/rpc@2.0.0-alpha.10
- @blitzjs/config@2.0.0-alpha.10
## 1.0.1-alpha.4
### Patch Changes
- Updated dependencies
- blitz@2.0.0-alpha.9
- @blitzjs/auth@2.0.0-alpha.9
- @blitzjs/next@2.0.0-alpha.9
- @blitzjs/rpc@2.0.0-alpha.9
- @blitzjs/config@2.0.0-alpha.9
## 1.0.1-alpha.3
### Patch Changes
- Updated dependencies
- blitz@2.0.0-alpha.8
- @blitzjs/auth@2.0.0-alpha.8
- @blitzjs/next@2.0.0-alpha.8
- @blitzjs/rpc@2.0.0-alpha.8
- @blitzjs/config@2.0.0-alpha.8
## 1.0.1-alpha.2
### Patch Changes
- Updated dependencies
- blitz@2.0.0-alpha.7
- @blitzjs/auth@2.0.0-alpha.7
- @blitzjs/next@2.0.0-alpha.7
- @blitzjs/rpc@2.0.0-alpha.7
- @blitzjs/config@2.0.0-alpha.7
## 1.0.1-alpha.1
### Patch Changes
- Updated dependencies
- @blitzjs/next@2.0.0-alpha.6
- blitz@2.0.0-alpha.6
- @blitzjs/auth@2.0.0-alpha.6
- @blitzjs/rpc@2.0.0-alpha.6
- @blitzjs/config@2.0.0-alpha.6
## 1.0.1-alpha.0
### Patch Changes

View File

@@ -5,7 +5,6 @@ import { Form, FORM_ERROR } from "app/core/components/Form"
import login from "app/auth/mutations/login"
import { Login } from "app/auth/validations"
import { useMutation } from "@blitzjs/rpc"
import { Routes } from "@blitzjs/next"
type LoginFormProps = {
onSuccess?: (user: PromiseReturnType<typeof login>) => void
@@ -40,7 +39,7 @@ export const LoginForm = (props: LoginFormProps) => {
<LabeledTextField name="email" label="Email" placeholder="Email" />
<LabeledTextField name="password" label="Password" placeholder="Password" type="password" />
<div>
<Link href={Routes.ForgotPasswordPage()} passHref>
<Link href="/auth/forgot-password" passHref>
<a>Forgot your password?</a>
</Link>
</div>
@@ -48,7 +47,7 @@ export const LoginForm = (props: LoginFormProps) => {
<div style={{ marginTop: "1rem" }}>
Or{" "}
<Link href={Routes.SignupPage()} passHref>
<Link href="/auth/signup" passHref>
<a>Sign Up</a>
</Link>
</div>

View File

@@ -1,5 +1,5 @@
import { NotFoundError } from "blitz"
import db from "db"
import { prisma as db } from "db"
import { authenticateUser } from "./login"
import { ChangePassword } from "../validations"
import { resolver } from "@blitzjs/rpc"

View File

@@ -1,6 +1,6 @@
import { generateToken, hash256 } from "@blitzjs/auth"
import { resolver } from "@blitzjs/rpc"
import db from "db"
import { prisma as db } from "db"
import { forgotPasswordMailer } from "mailers/forgotPasswordMailer"
import { ForgotPassword } from "../validations"

View File

@@ -1,7 +1,7 @@
import { SecurePassword } from "@blitzjs/auth"
import { resolver } from "@blitzjs/rpc"
import { AuthenticationError } from "blitz"
import db from "db"
import { prisma as db, User } from "db"
import { Role } from "types"
import { Login } from "../validations"

View File

@@ -1,5 +1,5 @@
import { SecurePassword, hash256 } from "@blitzjs/auth"
import db from "db"
import { prisma } from "db"
import { ResetPassword } from "../validations"
import login from "./login"
@@ -12,7 +12,7 @@ export default async function resetPassword(input, ctx) {
ResetPassword.parse(input)
// 1. Try to find this token in the database
const hashedToken = hash256(input.token)
const possibleToken = await db.token.findFirst({
const possibleToken = await prisma.token.findFirst({
where: { hashedToken, type: "RESET_PASSWORD" },
include: { user: true },
})
@@ -24,7 +24,7 @@ export default async function resetPassword(input, ctx) {
const savedToken = possibleToken
// 3. Delete token so it can't be used again
await db.token.delete({ where: { id: savedToken.id } })
await prisma.token.delete({ where: { id: savedToken.id } })
// 4. If token has expired, error
if (savedToken.expiresAt < new Date()) {
@@ -33,13 +33,13 @@ export default async function resetPassword(input, ctx) {
// 5. Since token is valid, now we can update the user's password
const hashedPassword = await SecurePassword.hash(input.password.trim())
const user = await db.user.update({
const user = await prisma.user.update({
where: { id: savedToken.userId },
data: { hashedPassword },
})
// 6. Revoke all existing login sessions for this user
await db.session.deleteMany({ where: { userId: user.id } })
await prisma.session.deleteMany({ where: { userId: user.id } })
// 7. Now log the user in with the new credentials
await login({ email: user.email, password: input.password }, ctx)

View File

@@ -1,20 +1,18 @@
import db from "db"
import { prisma } from "db"
import { SecurePassword } from "@blitzjs/auth"
import { Role } from "types"
export default async function signup(input, ctx) {
const blitzContext = ctx
const hashedPassword = await SecurePassword.hash((input.password as string) || "test-password")
const email = (input.email as string) || "test" + Math.random() + "@test.com"
const user = await db.user.create({
const user = await prisma.user.create({
data: { email, hashedPassword, role: "user" },
select: { id: true, name: true, email: true, role: true },
})
await blitzContext.session.$create({
userId: user.id,
role: user.role as Role,
})
return { userId: blitzContext.session.userId, ...user, email: input.email }

View File

@@ -2,11 +2,19 @@ import { AuthClientPlugin } from "@blitzjs/auth"
import { setupBlitzClient } from "@blitzjs/next"
import { BlitzRpcPlugin } from "@blitzjs/rpc"
export const { withBlitz } = setupBlitzClient({
const { withBlitz } = setupBlitzClient({
plugins: [
AuthClientPlugin({
cookiePrefix: "web-cookie-prefix",
}),
BlitzRpcPlugin({}),
BlitzRpcPlugin({
reactQueryOptions: {
queries: {
staleTime: 7000,
},
},
}),
],
})
export { withBlitz }

View File

@@ -1,13 +1,14 @@
import { setupBlitzServer } from "@blitzjs/next"
import { AuthServerPlugin, PrismaStorage } from "@blitzjs/auth"
import db from "db"
import { prisma as db } from "../db/index"
import { simpleRolesIsAuthorized } from "@blitzjs/auth"
const { gSSP, gSP, api } = setupBlitzServer({
plugins: [
AuthServerPlugin({
cookiePrefix: "web-cookie-prefix",
storage: PrismaStorage(db),
// TODO fix type
storage: PrismaStorage(db as any),
isAuthorized: simpleRolesIsAuthorized,
}),
],

View File

@@ -1,10 +1,10 @@
import { Ctx } from "blitz"
import db from "db"
import { prisma } from "db"
export default async function getCurrentUser(_ = null, { session }: Ctx) {
if (!session.userId) return null
const user = await db.user.findFirst({
const user = await prisma.user.findFirst({
where: { id: session.userId as number },
select: { id: true, name: true, email: true, role: true },
})

View File

@@ -4,5 +4,5 @@ import { PrismaClient } from "@prisma/client"
const EnhancedPrisma = enhancePrisma(PrismaClient)
export * from "@prisma/client"
const db = new EnhancedPrisma()
export default db
const prisma = new EnhancedPrisma()
export { prisma }

View File

@@ -1,4 +1,4 @@
import db from "./index"
// import db from "./index"
/*
* This seed function is executed when you run `blitz db seed`.
@@ -7,15 +7,9 @@ import db from "./index"
* to easily generate realistic data.
*/
const seed = async () => {
await db.$reset()
for (let i = 0; i < 1; i++) {
await db.user.create({
data: {
email: "test@test.com",
},
})
}
// for (let i = 0; i < 5; i++) {
// await db.project.create({ data: { name: "Project " + i } })
// }
}
export default seed

View File

@@ -1,9 +1,9 @@
{
"name": "toolkit-app",
"version": "1.0.1-alpha.16",
"version": "1.0.1-alpha.0",
"scripts": {
"start:dev": "pnpm run prisma:start && next dev",
"buildapp": "NODE_ENV=production pnpm blitz codegen && pnpm prisma generate && next build",
"buildapp": "prisma generate && next build",
"start": "next start",
"lint": "next lint",
"prisma:start": "prisma generate && prisma migrate deploy",
@@ -29,14 +29,15 @@
"@blitzjs/rpc": "workspace:*",
"@hookform/resolvers": "2.8.8",
"@prisma/client": "3.9.0",
"blitz": "workspace:2.0.0-alpha.50",
"next": "12.2.0",
"blitz": "workspace:2.0.0-alpha.5",
"next": "12.1.1",
"prisma": "3.9.0",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-hook-form": "7.29.0",
"styled-jsx": "5.0.2",
"ts-node": "10.7.0",
"zod": "3.17.3"
"zod": "3.10.1"
},
"devDependencies": {
"@next/bundle-analyzer": "12.0.8",
@@ -45,7 +46,7 @@
"@types/jest": "27.4.1",
"@types/node": "17.0.16",
"@types/preview-email": "2.0.1",
"@types/react": "18.0.1",
"@types/react": "17.0.43",
"eslint": "7.32.0",
"husky": "7.0.4",
"jest": "27.5.1",

View File

@@ -1,20 +0,0 @@
import Head from "next/head"
import { ErrorComponent } from "@blitzjs/next"
// ------------------------------------------------------
// This page is rendered if a route match is not found
// ------------------------------------------------------
export default function Page404() {
const statusCode = 404
const title = "This page could not be found"
return (
<>
<Head>
<title>
{statusCode}: {title}
</title>
</Head>
<ErrorComponent statusCode={statusCode} title={title} />
</>
)
}

View File

@@ -1,6 +1,7 @@
import { ErrorFallbackProps, ErrorComponent, ErrorBoundary, AppProps } from "@blitzjs/next"
import { ErrorFallbackProps, ErrorComponent, ErrorBoundary } from "@blitzjs/next"
import { AuthenticationError, AuthorizationError } from "blitz"
import React from "react"
import type { AppProps } from "next/app"
import React, { Suspense } from "react"
import { withBlitz } from "app/blitz-client"
function RootErrorFallback({ error }: ErrorFallbackProps) {
@@ -26,7 +27,9 @@ function RootErrorFallback({ error }: ErrorFallbackProps) {
function MyApp({ Component, pageProps }: AppProps) {
return (
<ErrorBoundary FallbackComponent={RootErrorFallback}>
<Component {...pageProps} />
<Suspense fallback="Loading...">
<Component {...pageProps} />
</Suspense>
</ErrorBoundary>
)
}

View File

@@ -1,22 +0,0 @@
import Document, { Html, Main, NextScript, Head } from "next/document"
class MyDocument extends Document {
// Only uncomment if you need to customize this behaviour
// static async getInitialProps(ctx: DocumentContext) {
// const initialProps = await Document.getInitialProps(ctx)
// return {...initialProps}
// }
render() {
return (
<Html lang="en">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default MyDocument

View File

@@ -1,14 +1,13 @@
import { useRouter } from "next/router"
import Layout from "app/core/layouts/Layout"
import { SignupForm } from "app/auth/components/SignupForm"
import { Routes } from "@blitzjs/next"
const SignupPage = () => {
const router = useRouter()
return (
<Layout title="Sign Up">
<SignupForm onSuccess={() => router.push(Routes.Home())} />
<SignupForm onSuccess={() => router.push("/")} />
</Layout>
)
}

View File

@@ -6,7 +6,6 @@ import { useCurrentUser } from "app/core/hooks/useCurrentUser"
import logout from "app/auth/mutations/logout"
import logo from "public/logo.png"
import { useMutation } from "@blitzjs/rpc"
import { Routes } from "@blitzjs/next"
/*
* This file is just for a pleasant getting started page for your new app.
@@ -38,12 +37,12 @@ const UserInfo = () => {
} else {
return (
<>
<Link href={Routes.SignupPage()} passHref>
<Link href="/auth/signup" passHref>
<a className="button small">
<strong>Sign Up</strong>
</a>
</Link>
<Link href={Routes.LoginPage()} passHref>
<Link href="/auth/login" passHref>
<a className="button small">
<strong>Login</strong>
</a>

View File

@@ -2,7 +2,7 @@
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"baseUrl": ".",
"baseUrl": "./",
"allowJs": true,
"skipLibCheck": true,
"strict": false,

View File

@@ -1,13 +1,14 @@
import {setupBlitzServer} from "@blitzjs/next"
import {AuthServerPlugin, PrismaStorage} from "@blitzjs/auth"
import db from "db"
import {prisma as db} from "../prisma/index"
import {simpleRolesIsAuthorized} from "@blitzjs/auth"
const {gSSP, gSP, api} = setupBlitzServer({
plugins: [
AuthServerPlugin({
cookiePrefix: "webapp-cookie-prefix",
storage: PrismaStorage(db),
// TODO fix type
storage: PrismaStorage(db as any),
isAuthorized: simpleRolesIsAuthorized,
}),
],

View File

@@ -1,5 +1,6 @@
import {Ctx} from "blitz"
import db, {User} from "db"
import {prisma} from "../../prisma"
import {User} from "prisma"
export default async function createUser(
input: {name: string; email: string},
@@ -7,7 +8,7 @@ export default async function createUser(
): Promise<User> {
ctx.session.$authorize()
const user = await db.user.create({data: {name: input.name, email: input.email}})
const user = await prisma.user.create({data: {name: input.name, email: input.email}})
return user
}

View File

@@ -1,27 +0,0 @@
import {resolver} from "@blitzjs/rpc"
import {paginate} from "blitz"
import db, {Prisma} from "db"
interface GetUsersInput
extends Pick<Prisma.UserFindManyArgs, "where" | "orderBy" | "skip" | "take"> {}
export default resolver.pipe(async ({where, orderBy, skip = 0, take = 100}: GetUsersInput) => {
const {
items: users,
hasMore,
nextPage,
count,
} = await paginate({
skip,
take,
count: () => db.user.count({where}),
query: (paginateArgs) => db.user.findMany({...paginateArgs, where, orderBy}),
})
return {
users,
nextPage,
hasMore,
count,
}
})

View File

@@ -1,10 +1,11 @@
import {Ctx} from "blitz"
import db, {User} from "db"
import {prisma} from "../../prisma"
import {User} from "prisma"
export default async function getUsers(_input: {}, ctx: Ctx): Promise<User[]> {
ctx.session.$authorize()
const users = await db.user.findMany()
const users = await prisma.user.findMany()
return users
}

View File

@@ -1,8 +0,0 @@
import {resolver} from "@blitzjs/rpc"
import db from "db"
export default resolver.pipe(resolver.authorize(), async () => {
const users = await db.user.findMany()
return users
})

View File

@@ -1,8 +0,0 @@
import {enhancePrisma} from "blitz"
import {PrismaClient} from "@prisma/client"
const EnhancedPrisma = enhancePrisma(PrismaClient)
export * from "@prisma/client"
const prisma = new EnhancedPrisma()
export default prisma

Some files were not shown because too many files have changed in this diff Show More