Files
planka/server/api/responses/conflict.js

66 lines
1.3 KiB
JavaScript
Raw Normal View History

/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
2019-08-31 04:07:25 +05:00
/**
* conflict.js
*
* A custom response.
*
* Example usage:
* ```
* return res.conflict();
* // -or-
* return res.conflict(optionalData);
* ```
*
* Or with actions2:
* ```
* exits: {
* somethingHappened: {
* responseType: 'conflict'
* }
* }
* ```
*
* ```
* throw 'somethingHappened';
* // -or-
* throw { somethingHappened: optionalData }
* ```
*/
2025-09-08 16:20:27 +02:00
/**
* @swagger
* components:
* responses:
* Conflict:
* description: Request conflicts with current state of the resource
* content:
* application/json:
* schema:
* type: object
* required:
* - code
* - message
* properties:
* code:
* type: string
* description: Error code
* example: E_CONFLICT
* message:
* type: string
* description: Error message
* example: Resource already exists
*/
2019-08-31 04:07:25 +05:00
module.exports = function conflict(message) {
const { res } = this;
return res.status(409).json({
code: 'E_CONFLICT',
message,
2019-08-31 04:07:25 +05:00
});
};