diff --git a/packages/server/src/api/controllers/oauth2.ts b/packages/server/src/api/controllers/oauth2.ts index 54a496ec3d..54b18586c5 100644 --- a/packages/server/src/api/controllers/oauth2.ts +++ b/packages/server/src/api/controllers/oauth2.ts @@ -1,6 +1,6 @@ import { - CreateOAuth2ConfigRequest, - CreateOAuth2ConfigResponse, + UpsertOAuth2ConfigRequest, + UpsertOAuth2ConfigResponse, Ctx, FetchOAuth2ConfigsResponse, OAuth2Config, @@ -22,7 +22,7 @@ export async function fetch(ctx: Ctx) { } export async function create( - ctx: Ctx + ctx: Ctx ) { const { body } = ctx.request const newConfig: RequiredKeys> = { @@ -38,7 +38,7 @@ export async function create( } export async function edit( - ctx: Ctx + ctx: Ctx ) { const { body } = ctx.request const toUpdate: RequiredKeys = { diff --git a/packages/server/src/api/routes/oauth2.ts b/packages/server/src/api/routes/oauth2.ts index 8973b49736..4f43c5a6e1 100644 --- a/packages/server/src/api/routes/oauth2.ts +++ b/packages/server/src/api/routes/oauth2.ts @@ -15,7 +15,7 @@ router.post( router.put( "/api/oauth2/:id", authorized(PermissionType.BUILDER), - createOAauth2ConfigValidator(), + oAuth2ConfigValidator(), controller.create ) diff --git a/packages/server/src/api/routes/tests/oauth2.spec.ts b/packages/server/src/api/routes/tests/oauth2.spec.ts index e219f5f6f1..88884feb39 100644 --- a/packages/server/src/api/routes/tests/oauth2.spec.ts +++ b/packages/server/src/api/routes/tests/oauth2.spec.ts @@ -1,11 +1,11 @@ -import { CreateOAuth2ConfigRequest, VirtualDocumentType } from "@budibase/types" +import { UpsertOAuth2ConfigRequest, VirtualDocumentType } from "@budibase/types" import * as setup from "./utilities" import { generator } from "@budibase/backend-core/tests" describe("/oauth2", () => { let config = setup.getConfig() - function makeOAuth2Config(): CreateOAuth2ConfigRequest { + function makeOAuth2Config(): UpsertOAuth2ConfigRequest { return { name: generator.guid(), url: generator.url(), diff --git a/packages/server/src/tests/utilities/api/oauth2.ts b/packages/server/src/tests/utilities/api/oauth2.ts index 9f52f27bfe..195ea40679 100644 --- a/packages/server/src/tests/utilities/api/oauth2.ts +++ b/packages/server/src/tests/utilities/api/oauth2.ts @@ -1,6 +1,6 @@ import { - CreateOAuth2ConfigRequest, - CreateOAuth2ConfigResponse, + UpsertOAuth2ConfigRequest, + UpsertOAuth2ConfigResponse, FetchOAuth2ConfigsResponse, } from "@budibase/types" import { Expectations, TestAPI } from "./base" @@ -13,10 +13,10 @@ export class OAuth2API extends TestAPI { } create = async ( - body: CreateOAuth2ConfigRequest, + body: UpsertOAuth2ConfigRequest, expectations?: Expectations ) => { - return await this._post("/api/oauth2", { + return await this._post("/api/oauth2", { body, expectations: { status: expectations?.status ?? 201, diff --git a/packages/types/src/api/web/app/oauth2.ts b/packages/types/src/api/web/app/oauth2.ts index 4a6e836ef4..452b816d1a 100644 --- a/packages/types/src/api/web/app/oauth2.ts +++ b/packages/types/src/api/web/app/oauth2.ts @@ -1,4 +1,4 @@ -export interface OAuth2ConfigResponse { +interface OAuth2ConfigResponse { id: string name: string } @@ -7,13 +7,13 @@ export interface FetchOAuth2ConfigsResponse { configs: OAuth2ConfigResponse[] } -export interface CreateOAuth2ConfigRequest { +export interface UpsertOAuth2ConfigRequest { name: string url: string clientId: string clientSecret: string } -export interface CreateOAuth2ConfigResponse { +export interface UpsertOAuth2ConfigResponse { config: OAuth2ConfigResponse }