chore: fixes to HTTP and request types for API Keys (#13819)
This commit is contained in:
@@ -19,5 +19,8 @@ export interface AdminUpdateApiKey {
|
||||
}
|
||||
|
||||
export interface AdminRevokeApiKey {
|
||||
/**
|
||||
* The number of seconds to wait before revoking the API key.
|
||||
*/
|
||||
revoke_in?: number
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminRevokeApiKeyType } from "../../validators"
|
||||
import { refetchApiKey } from "../../helpers"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminRevokeApiKeyType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminRevokeApiKey,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminApiKeyResponse>
|
||||
) => {
|
||||
await revokeApiKeysWorkflow(req.scope).run({
|
||||
|
||||
@@ -8,12 +8,11 @@ import {
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
import { refetchApiKey } from "../helpers"
|
||||
import { AdminUpdateApiKeyType } from "../validators"
|
||||
import { MedusaError } from "@medusajs/framework/utils"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminApiKeyResponse>
|
||||
) => {
|
||||
const apiKey = await refetchApiKey(
|
||||
@@ -33,7 +32,10 @@ export const GET = async (
|
||||
}
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminUpdateApiKeyType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminUpdateApiKey,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminApiKeyResponse>
|
||||
) => {
|
||||
await updateApiKeysWorkflow(req.scope).run({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { linkSalesChannelsToApiKeyWorkflow } from "@medusajs/core-flows"
|
||||
import { HttpTypes, LinkMethodRequest } from "@medusajs/framework/types"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
import { ApiKeyType, MedusaError } from "@medusajs/framework/utils"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
@@ -8,7 +8,10 @@ import {
|
||||
import { refetchApiKey } from "../../helpers"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<LinkMethodRequest>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminBatchLink,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminApiKeyResponse>
|
||||
) => {
|
||||
const { add, remove } = req.validatedBody
|
||||
|
||||
Reference in New Issue
Block a user