아예 functions라는 이름의 HTTP기반 node.js application 도 올릴 수 있다.
잘하면 meteor도 올릴 수 있을 거 같긴한데 일단 나중에 볼 일이고
https://firebase.google.com/docs/functions/get-started 따라 해보자
먼저 init 부터
$ firebase init functions
🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥 🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥
🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥
🔥🔥🔥🔥🔥🔥 🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥
🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥
🔥🔥 🔥🔥🔥🔥 🔥🔥 🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥 🔥🔥 🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥
You're about to initialize a Firebase project in this directory:
/Users/spectrum/Documents/js/_firebaseApp/sheepals
Before we get started, keep in mind:
* You are initializing in an existing Firebase project directory
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
i .firebaserc already has a default project, skipping
=== Functions Setup
A functions directory will be created in your project with a Node.js
package pre-configured. Functions can be deployed with firebase deploy.
✔ Wrote functions/package.json
✔ Wrote functions/index.js
? Do you want to install dependencies with npm now? Yes
물어봐주면 Yes. 그러면 firebase-admin과 firebase-functions를 설치한다.
i Writing configuration info to firebase.json...
i Writing project information to .firebaserc...
✔ Firebase initialization complete!
설치 끝.
cd funtions 해서 뭐뭐가 있는지 보자.
Dashboard에 가면 이런게 생겼고
잘 작동한다.
Firebase.. 무서운 아이!
로그를 보면
실행하는데 얼마나 걸렸는지도 나오고 Functions별 검색도 아주 잘된다.
그래도 구글이 호구는 아닌게 https://github.com/firebase/functions-samples/tree/master/stripe 같은 예를 보면 non-Google 서비스를 사용할 때엔 유료플랜인 Blaze나 Flame으로 변경해야 되나보다.
잘하면 meteor도 올릴 수 있을 거 같긴한데 일단 나중에 볼 일이고
https://firebase.google.com/docs/functions/get-started 따라 해보자
먼저 init 부터
$ firebase init functions
🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥 🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥
🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥
🔥🔥🔥🔥🔥🔥 🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥
🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥
🔥🔥 🔥🔥🔥🔥 🔥🔥 🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥 🔥🔥 🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥
You're about to initialize a Firebase project in this directory:
/Users/spectrum/Documents/js/_firebaseApp/sheepals
Before we get started, keep in mind:
* You are initializing in an existing Firebase project directory
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
i .firebaserc already has a default project, skipping
=== Functions Setup
A functions directory will be created in your project with a Node.js
package pre-configured. Functions can be deployed with firebase deploy.
✔ Wrote functions/package.json
✔ Wrote functions/index.js
? Do you want to install dependencies with npm now? Yes
물어봐주면 Yes. 그러면 firebase-admin과 firebase-functions를 설치한다.
i Writing configuration info to firebase.json...
i Writing project information to .firebaserc...
✔ Firebase initialization complete!
설치 끝.
cd funtions 해서 뭐뭐가 있는지 보자.
index.js다 있다. 끝내주네. package.json 하고 node_modules 폴더 있는 걸 보면 게임 오버네.
node_modules
package.json
var functions = require('firebase-functions');
// Create and Deploy Your First Cloud Functions
// https://firebase.google.com/docs/functions/write-firebase-functions
exports.helloWorld = functions.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
});
주석을 제거하고 실행해보자.
firebase deploy --only functions
로 functions만 적용이 가능하다.
꽤 시간이 걸리는데 과연 로컬환경 구성 같은 건 없나? 불편불편.
$ firebase deploy --only functions
=== Deploying to 'sheepals-2f2d6'...
i deploying functions
i functions: ensuring necessary APIs are enabled...
i runtimeconfig: ensuring necessary APIs are enabled...
✔ runtimeconfig: all necessary APIs are enabled
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (859 B) for uploading
✔ functions: functions folder uploaded successfully
i starting release process (may take several minutes)...
i functions: creating function helloWorld...
✔ functions[helloWorld]: Successful create operation.
✔ functions: all functions deployed successfully!
✔ Deploy complete!
Project Console: https://console.firebase.google.com/project/sheepals-2f2d6/overview
Function URL (helloWorld): https://us-central1-sheepals-2f2d6.cloudfunctions.net/helloWorld
하 테스트할 URL까지 뽑아주네.
잘 작동한다.
Firebase.. 무서운 아이!
로그를 보면
실행하는데 얼마나 걸렸는지도 나오고 Functions별 검색도 아주 잘된다.
그래도 구글이 호구는 아닌게 https://github.com/firebase/functions-samples/tree/master/stripe 같은 예를 보면 non-Google 서비스를 사용할 때엔 유료플랜인 Blaze나 Flame으로 변경해야 되나보다.
댓글
댓글 쓰기