mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
c298db912c
- this adds a simple set of types to the @tryghost/api-framework package that should describe all of the keys available on a controller, and then rolls it out to all API controllers - unfortunately, due to https://github.com/microsoft/TypeScript/issues/47107, we have to split apart `module.exports` into a variable assignment in order for type-checking to be done - the main benefit of this is that `frame` is now typed, and editors understand what keys are available, so intellisense works properly
28 lines
911 B
JavaScript
28 lines
911 B
JavaScript
/** @typedef {object} PermissionsObject */
|
|
/** @typedef {boolean} PermissionsBoolean */
|
|
|
|
/** @typedef {number} StatusCodeNumber */
|
|
/** @typedef {(result: any) => number} StatusCodeFunction */
|
|
|
|
/** @typedef {object} ValidationObject */
|
|
|
|
/**
|
|
* @typedef {object} ControllerMethod
|
|
* @property {object} headers
|
|
* @property {PermissionsBoolean | PermissionsObject} permissions
|
|
* @property {string[]} [options]
|
|
* @property {ValidationObject} [validation]
|
|
* @property {string[]} [data]
|
|
* @property {StatusCodeFunction | StatusCodeNumber} [statusCode]
|
|
* @property {object} [response]
|
|
* @property {function} [cache]
|
|
* @property {(frame: import('./lib/Frame')) => object} [generateCacheKeyData]
|
|
* @property {(frame: import('./lib/Frame')) => any} query
|
|
*/
|
|
|
|
/**
|
|
* @typedef {Record<string, ControllerMethod | string> & Record<'docName', string>} Controller
|
|
*/
|
|
|
|
module.exports = require('./lib/api-framework');
|