39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import queryDSQLAPI from "../../functions/api/query-dsql-api";
|
|
import { APIResponseObject } from "../../types";
|
|
import { DSQL_DATASQUIREL_USER_MEDIA } from "../../types/dsql";
|
|
import path from "path";
|
|
import grabAPIBasePath from "../../utils/grab-api-base-path";
|
|
|
|
type Params = {
|
|
mediaID?: string | number;
|
|
apiKey?: string;
|
|
};
|
|
|
|
export default async function apiMediaDELETE(
|
|
params: Params
|
|
): Promise<
|
|
APIResponseObject<
|
|
DSQL_DATASQUIREL_USER_MEDIA | DSQL_DATASQUIREL_USER_MEDIA[]
|
|
>
|
|
> {
|
|
const basePath = grabAPIBasePath({ paradigm: "media" });
|
|
|
|
const mediaID = params.mediaID
|
|
? typeof params.mediaID === "number"
|
|
? String(params.mediaID)
|
|
: params.mediaID
|
|
: undefined;
|
|
|
|
const finalPath = path.join(basePath, mediaID || "");
|
|
|
|
const DELETE_MEDIA_RES = await queryDSQLAPI({
|
|
method: "DELETE",
|
|
path: finalPath,
|
|
apiKey: params.apiKey,
|
|
});
|
|
|
|
return DELETE_MEDIA_RES as APIResponseObject<
|
|
DSQL_DATASQUIREL_USER_MEDIA | DSQL_DATASQUIREL_USER_MEDIA[]
|
|
>;
|
|
}
|