Skip to content

Instantly share code, notes, and snippets.

@joshghent
Created March 5, 2019 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshghent/c11698f57e8c9122dfd7eec64b9f626d to your computer and use it in GitHub Desktop.
Save joshghent/c11698f57e8c9122dfd7eec64b9f626d to your computer and use it in GitHub Desktop.
Router
import { Router } from "express";
import { Config } from "./configuration";
// Import or require the graphite controller and activity labels
import { GraphiteController, GraphiteLabel } from "../graphite";
const router = Router() as Router;
// Load your config
const config = Config.getConfig();
// Import the graphite controller
const graphiteController = GraphiteController.getInstance(config);
router.get("/", async (req, res, next) => {
try {
const record = await UserController.get(req.query, req.jwt.accountId);
if (record) {
// Just before the response is sent, we log the route being called
graphiteController.write(“GetUsers”);
res.json({ success: true, data: record });
} else {
res.status(404).send();
}
} catch (err) {
next(new InternalServerError("There was an error getting data from the database"));
}
});
export default router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment