How to use the typescript-rest.Errors.NotFoundError function in typescript-rest

To help you get started, we’ve selected a few typescript-rest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Soluto / tweek / services / authoring / src / routes / keys.ts View on Github external
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();
    }
  }
github TreeGateway / tree-gateway / src / admin / api / middleware.ts View on Github external
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();
        }
    }
github Soluto / tweek / services / authoring / src / routes / keys.ts View on Github external
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();
    }
  }
github Soluto / tweek / services / authoring / src / routes / hooks.ts View on Github external
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();
    }
  }
github Soluto / tweek / services / authoring / src / routes / hooks.ts View on Github external
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();
    }
  }
github TreeGateway / tree-gateway / src / lib / admin / api / stats.ts View on Github external
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."));
            }
        });
    }