api keycloak setup
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import { Controller, Get, Route, SuccessResponse } from 'tsoa';
|
||||
import { Controller, Get, Post, Route, Security, SuccessResponse } from "tsoa";
|
||||
import { inject } from "../infrastructure/di/index.js";
|
||||
import { KC_SECURITY_NAME } from "../services/keycloak/user/index.js";
|
||||
import { MessagingService } from "../services/messagingService.js";
|
||||
|
||||
export interface User {
|
||||
email: string;
|
||||
@@ -8,13 +11,21 @@ export interface User {
|
||||
|
||||
export type UserCreationParams = Pick<User, "email" | "name" | "phoneNumbers">;
|
||||
|
||||
@Route('health')
|
||||
@Route("health")
|
||||
export class HealthCheckController extends Controller {
|
||||
@Get('ok')
|
||||
@SuccessResponse('200', 'OK')
|
||||
public async getOk(
|
||||
): Promise<string> {
|
||||
this.setStatus(200);
|
||||
return 'Ok';
|
||||
private readonly messaging = inject(MessagingService);
|
||||
|
||||
@Get("ok")
|
||||
@SuccessResponse("200", "OK")
|
||||
public async getOk() {}
|
||||
|
||||
@Get("auth")
|
||||
@Security(KC_SECURITY_NAME)
|
||||
@SuccessResponse("200", "OK")
|
||||
public async getAuth() {}
|
||||
|
||||
@Post("testmessage")
|
||||
public async sendTestMessage() {
|
||||
await this.messaging.sendTestMessage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Controller, Route } from "@tsoa/runtime";
|
||||
import { inject } from "../infrastructure/di/index.js";
|
||||
import { MembersService } from "../services/membersService.js";
|
||||
|
||||
@Route("members")
|
||||
export class MembersContoller extends Controller {
|
||||
private readonly membersService = inject(MembersService);
|
||||
// @Security(KC_SECURITY_NAME)
|
||||
// @Get()
|
||||
// public async getMembers(): Promise<Member[]> {
|
||||
// return await this.membersService.getMembers();
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
Body,
|
||||
BodyProp,
|
||||
Controller,
|
||||
Get,
|
||||
Path,
|
||||
Put,
|
||||
Query,
|
||||
Route,
|
||||
Security,
|
||||
} from "@tsoa/runtime";
|
||||
import { inject } from "../infrastructure/di";
|
||||
import { Claim } from "../models/claim";
|
||||
import { Topic } from "../models/topic";
|
||||
import { User } from "../models/user";
|
||||
import { KC_SECURITY_NAME } from "../services/keycloak/user/index.js";
|
||||
import { UserService } from "../services/userService";
|
||||
|
||||
@Route("users")
|
||||
export class UsersController extends Controller {
|
||||
private readonly userService = inject(UserService);
|
||||
|
||||
@Security(KC_SECURITY_NAME, [Claim.UserAdmin])
|
||||
@Get()
|
||||
public async getUsers(): Promise<User[]> {
|
||||
return await this.userService.getUsers();
|
||||
}
|
||||
|
||||
@Security(KC_SECURITY_NAME, [Claim.UserAdmin])
|
||||
@Put("/claims/{uid}")
|
||||
public async setClaims(
|
||||
@Path() uid: string,
|
||||
@BodyProp() claim: Claim,
|
||||
@Query() value: boolean,
|
||||
): Promise<void> {
|
||||
await this.userService.setClaim(uid, claim, value);
|
||||
}
|
||||
|
||||
@Security(KC_SECURITY_NAME)
|
||||
@Put("/subscriptions/{token}")
|
||||
public async setSubscriptions(
|
||||
@Body() topics: Topic[],
|
||||
@Path() token: string,
|
||||
) {
|
||||
await this.userService.setSubscriptions(token, topics);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user