Skip to content

Commit

Permalink
feat: add elysia-oauth2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
kravetsone committed Aug 12, 2024
1 parent b331786 commit 7b66317
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ bun create elysiajs <dir>
- - [Swagger](https://elysiajs.com/plugins/swagger.html)
- - [JWT](https://elysiajs.com/plugins/jwt.html)
- - [Autoload](https://github.com/kravetsone/elysia-autoload)
- - [Oauth 2.0](https://github.com/kravetsone/elysia-oauth2)
- - [HTML/JSX](https://elysiajs.com/plugins/html.html)
- - [Logger](https://github.com/bogeychan/elysia-logger)
- - [Static](https://elysiajs.com/plugins/static.html)
Expand Down
2 changes: 2 additions & 0 deletions src/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ export const dependencies = {
"@bogeychan/elysia-logger": "^0.1.1",
"@antfu/eslint-config": "^2.25.1",
"@gramio/init-data": "^0.0.1",
"elysia-oauth2": "^1.3.0",
artic: "^1.9.2",
};
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ createOrFindDir(projectDir).then(async () => {
"Swagger",
"JWT",
"Autoload",
"Oauth 2.0",
"Logger",
"HTML/JSX",
"Static",
Expand Down
4 changes: 4 additions & 0 deletions src/templates/elysia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export function getElysiaIndex({ orm, driver, plugins }: Preferences) {
elysiaImports.push(`import { swagger } from "@elysiajs/swagger"`);
elysiaPlugins.push(".use(swagger())");
}
if (plugins.includes("Oauth 2.0")) {
elysiaImports.push(`import { oauth2 } from "elysia-oauth2"`);
elysiaPlugins.push(".use(oauth2())");
}
if (plugins.includes("Bearer")) {
elysiaImports.push(`import { bearer } from "@elysiajs/bearer"`);
elysiaPlugins.push(".use(bearer())");
Expand Down
5 changes: 5 additions & 0 deletions src/templates/package.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ export function getPackageJson({
sample.dependencies["@bogeychan/elysia-logger"] =
dependencies["@bogeychan/elysia-logger"];

if (plugins.includes("Oauth 2.0")) {
sample.dependencies.artic = dependencies.artic;
sample.dependencies["elysia-oauth2"] = dependencies["elysia-oauth2"];
}

if (isMonorepo)
sample.dependencies["@gramio/init-data"] =
dependencies["@gramio/init-data"];
Expand Down
1 change: 1 addition & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class Preferences {
| "CORS"
| "Swagger"
| "Autoload"
| "Oauth 2.0"
| "Logger"
| "HTML/JSX"
| "Static"
Expand Down

0 comments on commit 7b66317

Please sign in to comment.