Skip to content

Commit

Permalink
Added delete a File api endpoint to api docs generation
Browse files Browse the repository at this point in the history
  • Loading branch information
NickOvt committed Apr 22, 2024
1 parent 25a5b06 commit bd9dcbf
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions lib/api/storage.js
Expand Up @@ -309,15 +309,39 @@ module.exports = (db, server, storageHandler) => {
);

server.del(
'/users/:user/storage/:file',
{
path: '/users/:user/storage/:file',
tags: ['Storage'],
summary: 'Delete a File',
validationObjs: {
requestBody: {},
queryParams: {
sess: sessSchema,
ip: sessIPSchema
},
pathParams: {
user: userId,
file: Joi.string().hex().lowercase().length(24).required().description('ID of the File')
},
response: {
200: {
description: 'Success',
model: Joi.object({
success: successRes
})
}
}
}
},
tools.responseWrapper(async (req, res) => {
res.charSet('utf-8');

const schema = Joi.object().keys({
user: Joi.string().hex().lowercase().length(24).required(),
file: Joi.string().hex().lowercase().length(24).required(),
sess: sessSchema,
ip: sessIPSchema
const { requestBody, queryParams, pathParams } = req.route.spec.validationObjs;

const schema = Joi.object({
...requestBody,
...queryParams,
...pathParams
});

const result = schema.validate(req.params, {
Expand Down

0 comments on commit bd9dcbf

Please sign in to comment.