Skip to content

Instantly share code, notes, and snippets.

@kameshsampath
Created August 30, 2018 17:03
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 kameshsampath/e550d5bf19feb9b59d0ec1871e59b53a to your computer and use it in GitHub Desktop.
Save kameshsampath/e550d5bf19feb9b59d0ec1871e59b53a to your computer and use it in GitHub Desktop.
import { Request, Response } from "express";
import { app, db } from "../app";
import { loadCollection } from "../utils/collectionUtils";
//Get all frames
app.get("/api/frames", async (req: Request, res: Response, next: any) => {
//TODO move this to higher order function
try {
const qCollection = await loadCollection("frames", db);
const docs = qCollection.find();
if (docs) {
return res
.contentType("json")
.status(200)
.send(docs);
}
} catch (err) {
res.status(404).send(err);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment