-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move changelog to app rather than appversion
- Loading branch information
Showing
11 changed files
with
114 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const joi = require('joi') | ||
|
||
const paramsSchema = joi | ||
.object() | ||
.keys({ | ||
changelog: joi.string().allow('', null), | ||
d2config: joi.string().allow('', null), | ||
id: joi.string().uuid().required(), | ||
}) | ||
.options({ allowUnknown: false }) | ||
|
||
/** | ||
* Patches an app instance | ||
* | ||
* @param {object} params | ||
* @param {string} params.id id of the app to update | ||
* @param {number} params.changelog The changelog of the app | ||
* @param {string} params.d2config The latest d2config of the app | ||
* @returns {Promise<CreateUserResult>} | ||
*/ | ||
const patchApp = async (params, knex) => { | ||
const validation = paramsSchema.validate(params) | ||
|
||
if (validation.error !== undefined) { | ||
throw new Error(validation.error) | ||
} | ||
|
||
if (!knex) { | ||
throw new Error('Missing parameter: knex') | ||
} | ||
|
||
const { id, ...rest } = params | ||
|
||
try { | ||
await knex('app').update(rest).where({ | ||
id, | ||
}) | ||
} catch (err) { | ||
throw new Error(`Could not update app: ${id}. ${err.message}`) | ||
} | ||
} | ||
|
||
module.exports = patchApp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters