Skip to content

Instantly share code, notes, and snippets.

@simonprickett
Created May 23, 2021 15:28
Show Gist options
  • Select an option

  • Save simonprickett/4786c884c96b5ff538d7ffdcb91280a1 to your computer and use it in GitHub Desktop.

Select an option

Save simonprickett/4786c884c96b5ff538d7ffdcb91280a1 to your computer and use it in GitHub Desktop.
Getting Started with Express Part 1: Database information route
app.get('/dbinfo', (req, res) => {
const dbKeys = Object.keys(db);
const info = {
size: dbKeys.length
};
if ('true' === req.query.details) {
info.keys = dbKeys;
}
res.json(info);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment