Last active
June 23, 2017 19:15
-
-
Save brygrill/27e4bbf66e96bd12f2672e4a7a10cd8c to your computer and use it in GitHub Desktop.
Deploying a GraphQL Server with Firebase Functions
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
// 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