Skip to content

Instantly share code, notes, and snippets.

@brygrill
Last active June 23, 2017 19:15
Show Gist options
  • Save brygrill/27e4bbf66e96bd12f2672e4a7a10cd8c to your computer and use it in GitHub Desktop.
Save brygrill/27e4bbf66e96bd12f2672e4a7a10cd8c to your computer and use it in GitHub Desktop.
Deploying a GraphQL Server with Firebase Functions
// via https://github.com/firebase/functions-samples/blob/master/quickstarts/big-ben/functions/index.js
const functions = require('firebase-functions');
// endpoint would be the <the url firebase gives you>/bigben
exports.bigben = functions.https.onRequest((req, res) => {
// you have access to standard express req and res inside function
const hours = (new Date().getHours() % 12) + 1; // london is UTC + 1hr;
res.status(200).send(`<!doctype html>
<head>
<title>Time</title>
</head>
<body>
${'BONG '.repeat(hours)}
</body>
</html>`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment