1
0
mirror of synced 2026-02-03 18:01:02 -05:00

Compare commits

...

144 Commits

Author SHA1 Message Date
github-actions[bot]
ac9c4cebc8 Version Packages (alpha) (#3514)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-07-07 15:43:57 +02:00
Dillon Raphael
a7e37c58db Export BlitzProvider from blitz-next (#3513)
Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-07-07 15:36:52 +02:00
Brandon Bayer
b0d2505a85 Update CODEOWNERS 2022-07-06 23:54:29 +02:00
github-actions[bot]
024cd819e3 Version Packages (alpha) (#3512)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-07-06 19:25:31 +02:00
Dillon Raphael
12cb7a727d Upgrade Prisma to v4.0.0 (#3511)
* Upgrade Prisma to v4.0.0

* Changeset
2022-07-06 19:21:36 +02:00
github-actions[bot]
923703b661 Version Packages (alpha) (#3510)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-07-06 18:26:09 +02:00
Dillon Raphael
70f9ae4921 Handle next/dynamic default import in codemod (#3509) 2022-07-06 18:21:45 +02:00
beerose
c738ecacbc Remove --tag option from release script 2022-07-06 17:07:55 +02:00
github-actions[bot]
ad0b087d9f Version Packages (alpha) (#3507)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-07-06 16:03:29 +02:00
Dillon Raphael
dc694cf1cf remove mounted check from withBlitz (#3504)
Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-07-06 15:59:18 +02:00
Aleksandra
4c221b655e Tag @blitzjs/rpc and @blitzjs/auth with alpha, update package.json files (#3508) 2022-07-06 13:56:25 +02:00
Aleksandra
c11f0401cf Update Next.js version and addBasePath location (#3506) 2022-07-06 13:14:48 +02:00
github-actions[bot]
830b51d0dc Version Packages (alpha) (#3492)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-07-04 17:39:14 +02:00
David
bec9512e30 Expand & rename baseResolverPath (#3421)
Co-authored-by: beerose <alexsandra.sikora@gmail.com>
2022-07-04 17:35:36 +02:00
Dillon Raphael
1493729d6b forked changesets action 2022-07-04 16:48:30 +02:00
Dillon Raphael
6bb5980da9 revert changesets action version 2022-07-04 15:44:21 +02:00
Dillon Raphael
7310f7171d use forked changesets github action 2022-07-04 15:32:28 +02:00
github-actions[bot]
d855ee3e1d Version Packages (alpha) (#3487)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-07-04 13:29:42 +02:00
Aleksandra
93851d90ca Handle duplicated imports with Blitz codemod (#3486) 2022-07-04 13:25:44 +02:00
beerose
3ab05b3cda Update pnpm-lock.yaml 2022-07-01 17:07:36 +02:00
github-actions[bot]
bb3dd56f7a Version Packages (alpha) (#3482)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-07-01 17:06:10 +02:00
Aleksandra
1d9804a610 remove references to the logging package (#3474) 2022-07-01 17:01:41 +02:00
Aleksandra
0fd1f9c9b1 Revert codemod changes (#3483) 2022-07-01 16:10:28 +02:00
Aleksandra
b86b569d56 Remove as any assertion for the PrismaStorage argument (#3481) 2022-07-01 16:04:58 +02:00
Aleksandra
b405c1e876 Add missing _document and 404 pages to the templates (#3480) 2022-07-01 12:44:37 +02:00
Dillon Raphael
c957828ea6 remove release-drafter 2022-06-30 11:54:31 +02:00
Dillon Raphael
c78e5c4704 set config name in release action 2022-06-30 11:47:58 +02:00
Dillon Raphael
009664e0f5 Merge branch 'main' of github.com:blitz-js/blitz 2022-06-30 11:33:42 +02:00
Dillon Raphael
3110522dca release drafter template 2022-06-30 11:33:32 +02:00
github-actions[bot]
7269ac2bc5 Version Packages (alpha) (#3472)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-30 11:09:25 +02:00
Datner
7a7ce2229e Add middleware integration tests (#3411)
* Set up middleware integration test application

* Add middleware integration test

* Update pnpm lock

Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-06-30 11:05:30 +02:00
Dillon Raphael
10c23d3d20 Merge branch 'main' of github.com:blitz-js/blitz 2022-06-29 13:03:54 +02:00
Dillon Raphael
d93b05d0ac Add github release template 2022-06-29 13:03:41 +02:00
Dillon Raphael
aafdc5b4c4 Codemod: Move middlewares from blitz config to blitz server (#3471)
Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-06-29 12:52:56 +02:00
Dillon Raphael
37ef42811b Merge branch 'main' of github.com:blitz-js/blitz 2022-06-29 12:24:44 +02:00
Dillon Raphael
34cc29e40c Turn off auto github releases 2022-06-29 12:24:26 +02:00
Fran Zekan
bee19a259d Hook up onError function for rpc server and next (#3460)
Co-authored-by: beerose <alexsandra.sikora@gmail.com>
2022-06-29 12:18:22 +02:00
Fran Zekan
9ada0f6661 Allow customizing PreviewData in gSSP (#3461) 2022-06-29 11:42:41 +02:00
Dillon Raphael
425559d360 pnpm install without frozen lockfile for github release action 2022-06-29 10:40:12 +02:00
Dillon Raphael
0411689b1d pnpmlock 2022-06-26 06:28:07 -04:00
github-actions[bot]
0d3514cd27 Version Packages (alpha) (#3464)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-26 06:18:37 -04:00
Dillon Raphael
a9edde6d83 pnpmlock 2022-06-26 06:05:38 -04:00
Dillon Raphael
5c5decbce2 Remove suspense wrapper from withBlitz (#3463)
* remove suspense wrapper

* changeset
2022-06-26 06:02:45 -04:00
beerose
e476beba39 Update pnpm-lock.yaml 2022-06-23 17:00:27 +02:00
github-actions[bot]
1a1b23a7e8 Version Packages (alpha) (#3459)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-23 16:59:54 +02:00
Fran Zekan
ae0b714f69 Expanding types for GetServerSideProps (#3457)
Co-authored-by: beerose <alexsandra.sikora@gmail.com>
2022-06-23 16:56:41 +02:00
Aleksandra
7817fe3a85 Add missing RouteUrlObject on Page.authenticate.redirectTo (#3458) 2022-06-23 16:45:27 +02:00
beerose
30bb474abb Update pnpm-lock.yaml 2022-06-23 13:32:30 +02:00
github-actions[bot]
135b30efde Version Packages (alpha) (#3456)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-23 13:31:59 +02:00
Aleksandra
527e48ac3e Fix running bin commands with Blitz CLI (#3455) 2022-06-23 13:29:22 +02:00
beerose
b905270875 Update pnpm-lock.yaml 2022-06-23 12:56:21 +02:00
github-actions[bot]
96ea5291e4 Version Packages (alpha) (#3454)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-23 12:54:23 +02:00
Aleksandra
9c2e7d372c Import useRouter form next/router in useParams.tsx (#3453) 2022-06-23 12:47:01 +02:00
beerose
493d505b24 Update pnpm-lock 2022-06-22 12:12:57 +02:00
github-actions[bot]
09da992bef Version Packages (alpha) (#3450)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-22 12:11:54 +02:00
Dillon Raphael
bbac7906e8 fix codemod for wrapping \_app arrow function and nested pages directory (#3443)
Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-06-22 10:55:35 +02:00
Dillon Raphael
21ca3a9b02 pnpmlock 2022-06-21 10:27:09 -04:00
github-actions[bot]
32274803d9 Version Packages (alpha) (#3449)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-21 10:25:53 -04:00
Dillon Raphael
9ded8dacba Export useParam & useParams from @blitzjs/next (#3448) 2022-06-21 14:45:29 +02:00
beerose
80ffbeaa4c Update pnpm-lock.yaml 2022-06-19 18:20:49 +02:00
github-actions[bot]
6bde1b07da Version Packages (alpha) (#3445)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-19 18:18:57 +02:00
Datner
b918055bf3 Add aliases for Blitz CLI commands (#3410)
Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-06-19 18:13:43 +02:00
Aleksandra
f9a2971f05 Improve typings in blitz cli package (#3444) 2022-06-19 15:48:27 +02:00
Dillon Raphael
72b08f2269 pnpmlock 2022-06-13 15:45:47 -04:00
github-actions[bot]
2124a4d0c5 Version Packages (alpha) (#3440)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-13 15:41:12 -04:00
Dillon Raphael
8aee25c58a changeset 2022-06-13 15:37:27 -04:00
Dillon Raphael
f1003faf94 update generator template (#3439) 2022-06-13 15:35:38 -04:00
Andreas Asprou
50468a3bb0 Fix duplicate react-query clients (#3431)
* Fix duplicate react-query clients

* fix tests

* add codemod & remove queryClient export from generator templates

Co-authored-by: Dillon Raphael <dillon@creatorsneverdie.com>
2022-06-13 11:07:41 -04:00
Dillon Raphael
891d91bf4d pnpmlock 2022-06-10 16:19:50 -04:00
github-actions[bot]
f96c953457 Version Packages (alpha) (#3430)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-10 16:18:48 -04:00
Dillon Raphael
a80d2a8f77 Rename Blitz server plugin type from Middleware to RequestMiddleware (#3428)
* rename to requestMiddleware

* update plugins

* merge main

* changeset
2022-06-10 16:14:21 -04:00
beerose
b336ad05f4 Update pnpm-lock.yaml 2022-06-10 11:32:17 -07:00
github-actions[bot]
39ca0ef8bf Version Packages (alpha) (#3429)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-10 11:31:27 -07:00
Aleksandra
4cad9cca25 Add queryClient to RPC plugin exports (#3424) 2022-06-10 10:18:50 -07:00
Dillon Raphael
b6fc940bf2 pnpmlock 2022-06-10 11:21:33 -04:00
github-actions[bot]
a946dd5889 Version Packages (alpha) (#3427)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-10 11:20:25 -04:00
Dillon Raphael
e3750b049d Codemod fixes (#3420)
* change BlitzApiRequest to NextApiRequest & update import map & fail catch for custom server

* fix page consolidation when there are sub directories

* Update prisma db export/import

* Update db imports in templates

* update root types file

* update error messages + merge main + changeset

Co-authored-by: beerose <alexsandra.sikora@gmail.com>
2022-06-10 11:16:18 -04:00
Dillon Raphael
fb01cc7788 pnpmlock 2022-06-10 10:34:59 -04:00
github-actions[bot]
ac8c412da2 Version Packages (alpha) (#3419)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-10 10:31:19 -04:00
David
dfd2408e95 Added resolverBasePath option to rpc loaders (#3380)
Co-authored-by: beerose <alexsandra.sikora@gmail.com>
2022-06-08 14:50:00 -07:00
Dillon Raphael
9741287050 pnpmlock 2022-06-07 18:28:53 -04:00
github-actions[bot]
0e9c81abdc Version Packages (alpha) (#3409)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-07 18:28:29 -04:00
Dillon Raphael
9e05d6e155 Filter file extensions in codemod (#3408)
* add allowedExt to getAllFiles for codemod

* pnpmlock

* codemod
2022-06-07 18:24:10 -04:00
beerose
17f70e65ef Update pnpm-lock.yaml 2022-06-07 13:21:28 -07:00
github-actions[bot]
0ddc5a8169 Version Packages (alpha) (#3407)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-07 13:20:44 -07:00
Aleksandra
e6fb09d494 Use dist/templates for rpc template (#3406) 2022-06-07 13:02:13 -07:00
beerose
d846fc6be9 Update pnpm-lock.yaml 2022-06-07 11:47:05 -07:00
github-actions[bot]
f5e80e3835 Version Packages (alpha) (#3405)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-07 11:46:31 -07:00
Aleksandra
17ce29e5e4 Update rpc plugin setup in templates (#3404) 2022-06-07 11:33:06 -07:00
Aleksandra
46d9f81adf Update templates directory for codemod (#3402) 2022-06-07 11:04:34 -07:00
Dillon Raphael
994cfc6292 pnpmlock 2022-06-07 12:09:09 -04:00
github-actions[bot]
7811748526 Version Packages (alpha) (#3401)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-07 12:08:45 -04:00
Dillon Raphael
ce45368334 Add codemods to upgrade from framework to toolkit (#3353)
* init migrate cli command

* make sure migrate command can only be run in legacy blitz directory

* extract codemods into its own package/cli

* removed unused dependencies

* renamed codemods bin directory

* update next.config file to use withBlitz

* codemods update package.json step

* codemod for blitz server & client setup, as well as the blitz rpc route in pages dir

* fix ignore previous step if statement to check for less than instead of equal

* move files from app/pages to root pages directory

* remove blitz babel plugin & update imports inside app dir

* consolidate pages from app dir to root pages dir

* move all api directories to the root pages dir

* use generator templates for blitz rpc route & server/client setup files

* update custom server file

* make custom server step work with require statement & import statements

* useRouterQuery to useRouter().query

* pkg dependecy & import map updates

* Change import map

* Add BlitzLayout to import map

* import withBlitz and wrap App function in _app

* modify _document to use next.js imports

* fix default import for next modules & add useParam to source map

* gssp/gsp

* api routes

* dont run api wrap on rpc/[[...blitz]] & error on usage of local middleware

* DRY cleanup

* update codemod steps

* add ignore extension to getAllFiles

* add more imports to source map

* check for invokeWithMiddleware

* add error counter to middleware checker

* rename codemod & fix silly typo error

* update bin file & change all invokeWithMiddleware to invoke

* add logging from blitz

* manypkg fix

* add codemod test

* lockfile

* fix test

* show errors for invokeWithMiddleware

* update invokeWithMiddleware error message

* line break in new app generator before your new blitz app is ready

* Apply suggestions from code review

* Add changeset

* changeset

* pnpmlock

Co-authored-by: beerose <alexsandra.sikora@gmail.com>
2022-06-07 12:03:37 -04:00
Dillon Raphael
4e9c1f60b6 pnpm lock 2022-06-07 11:36:45 -04:00
github-actions[bot]
508682c8f8 Version Packages (alpha) (#3400)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-07 11:35:42 -04:00
Dillon Raphael
962eb58af6 Migrate printEnvInfo to CLI (#3394)
* init printEnvInfo function

* changeset
2022-06-07 11:31:56 -04:00
Dillon Raphael
17669b3af8 pnpmlock 2022-06-07 11:06:31 -04:00
github-actions[bot]
ec6299c36a Version Packages (alpha) (#3399)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-07 11:05:15 -04:00
Dillon Raphael
6ac2d3412a Update generator template npmrc & next versions (#3398)
* add strict-peer-dependencies=false
side-effects-cache=false to npmrc generator template

* add comment to generated npmrc file

* update versions of next for full and minimal templates

* pinned next version to 12.1.6 in generator templates

* add next back to root package

* fix lock file

* add changeset

Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-06-07 10:59:28 -04:00
Dillon Raphael
85f9959d1f update pnpm lock file 2022-06-07 10:23:51 -04:00
github-actions[bot]
354f0440d6 Version Packages (alpha) (#3392)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-07 10:21:41 -04:00
Dillon Raphael
ac365a0656 No suspense test and Trailing slash test (#3390)
* no suspense test and trailing slash test

* use playwright for integration tests

* remove seed from server mode test in auth integration

* change pkg-dir version for blitz cli

* use pkg-dir 5.0.0

* clean up

* move seed location in auth test

* explict timeout for auth test

Co-authored-by: beerose <alexsandra.sikora@gmail.com>
2022-06-01 20:54:29 -04:00
Aleksandra
0729291099 Add invokeWithCtx (#3391) 2022-05-31 16:06:45 -04:00
Dillon Raphael
9cf924ee86 Regenerate route manifest on page changes (Working build) (#3385) 2022-05-30 10:09:20 -04:00
Dillon Raphael
b545a38b87 pnpmlock 2022-05-24 15:11:18 -04:00
github-actions[bot]
1463a20471 Version Packages (alpha) (#3378)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-05-24 15:09:03 -04:00
Dillon Raphael
0e762fb557 export BlitzPage & BlitzLayout types from @blitzjs/next (#3376)
* Export types

* Add changeset

* export AppProps

Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-05-24 21:02:17 +02:00
github-actions[bot]
6fe860512c Version Packages (alpha) (#3377)
* Version Packages (alpha)

* empty

* pnpm lock

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Dillon Raphael <dillon@creatorsneverdie.com>
2022-05-24 14:48:47 -04:00
Dillon Raphael
adfe8ff919 run build after pnpm i --frozen-lockfile so lint can work 2022-05-24 14:22:02 -04:00
Dillon Raphael
980869fbc8 add npm auth token to npmrc file in action step 2022-05-24 14:15:50 -04:00
Dillon Raphael
00f6d5576a merge main branch 2022-05-24 13:52:40 -04:00
Dillon Raphael
1945d85db2 Set strict peer dependencies to false 2022-05-24 13:47:56 -04:00
Aleksandra
b0c21b0706 Move blitz config to next.config.js (#3370) 2022-05-19 15:34:37 +02:00
Aleksandra
931156c352 Add support for prefetchInfiniteQuery (#3369) 2022-05-17 16:29:12 +02:00
Aleksandra
1436e76180 Export zod-utils from blitz core (#3368) 2022-05-17 15:49:42 +02:00
Aleksandra
c3bb5cd95b Add passport adapter (#3365) 2022-05-16 18:02:44 +02:00
beerose
8b08fe4e38 Update release workflow 2022-05-12 18:12:46 +02:00
beerose
604dc3b345 Update pnpm-lock after manually updating packages versions 2022-05-12 17:58:21 +02:00
beerose
20fb3b9427 Update packages versions manually 2022-05-12 17:52:00 +02:00
beerose
66ea6ec0cb Update package-lock 2022-05-12 17:47:17 +02:00
Dillon Raphael
8490b07246 test automated publish 2022-05-12 11:44:53 -04:00
Dillon Raphael
f15a519017 alpha.23 2022-05-12 11:39:15 -04:00
Aleksandra
cfcd3f83df Read custom server config from blitz config (#3359) 2022-05-12 17:15:50 +02:00
beerose
adabb11a0c 2.0.0-alpha.23 2022-05-12 16:06:10 +02:00
Dillon Raphael
909dc76087 merge 2022-05-12 09:35:11 -04:00
Dillon Raphael
c5c727cb67 add mounted check to withBlitz 2022-05-12 09:31:55 -04:00
Aleksandra
6ff9ec0d75 Upgrade @types/react, fix typings inside @blitzjs/next (#3356) 2022-05-12 13:04:05 +02:00
Aleksandra
da17cc8a24 Support prefetchBlitzQuery in gSP and gSSP (#3341) 2022-05-12 12:55:13 +02:00
Dillon Raphael
89bf993a1d Add db seed cli command (#3350)
* added db seed cli command

* Update .changeset/poor-penguins-look.md

* Add tsconfig-paths to blitz deps

Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-05-10 15:24:58 +02:00
Blake Bayer
68f129491c change password updated with try/catch (#3321)
* change password updated with try/catch

* Update changePassword.ts

* Update changePassword.ts

* Apply suggestions from code review

Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-05-10 11:26:39 +02:00
Dillon Raphael
c096891bf0 change queries & mutation test package.json to different name 2022-05-09 14:30:59 -04:00
Dillon Raphael
81b4b41a99 add mounted check in app generator (#3349)
* add mounted check in app generator

* add changeset
2022-05-09 14:26:30 -04:00
Dillon Raphael
e8271d579c React query tests (#3348)
* init tests

* fix custom blitz provider for testing-library render function

* fix mutation test setup and set globaThis react environment to true so the act function will work

* added query tests & moved blitz test utils to the utils dir

* clean queries and mutation test files

* remove .env file from qm tests

Co-authored-by: beerose <alexsandra.sikora@gmail.com>
2022-05-09 17:05:42 +02:00
GaneshMani
9e798b152b migrate react-query unit test to blitz-rpc (#3340) 2022-05-08 14:44:50 +02:00
Aleksandra
3c6f43a11d Add github workflow for automatic release (#3330) 2022-05-05 15:33:31 +02:00
Dillon Raphael
8107138e2f alpha.21 2022-05-04 13:58:20 -04:00
Dillon Raphael
8cb1134d94 Change template package.json to use latest tags on blitz/auth & blitz/rpc 2022-05-04 13:56:50 -04:00
Dillon Raphael
2073714f8d testing explicity setting dist-tag for changesets 2022-05-04 13:48:11 -04:00
Dillon Raphael
9631c45833 alpha.19 2022-05-04 12:23:32 -04:00
Aleksandra
2150dcc3e7 Setup Superjson for gssp and gsp (#3335) 2022-05-04 17:45:35 +02:00
Aleksandra
63605961b4 Use routes manifest in template app (#3334) 2022-05-04 17:18:23 +02:00
Brandon Bayer
d711948809 toolkit: fix suspense loading by throwing error on the server (but still have error popup) (#3332)
* wip

* cleanup

* upgrade next@canary
2022-05-02 17:07:41 -07:00
Dillon Raphael
1f6b0b54c2 alpha.18 2022-04-29 20:46:32 -04:00
Dillon Raphael
4603a2b7bd alpha.17 2022-04-29 20:04:23 -04:00
297 changed files with 10850 additions and 2275 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/next": patch
---
Export BlitzProvider from @blitzjs/next

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,11 @@
---
"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

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

View File

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

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/codemod": patch
---
Handle next/dynamic default import in codemod

View File

@@ -12,25 +12,87 @@
"@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"
"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"
},
"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-deers-dream",
"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",
"popular-teachers-pay",
"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",
"tall-meals-learn",
"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",
"wicked-ghosts-cough"
"violet-bags-leave",
"violet-lions-help",
"weak-suns-shave",
"wicked-ghosts-cough",
"wise-frogs-give"
]
}

View File

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

View File

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

View File

@@ -0,0 +1,5 @@
---
"@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

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,6 @@
---
"@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

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---
Upgrade Prisma to v4.0.0

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,5 @@
---
"@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
* @flybayer @beerose @dillonraphael
packages/generator/templates**/* @flybayer

58
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,58 @@
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
.npmrc
View File

@@ -1,7 +1,9 @@
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

@@ -1,5 +1,59 @@
# 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

View File

@@ -5,6 +5,7 @@ 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
@@ -39,7 +40,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="/auth/forgot-password" passHref>
<Link href={Routes.ForgotPasswordPage()} passHref>
<a>Forgot your password?</a>
</Link>
</div>
@@ -47,7 +48,7 @@ export const LoginForm = (props: LoginFormProps) => {
<div style={{ marginTop: "1rem" }}>
Or{" "}
<Link href="/auth/signup" passHref>
<Link href={Routes.SignupPage()} passHref>
<a>Sign Up</a>
</Link>
</div>

View File

@@ -1,5 +1,5 @@
import { NotFoundError } from "blitz"
import { db } from "db"
import 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 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 db 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 db from "db"
import { ResetPassword } from "../validations"
import login from "./login"

View File

@@ -1,5 +1,6 @@
import { db } from "db"
import db from "db"
import { SecurePassword } from "@blitzjs/auth"
import { Role } from "types"
export default async function signup(input, ctx) {
const blitzContext = ctx
@@ -13,6 +14,7 @@ export default async function signup(input, ctx) {
await blitzContext.session.$create({
userId: user.id,
role: user.role as Role,
})
return { userId: blitzContext.session.userId, ...user, email: input.email }

View File

@@ -7,12 +7,6 @@ export const { withBlitz } = setupBlitzClient({
AuthClientPlugin({
cookiePrefix: "web-cookie-prefix",
}),
BlitzRpcPlugin({
reactQueryOptions: {
queries: {
staleTime: 7000,
},
},
}),
BlitzRpcPlugin({}),
],
})

View File

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

View File

@@ -1,5 +1,5 @@
import { Ctx } from "blitz"
import { db } from "db"
import db from "db"
export default async function getCurrentUser(_ = null, { session }: Ctx) {
if (!session.userId) return null

View File

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

View File

@@ -0,0 +1,47 @@
-- CreateTable
CREATE TABLE "User" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"name" TEXT,
"email" TEXT NOT NULL,
"hashedPassword" TEXT,
"role" TEXT NOT NULL DEFAULT 'USER'
);
-- CreateTable
CREATE TABLE "Session" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"expiresAt" DATETIME,
"handle" TEXT NOT NULL,
"hashedSessionToken" TEXT,
"antiCSRFToken" TEXT,
"publicData" TEXT,
"privateData" TEXT,
"userId" INTEGER,
CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "Token" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"hashedToken" TEXT NOT NULL,
"type" TEXT NOT NULL,
"expiresAt" DATETIME NOT NULL,
"sentTo" TEXT NOT NULL,
"userId" INTEGER NOT NULL,
CONSTRAINT "Token_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
-- CreateIndex
CREATE UNIQUE INDEX "Session_handle_key" ON "Session"("handle");
-- CreateIndex
CREATE UNIQUE INDEX "Token_hashedToken_type_key" ON "Token"("hashedToken", "type");

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,9 +7,15 @@
* to easily generate realistic data.
*/
const seed = async () => {
// for (let i = 0; i < 5; i++) {
// await db.project.create({ data: { name: "Project " + i } })
// }
await db.$reset()
for (let i = 0; i < 1; i++) {
await db.user.create({
data: {
email: "test@test.com",
},
})
}
}
export default seed

View File

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

View File

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

View File

@@ -0,0 +1,22 @@
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,13 +1,14 @@
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("/")} />
<SignupForm onSuccess={() => router.push(Routes.Home())} />
</Layout>
)
}

View File

@@ -6,6 +6,7 @@ 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.
@@ -37,12 +38,12 @@ const UserInfo = () => {
} else {
return (
<>
<Link href="/auth/signup" passHref>
<Link href={Routes.SignupPage()} passHref>
<a className="button small">
<strong>Sign Up</strong>
</a>
</Link>
<Link href="/auth/login" passHref>
<Link href={Routes.LoginPage()} 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,14 +1,13 @@
import {setupBlitzServer} from "@blitzjs/next"
import {AuthServerPlugin, PrismaStorage} from "@blitzjs/auth"
import {prisma as db} from "../prisma/index"
import db from "db"
import {simpleRolesIsAuthorized} from "@blitzjs/auth"
const {gSSP, gSP, api} = setupBlitzServer({
plugins: [
AuthServerPlugin({
cookiePrefix: "webapp-cookie-prefix",
// TODO fix type
storage: PrismaStorage(db as any),
storage: PrismaStorage(db),
isAuthorized: simpleRolesIsAuthorized,
}),
],

View File

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

View File

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

View File

@@ -0,0 +1,8 @@
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

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

View File

@@ -6,5 +6,10 @@ const {withBlitz} = require("@blitzjs/next")
module.exports = withBlitz(
withBundleAnalyzer({
reactStrictMode: true,
blitz: {
customServer: {
hotReload: false,
},
},
}),
)

View File

@@ -12,6 +12,9 @@
"prisma:studio": "prisma studio",
"test": "jest"
},
"prisma": {
"schema": "./db/schema.prisma"
},
"dependencies": {
"@blitzjs/auth": "workspace:*",
"@blitzjs/config": "workspace:*",
@@ -19,17 +22,20 @@
"@blitzjs/rpc": "workspace:*",
"@prisma/client": "3.9.0",
"@types/jest": "27.4.1",
"@types/passport-twitter": "1.0.37",
"blitz": "workspace:*",
"jest": "27.5.1",
"next": "12.1.1",
"prisma": "3.9.0",
"next": "12.2.0",
"passport-mock-strategy": "2.0.0",
"passport-twitter": "1.0.4",
"prisma": "4.0.0",
"react": "18.0.0",
"react-dom": "18.0.0",
"ts-node": "10.7.0"
},
"devDependencies": {
"@next/bundle-analyzer": "12.0.8",
"@types/react": "17.0.43",
"@types/react": "18.0.1",
"eslint": "7.32.0",
"typescript": "^4.5.3"
}

View File

@@ -1,6 +1,5 @@
import {ErrorFallbackProps, ErrorComponent, ErrorBoundary} from "@blitzjs/next"
import {ErrorFallbackProps, ErrorComponent, ErrorBoundary, AppProps} from "@blitzjs/next"
import {AuthenticationError, AuthorizationError} from "blitz"
import type {AppProps} from "next/app"
import React, {Suspense} from "react"
import {withBlitz} from "app/blitz-client"

View File

@@ -0,0 +1,44 @@
import {passportAuth} from "@blitzjs/auth"
import {api} from "app/blitz-server"
import db from "db"
import {Strategy as TwitterStrategy} from "passport-twitter"
export default api(
passportAuth({
successRedirectUrl: "/",
errorRedirectUrl: "/",
strategies: [
{
strategy: new TwitterStrategy(
{
consumerKey: process.env.TWITTER_CONSUMER_KEY as string,
consumerSecret: process.env.TWITTER_CONSUMER_SECRET as string,
accessTokenURL: "https://api.twitter.com/oauth/access_token",
callbackURL: "http://127.0.0.1:3000/api/auth/twitter/callback",
includeEmail: true,
},
async function (_token, _tokenSecret, profile, done) {
const email = profile.emails?.[0]?.value ?? "blitz@test.com"
const user = await db.user.upsert({
where: {email},
create: {
email,
name: profile.displayName,
},
update: {email},
})
const publicData = {
userId: user.id,
roles: [user.role],
source: "twitter",
}
done(undefined, {publicData})
},
),
},
],
}),
)

View File

@@ -1,14 +1,13 @@
import {api} from "app/blitz-server"
import {SessionContext} from "@blitzjs/auth"
import {prisma} from "../../prisma/index"
import db from "db"
export default api(async (_req, res, ctx) => {
const blitzContext = ctx
const publicData = blitzContext.session.$publicData
const sessions = await prisma.session.findMany({})
const sessionsCount = await prisma.session.count({})
const sessions = await db.session.findMany({})
const sessionsCount = await db.session.count({})
res.status(200).json({
userId: blitzContext.session.userId,

View File

@@ -1,8 +1,8 @@
import {NextApiRequest, NextApiResponse} from "next"
import {prisma} from "../../prisma/index"
import db from "db"
export default async function handle(req: NextApiRequest, res: NextApiResponse) {
const session = await prisma.session.findFirst({
const session = await db.session.findFirst({
where: {
handle: "test",
},

View File

@@ -1,9 +1,9 @@
import {api} from "app/blitz-server"
import {prisma} from "../../prisma/index"
import db from "db"
export default api(async (_req, res) => {
const sessions = await prisma.session.deleteMany()
const sessionsCount = await prisma.session.count()
const sessions = await db.session.deleteMany()
const sessionsCount = await db.session.count()
res.status(200).json({
activeSessions: sessions,

View File

@@ -1,12 +1,12 @@
import {setPublicDataForUser} from "@blitzjs/auth"
import {api} from "app/blitz-server"
import {prisma} from "../../prisma/index"
import db from "db"
export default api(async (req, res, ctx) => {
if (ctx.session.$thisIsAuthorized()) {
ctx.session.$publicData
await prisma.user.update({
await db.user.update({
where: {id: ctx.session.userId as number},
data: {role: req.query.role as string},
})

View File

@@ -1,9 +1,9 @@
import {api} from "app/blitz-server"
import {prisma} from "../../prisma/index"
import db from "db"
import {SecurePassword} from "@blitzjs/auth"
export const authenticateUser = async (email: string, password: string) => {
const user = await prisma.user.findFirst({where: {email}})
const user = await db.user.findFirst({where: {email}})
if (!user) throw new Error("Authentication Error")
const result = await SecurePassword.verify(user.hashedPassword, password)
@@ -11,7 +11,7 @@ export const authenticateUser = async (email: string, password: string) => {
if (result === SecurePassword.VALID_NEEDS_REHASH) {
// Upgrade hashed password with a more secure hash
const improvedHash = await SecurePassword.hash(password)
await prisma.user.update({where: {id: user.id}, data: {hashedPassword: improvedHash}})
await db.user.update({where: {id: user.id}, data: {hashedPassword: improvedHash}})
}
const {hashedPassword, ...rest} = user
@@ -25,6 +25,7 @@ export default api(async (req, res, ctx) => {
await blitzContext.session.$create({
userId: user.id,
role: "USER",
})
res.status(200).json({email: req.query.email, userId: blitzContext.session.userId})

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