Created
March 5, 2019 18:02
-
-
Save joshghent/c11698f57e8c9122dfd7eec64b9f626d to your computer and use it in GitHub Desktop.
Router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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