I have the following express server:
import * as express from "express";
import * as bodyParser from "body-parser";
import * as mongoose from "mongoose";
import { Routes } from "./routes/transactions";
import { authMiddleware } from "./middleware/auth";
import { errorMiddleware } from "./middleware/error";
class App {
  public app: express.Application;
  public routeProvider: Routes = new Routes();
  public mongoUrl: string = "mongodb://...:...@mydomain.com:27017/mycollection"; // This should be read from github CLI
  constructor() {
    this.app = express();
    this.config();
    this.routeProvider.routes(this.app);
    this.mongoSetup();
  }
  private config(): void {
    this.app.use(bodyParser.json());
    this.app.use(bodyParser.urlencoded({ extended: false }));
    this.app.use(errorMiddleware);
    this.app.use(authMiddleware);
  }
  private mongoSetup(): void {
    mongoose.Promise = global.Promise;
    mongoose.connect(
      this.mongoUrl,
      { useNewUrlParser: true }
    );
  }
}
export default new App().app;
This is the authMiddleware (almost the same as the guide on the auth0 site for usage with node.js):
import * as jwt from "express-jwt";
import { expressJwtSecret } from "jwks-rsa";
export function authMiddleware() {
  return jwt({
    secret: expressJwtSecret({
      cache: true,
      rateLimit: true,
      jwksRequestsPerMinute: 5,
      jwksUri: "..."
    }),
    audience: "...",
    issuer: "...",
    algorithms: ["RS256"]
  });
}
And my error middleware:
import { Request, Response } from "express";
export function errorMiddleware(err, req: Request, res: Response, next) {
  console.error(err.stack);
  res.status(500).send("Something broke!");
}
Now what would expect to happen - since I broke all the auth and mongodb URLs on purpose, that I would get a status code 500 with the message Something broke!.
Instead I get the
Could not get any response
message when sending a requst using postman.
What am I doing wrong?
 
    