Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/react-server / src / middleware / errorHandlers.ts
Size: Mime:
/* eslint-disable no-console */
/* eslint-disable no-unused-vars */
/**
 * @see https://gist.github.com/benjamingr/0237932cee84712951a2
 */
import { Request, Response, NextFunction } from 'express'

const errorHandlersMiddleware = [
  /**
   * 404 errors middleware.
   *
   * NOTE: the react application middleware hands 404 paths, but it is good to
   * have this backup for paths not handled by the react middleware. For
   * example you may bind a /api path to express.
   */
  function notFoundMiddlware(req: Request, res: Response, next: NextFunction) {
    res.status(404).send('Sorry, that resource was not found.')
  },

  /**
   * 500 errors middleware.
   *
   * NOTE: You must provide specify all 4 parameters on this callback function
   * even if they aren't used, otherwise it won't be used.
   */
  // function unexpectedErrorMiddleware(expressError, req, res, next) {
  //   if (expressError) {
  //     console.log(expressError)
  //     console.log(expressError.stack)
  //   }
  //   res.status(500).send('Sorry, an unexpected error occurred.')
  // },
]

export default errorHandlersMiddleware