Skip to content

Commit

Permalink
example: fix adapter examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonraimondi committed Jun 5, 2023
1 parent ce194d5 commit cba732a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
.idea
.env

6 changes: 3 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"license": "MIT",
"scripts": {
"gen": "prisma generate",
"dev": "tsx src/main-express.ts",
"dev:fastify": "tsx src/main-fastify.ts"
"dev": "tsx watch src/main-express.ts",
"dev:fastify": "tsx watch src/main-fastify.ts"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.2",
Expand All @@ -16,7 +16,7 @@
"typescript": "^5.1.3"
},
"dependencies": {
"@jmondi/oauth2-server": "3.0.0-alpha.4",
"@jmondi/oauth2-server": "3.0.0-alpha.5",
"@prisma/client": "^4.15.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.20.2",
Expand Down
8 changes: 4 additions & 4 deletions example/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions example/src/main-express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import "dotenv/config";
import { PrismaClient } from "@prisma/client";
import { json, urlencoded } from "body-parser";
import Express from "express";
import { AuthorizationServer, DateInterval, JwtService } from "@jmondi/oauth2-server";
import {
requestFromExpress,
AuthorizationServer,
DateInterval,
JwtService,
handleExpressError,
handleExpressResponse,
} from "@jmondi/oauth2-server/dist/adapters/express";
} from "@jmondi/oauth2-server";

import { AuthCodeRepository } from "./repositories/auth_code_repository";
import { ClientRepository } from "./repositories/client_repository";
Expand Down Expand Up @@ -40,7 +41,7 @@ async function bootstrap() {
app.get("/authorize", async (req: Express.Request, res: Express.Response) => {
try {
// Validate the HTTP request and return an AuthorizationRequest object.
const authRequest = await authorizationServer.validateAuthorizationRequest(requestFromExpress(req));
const authRequest = await authorizationServer.validateAuthorizationRequest(req);

// The auth request object can be serialized and saved into a user's session.
// You will probably want to redirect the user at this point to a login endpoint.
Expand Down Expand Up @@ -83,7 +84,6 @@ async function bootstrap() {
});

app.listen(3000);

console.log("app is listening on localhost:3000");
}

Expand Down
6 changes: 1 addition & 5 deletions example/src/main-fastify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import "dotenv/config";
import { PrismaClient } from "@prisma/client";
import Fastify, { FastifyReply, FastifyRequest } from "fastify";
import { AuthorizationServer, DateInterval, JwtService } from "@jmondi/oauth2-server";
import {
requestFromFastify,
handleFastifyError,
handleFastifyReply,
} from "@jmondi/oauth2-server/dist/adapters/fastify";
import { requestFromFastify, handleFastifyError, handleFastifyReply } from "@jmondi/oauth2-server/fastify";

import { ClientRepository } from "./repositories/client_repository";
import { AuthCodeRepository } from "./repositories/auth_code_repository";
Expand Down
4 changes: 3 additions & 1 deletion example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@
"@types",
"node_modules/@types"
]
}
},
"include": ["src/**"],
"exclude": ["node_modules/**"]
}

0 comments on commit cba732a

Please sign in to comment.