* allow serviceData to override cacheSeconds with a longer value * prevent [endpoint] json cacheSeconds property exceeding service default * allow ShieldsRuntimeError to specify a cacheSeconds property By default error responses use the cacheLength of the service class throwing the error. This allows error to tell the handling layer the maxAge that should be set on the error badge response. * add customExceptions param This 1. allows us to specify custom properties to pass to the exception constructor if we throw any of the standard got errors e.g: `ETIMEDOUT`, `ECONNRESET`, etc 2. uses a custom `cacheSeconds` property (if set on the exception) to set the response maxAge * customExceptions --> systemErrors * errorMessages --> httpErrors
39 lines
865 B
JavaScript
39 lines
865 B
JavaScript
import { BaseJsonService } from '../index.js'
|
|
|
|
const keywords = [
|
|
'visual-studio',
|
|
'vsac',
|
|
'visual-studio-app-center',
|
|
'app-center',
|
|
]
|
|
|
|
const documentation =
|
|
"You will need to create a <b>read-only</b> API token <a target='_blank' href='https://appcenter.ms/settings/apitokens'>here</a>."
|
|
|
|
class BaseVisualStudioAppCenterService extends BaseJsonService {
|
|
async fetch({
|
|
owner,
|
|
app,
|
|
token,
|
|
schema,
|
|
url = `https://api.appcenter.ms/v0.1/apps/${owner}/${app}/releases/latest`,
|
|
}) {
|
|
return this._requestJson({
|
|
schema,
|
|
options: {
|
|
headers: {
|
|
'X-API-Token': token,
|
|
},
|
|
},
|
|
httpErrors: {
|
|
401: 'invalid token',
|
|
403: 'project not found',
|
|
404: 'project not found',
|
|
},
|
|
url,
|
|
})
|
|
}
|
|
}
|
|
|
|
export { keywords, documentation, BaseVisualStudioAppCenterService }
|