{"size": 914, "ext": "js", "max_stars_repo_path": "__tests__/_regressionsApp.js", "max_stars_repo_name": "yacinehmito/express-inspector", "max_stars_repo_stars_event_min_datetime": "2018-01-21T22:15:03.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-06T17:56:05.000Z", "max_issues_repo_path": "__tests__/_regressionsApp.js", "max_issues_repo_name": "yacinehmito/express-inspector", "max_issues_repo_issues_event_min_datetime": "2018-01-14T12:38:24.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-26T21:28:30.000Z", "max_forks_repo_path": "__tests__/_regressionsApp.js", "max_forks_repo_name": "yacinehmito/express-inspector", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 13, "max_forks_count": null, "avg_line_length": 18.28, "max_line_length": 60, "alphanum_fraction": 0.5831509847}
const express = require("express");

const app = express();

// Testing simple case
app.post("/foos", (req, res) => {
  res.send("POST /foos");
});

// Testing global middleware
app.use((err, req, res, next) => {
  if (err) {
    res.status(400).send("Simple error handler middleware");
  }
  next();
});

// Testing method chain
app
  .route("/foos/:id")
  .get((req, res) => {
    res.send(`GET /foos/${req.params.id}`);
  })
  .delete((req, res) => {
    res.send(`DELETE /foos/${req.params.id}`);
  });

// Testing Router
const router = express.Router();

router.get("/", (req, res) => {
  res.send("GET /bars");
});

router.get("/:id", (req, res) => {
  res.send(`GET /bars/${req.params.id}`);
});

app.use("/bars", router);

// Testing local middleware
function localMiddleware(req, res, next) {
  next();
}
app.get("/baz", localMiddleware, (req, res) => {
  res.send("GET /baz");
});

module.exports = app;
