Skip to content

Commit

Permalink
[add] JWT Verifier middleware
Browse files Browse the repository at this point in the history
[optimize] update Upstream packages
  • Loading branch information
TechQuery committed Nov 6, 2023
1 parent 5df8ce8 commit fbbc90b
Show file tree
Hide file tree
Showing 5 changed files with 233 additions and 100 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
package-lock.json
yarn.lock
dist/
docs/
docs/
.vscode/settings.json
23 changes: 19 additions & 4 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,23 @@
### `pages/user/[id].tsx`

```tsx
import { InferGetServerSidePropsType } from 'next';
import {
JWTProps,
RouterProps,
jwtVerifier,
cache,
errorLogger,
router,
translator
} from 'next-ssr-middleware';

import i18n from '../../model/Translation';
import { User, UserModel } from '../../model/User';

export const getServerSideProps = compose<{ id: string }, User>(
type UserDetailPageProps = User & JWTProps & RouterProps;

export const getServerSideProps = compose<{ id: string }, UserDetailPageProps>(
jwtVerifier(),
cache(),
errorLogger,
router,
Expand All @@ -30,12 +41,16 @@ export const getServerSideProps = compose<{ id: string }, User>(
);

export default function UserDetailPage({
jwtPayload,
route,
name,
summary
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
}: UserDetailPageProps) {
return (
<>
<h1>{name}</h1>
<h1>
{name} - {route.params!.id}
</h1>
<p>{summary}</p>
</>
);
Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-ssr-middleware",
"version": "0.5.2",
"version": "0.6.0",
"license": "LGPL-3.0-or-later",
"author": "shiy2008@gmail.com",
"description": "Koa-like middlewares for Next.js Server Side Rendering",
Expand All @@ -22,22 +22,24 @@
"types": "dist/index.d.ts",
"main": "dist/index.js",
"dependencies": {
"mobx-i18n": "^0.4.1",
"jsonwebtoken": "^9.0.2",
"mobx-i18n": "^0.4.2",
"tslib": "^2.6.2",
"web-utility": "^4.1.3"
},
"peerDependencies": {
"next": ">=9.3"
},
"devDependencies": {
"@types/node": "^18.18.5",
"@types/jsonwebtoken": "^9.0.4",
"@types/node": "^18.18.8",
"husky": "^8.0.3",
"koajax": "^0.9.4",
"lint-staged": "^15.0.1",
"next": "^13.5.5",
"lint-staged": "^15.0.2",
"next": "^14.0.1",
"open-cli": "^7.2.0",
"prettier": "^3.0.3",
"typedoc": "^0.25.2",
"typedoc": "^0.25.3",
"typescript": "~5.2.2"
},
"prettier": {
Expand Down
Loading

0 comments on commit fbbc90b

Please sign in to comment.