Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async getKey( @QueryParam('keyPath') keyPath: string, @QueryParam('revision') revision?: string): Promise {
try {
return await this.keysRepository.getKeyDetails(keyPath, { revision });
} catch (exp) {
logger.error(`Error retrieving key ${keyPath}`, exp);
throw new Errors.NotFoundError();
}
}
private async getMiddleware(type: string, name: string): Promise {
try {
const value = await this.service.read(type, name);
return new Return.DownloadBinaryData(value, 'application/javascript', name + '.js');
} catch (err) {
throw new Errors.NotFoundError();
}
}
async getManifest( @QueryParam('keyPath') keyPath: string, @QueryParam('revision') revision?: string): Promise {
try {
return await this.keysRepository.getKeyManifest(keyPath, { revision });
} catch (exp) {
throw new Errors.NotFoundError();
}
}
async deleteHook(
@PathParam('id') id: string,
@QueryParam('author.name') name: string,
@QueryParam('author.email') email: string,
): Promise {
try {
const hooksRepository = this.hooksRepositoryFactory.createRepository();
if (!(await this._handleETagValidation(hooksRepository))) return;
const oid = await hooksRepository.deleteHook(id, { name, email });
addOid(this.context.response, oid);
} catch (err) {
logger.error({ err, hookId: id }, err.message);
throw new Errors.NotFoundError();
}
}
async updateHook(
@PathParam('id') id: string,
@QueryParam('author.name') name: string,
@QueryParam('author.email') email: string,
hook: Hook,
): Promise {
try {
const hooksRepository = this.hooksRepositoryFactory.createRepository();
hook = { id, keyPath: hook.keyPath, type: hook.type, url: hook.url };
if (!(await this._handleETagValidation(hooksRepository))) return;
const oid = await hooksRepository.updateHook(hook, { name, email });
addOid(this.context.response, oid);
} catch (err) {
logger.error({ err, hook }, err.message);
throw new Errors.NotFoundError();
}
}
return new Promise>>((resolve, reject) =>{
let apiConfig = this.gateway.getApiConfig(apiId);
if (!apiConfig) {
return reject(new Errors.NotFoundError("API not found"));
}
if (path) {
let stats = this.statsRecorder.createStats(Stats.getStatsKey(prefix, apiConfig.path, key))
stats.getLastOccurrences(count||24, path, ...extra)
.then(resolve)
.catch(reject);
}
else {
return reject(new Errors.ForbidenError("Path parameter is required."));
}
});
}