Skip to content

Instantly share code, notes, and snippets.

@serinuntius
Last active November 6, 2018 11:52
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 serinuntius/816c744966c17e3a68f21ce819f322d5 to your computer and use it in GitHub Desktop.
Save serinuntius/816c744966c17e3a68f21ce819f322d5 to your computer and use it in GitHub Desktop.
firebaseとexpressの最小構成サンプル(?)
const functions = require('firebase-functions');
const express = require("express");
const app = express();
app.get('/hoge', (req, res) => {
res.send('hoge')
});
const api = functions.https.onRequest(app);
module.exports = {api};
@serinuntius
Copy link
Author

serinuntius commented Nov 6, 2018

上記コードは動作確認をしておりません。

動いてるコードを最小構成にしたらこんな感じになりました。

基本的には

firebase login
firebase init

あたりをしておけば問題ないと思います。

ハマるかもしれないポイントは、 module.exports = {api}; で渡してるので自動的に /api というネームスペースが切られるところでしょうか?

curl <host>/api/hoge でアクセスできるはずです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment