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
// input - async/awaiy with CommonJS module syntax | |
const functions = require('firebase-functions'); | |
// returns a string after 5 seconds | |
const message = () => { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
resolve(`from Babelified Cloud Functions!`) | |
}, 5000) | |
}) |
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
// Babel output - with Babel REPL settings: | |
// * prettify | |
// * preset-env Node v6.9 | |
"use strict"; | |
function _asyncToGenerator(fn) { | |
return function() { | |
var gen = fn.apply(this, arguments); | |
return new Promise(function(resolve, reject) { |
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
// Babel output - with Babel REPL settings: | |
// * prettify | |
// * preset-es2015 (es6->es5) | |
// * preset-es2016 (es7->es6) | |
// * preset-es2017 (es8->es7) | |
"use strict"; | |
function _asyncToGenerator(fn) { | |
return function() { |
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
// Babel output - with Babel REPL settings: | |
// * preset-es2015 | |
"use strict"; | |
var functions = require("firebase-functions"); | |
var message = function message() { | |
return new Promise(function(resolve) { | |
setTimeout(function() { | |
resolve("from Babelified Cloud 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
// input - using ES module syntax | |
import * as functions from 'firebase-functions'; | |
export let helloWorld = functions.https.onRequest((req, res) => { | |
let world = `from Babelified Cloud Functions!`; | |
res.status(200).send(`Hello ${world}`); | |
}) | |
// Babel output - with Babel REPL settings: | |
// * prettify |
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
// input - using CommonJS module syntax | |
const functions = require('firebase-functions') | |
module.exports.helloWorld = functions.https.onRequest((req, res) => { | |
let world = `from Babelified Cloud Functions!`; | |
res.status(200).send(`Hello ${world}`); | |
}) | |
// Babel output - with Babel REPL settings: | |
// * preset-es2015 |
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
{ | |
"hosting": { | |
"public": "src/public", | |
"rewrites": [ | |
{ | |
"source": "**/**", | |
"function": "next" | |
} | |
] | |
}, |
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
{ | |
"name": "nextonfirebase", | |
"version": "1.0.0", | |
"license": "MIT", | |
"scripts": { | |
"install": "yarn build-all", | |
"next": "yarn build-firebase && cd \"src/app\" && yarn && yarn dev", | |
"preserve": "yarn build-all", | |
"serve": "firebase serve", | |
"predeploy": "yarn build-all", |
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
const functions = require("firebase-functions") | |
const next = require("next") | |
var dev = process.env.NODE_ENV !== "production" | |
var app = next({ dev, conf: { distDir: "next" } }) | |
var handle = app.getRequestHandler() | |
exports.next = functions.https.onRequest((req, res) => { | |
console.log("File: " + req.originalUrl) // log the page.js file that is being requested | |
return app.prepare().then(() => handle(req, res)) |
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
# src/functions/.gitignore | |
next |