How to use the http-status.NOT_FOUND function in http-status

To help you get started, we’ve selected a few http-status 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 shortlist-digital / tapestry-wp / src / shared / route-wrapper.js View on Github external
const RouteWrapper = config => {
  // if user routes have been defined, take those in preference to the defaults
  const errorResponse = {
    code: HTTPStatus.NOT_FOUND,
    message: HTTPStatus[HTTPStatus.NOT_FOUND]
  }
  const routes = config.routes || defaultRoutes(config.components)
  const ErrorComponent = () =>
    RenderError({
      config,
      response: errorResponse
    })
  // loops over routes and return react-router  components
  return (
    
      {routes.map(route => {
        // cancel if component not defined in user config, joi will validate user routes for component/path keys
        if (!route.component && !route.getComponent) {
          route.component = null
        }
        // on 'route' event:
github deepstreamIO / deepstream.io / src / connection-endpoint / http / node-server.ts View on Github external
HTTPStatus.BAD_REQUEST,
          `Failed to parse body of request: ${err.message}`
        )
        return
      }
      const onResponse = Server.onHandlerResponse.bind(null, response)
      const metadata = { headers: request.headers, url: request.url }

      if (this.config.enableAuthEndpoint && this.authPathRegExp.test(request.url)) {
        this.httpEvents.onAuthMessage(request.body, metadata, onResponse)

      } else if (this.postPathRegExp.test(request.url)) {
        this.httpEvents.onPostMessage(request.body, metadata, onResponse)

      } else {
        Server.terminateResponse(response, HTTPStatus.NOT_FOUND, 'Endpoint not found.')
      }
    })
  }
github WaftTech / WaftEngine / server / app.js View on Github external
app.use((err, req, res, next) => {
  if (err.status === 404) {
    return otherHelper.sendResponse(res, httpStatus.NOT_FOUND, false, null, err, 'Route Not Found', null);
  } else {
    console.log('\x1b[41m', err);
    AddErrorToLogs(req, res, next, err);
    return otherHelper.sendResponse(res, httpStatus.INTERNAL_SERVER_ERROR, false, null, err, null, null);
  }
});
github IBM / taxinomitis / src / lib / training / visualrecognition.ts View on Github external
export async function deleteClassifierFromBluemix(
    credentials: TrainingObjects.BluemixCredentials,
    classifierId: string,
): Promise
{
    const req = await createBaseRequest(credentials);

    try {
        const url = credentials.url + '/v3/classifiers/' + encodeURIComponent(classifierId);
        await request.delete(url, req);
    }
    catch (err) {
        if (err.statusCode === httpStatus.NOT_FOUND) {
            log.debug({ classifierId }, 'Attempted to delete non-existent classifier');
            return;
        }
        throw err;
    }
}
github IBM / taxinomitis / src / lib / utils / download.ts View on Github external
.catch ((err: any) => {
            if (err.statusCode === httpstatus.NOT_FOUND || err.message === 'ETIMEDOUT') {
                log.warn({ err, url }, 'Image could not be downloaded');
            }
            else if (err.statusCode === httpstatus.FORBIDDEN || err.statusCode === httpstatus.UNAUTHORIZED) {
                log.warn({ err, url }, 'Image download was forbidden');
                return resolve(new Error(safeGetHost(url) + ERRORS.DOWNLOAD_FORBIDDEN));
            }
            else {
                log.error({ err, url }, 'Download fail (probe)');
            }
            resolve(new Error(ERRORS.DOWNLOAD_FAIL + url));
        });
}
github IBM / taxinomitis / archive / nlc.ts View on Github external
classifierId: string,
): Promise
{
    const req = {
        auth : {
            user : credentials.username,
            pass : credentials.password,
        },
    };

    try {
        await request.delete(credentials.url + '/v1/classifiers/' + classifierId,
                             req);
    }
    catch (err) {
        if (err.statusCode === httpStatus.NOT_FOUND) {
            log.debug({ classifierId }, 'Attempted to delete non-existent classifier');
            return;
        }
        throw err;
    }
}
github eclipse / repairnator / website / repairnator-mongo-rest-api / server / models / pipeline-error.model.js View on Github external
.then((pipelineError) => {
         if (pipelineError) {
           return pipelineError;
         }
         const err = new APIError('No such pipelineError data exists!', httpStatus.NOT_FOUND);
         return Promise.reject(err);
       });
  },
github Codeminer42 / cm42-central / app / assets / javascripts / actions / notifications.js View on Github external
switch (error.response.status) {
      case status.UNPROCESSABLE_ENTITY:
        return dispatch(
          addValidationNotifications(error.response.data.story.errors)
        );
      case status.UNAUTHORIZED:
        return dispatch(
          addNotification(
            Notification.createNotification({
              type,
              message: I18n.t('users.You are not authorized to perform this action')
            })
          )
        );
      case status.NOT_FOUND:
        return dispatch(
          addNotification(
            Notification.createNotification({
              type,
              message: I18n.t('not_found')
            })
          )
        );
      default:
        return dispatch(
          addDefaultErrorNotification(Notification)
        );
    }
  }
github SoftwareEngineeringDaily / software-engineering-daily-api / server / models / comment.model.js View on Github external
.then((comment) => {
        if (comment) {
          this.upadteDeletedContent(comment);
          return comment;
        }
        const err = new APIError('No such comment exists!', httpStatus.NOT_FOUND);
        return Promise.reject(err);
      });
  },