1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 05:09:43 +02:00

feat: add routes for creating, cycling and deleting apiKeys

This commit is contained in:
Samuel 2025-07-13 01:56:44 +02:00
parent d6cbb889fb
commit 846b0579b3
7 changed files with 243 additions and 0 deletions

View file

@ -0,0 +1,51 @@
/*!
* Copyright (c) 2025 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
const { idInput } = require('../../../utils/inputs');
const Errors = {
USER_NOT_FOUND: {
userNotFound: 'User not found',
},
DOES_NOT_EXIST: {
doesNotExist: 'User does not have an API key',
},
};
module.exports = {
inputs: {
id: {
...idInput,
required: true,
},
},
exits: {
userNotFound: {
responseType: 'notFound',
},
doesNotExist: {
responseType: 'notFound',
},
},
async fn(inputs) {
const { id } = inputs;
const { apiKey } = await sails.helpers.apiKey.createAndStore
.with({
id,
cycle: true,
})
.intercept('doesNotExist', () => Errors.DOES_NOT_EXIST)
.intercept('userNotFound', () => Errors.USER_NOT_FOUND);
return {
item: {
apiKey,
},
};
},
};