This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
2023-01-11 00:24:19 +01:00

49 lines
1.2 KiB
TypeScript

import type { FastifyPluginAsync, FastifySchema } from 'fastify'
import { Type } from '@sinclair/typebox'
import { fastifyErrors } from '../../../models/utils.js'
import verifyAPIKey from '../../../tools/plugins/verifyAPIKey.js'
import type { DeleteParameters } from '../../../tools/utils/deleteUploadedFile.js'
import {
deleteParameters,
deleteUploadedFile
} from '../../../tools/utils/deleteUploadedFile.js'
export const deleteServiceSchema: FastifySchema = {
tags: ['guilds'] as string[],
security: [
{
apiKeyAuth: []
}
] as Array<{ [key: string]: [] }>,
params: deleteParameters,
response: {
200: Type.String(),
400: fastifyErrors[400],
404: fastifyErrors[404],
500: fastifyErrors[500]
}
} as const
export const deleteGuildsUploadsService: FastifyPluginAsync = async (
fastify
) => {
await fastify.register(verifyAPIKey)
await fastify.route<{
Params: DeleteParameters
}>({
method: 'DELETE',
url: '/uploads/guilds/:file',
schema: deleteServiceSchema,
handler: async (request, reply) => {
return await deleteUploadedFile({
fastify,
request,
reply,
folder: 'guilds'
})
}
})
}