Skip to content
This repository was archived by the owner on Apr 9, 2024. It is now read-only.

Commit 6dcf3c9

Browse files
committed
feat: switch to bun and update plugin-keycloak to v1.1.5
1 parent 0fbb931 commit 6dcf3c9

File tree

5 files changed

+14
-895
lines changed

5 files changed

+14
-895
lines changed

bun.lockb

50.6 KB
Binary file not shown.

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@
1111
},
1212
"keywords": [],
1313
"dependencies": {
14-
"@nexirift/plugin-keycloak": "^1.1.4",
14+
"@nexirift/plugin-keycloak": "^1.1.5",
1515
"@pothos/core": "^3.41.0",
1616
"@types/node": "^20.11.24",
1717
"dotenv": "^16.4.5",
1818
"graphql": "^16.8.1",
1919
"graphql-yoga": "^5.1.1",
20-
"keycloak-backend": "^5.0.0",
2120
"redis": "^4.6.13"
2221
},
2322
"devDependencies": {
2423
"ts-node-dev": "^2.0.0",
2524
"typescript": "^5.3.3"
2625
}
27-
}
26+
}

src/context.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ITokenContent } from "keycloak-backend";
1+
import { KeycloakToken } from "@nexirift/plugin-keycloak";
22

33
/**
44
* Represents the context object used in the application.
@@ -15,5 +15,5 @@ export interface Context {
1515
/**
1616
* The Keycloak token content.
1717
*/
18-
keycloak: ITokenContent;
18+
keycloak: KeycloakToken;
1919
}

src/server.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { createYoga } from 'graphql-yoga';
22
import { createServer } from 'node:http';
33
import SchemaBuilder from '@pothos/core';
4-
import { Keycloak } from 'keycloak-backend';
5-
import { useKeycloak } from '@nexirift/plugin-keycloak';
4+
import { Keycloak, KeycloakToken, useKeycloak } from '@nexirift/plugin-keycloak';
65
import { redisClient } from './redis';
76
import { Context } from './context';
87

@@ -26,6 +25,15 @@ builder.queryType({
2625
hello: t.string({
2726
resolve: (_root, _args, ctx: Context) =>
2827
`Hello ${ctx?.keycloak?.preferred_username || 'Anonymous'}`
28+
}),
29+
checkScope: t.boolean({
30+
resolve: (_root, _args, ctx: Context) => {
31+
if (!ctx.keycloak) {
32+
return false;
33+
}
34+
35+
return (new KeycloakToken(ctx.keycloak).hasScopes(["test:scope"]))
36+
}
2937
})
3038
})
3139
});

0 commit comments

Comments
 (0)