기본 콘텐츠로 건너뛰기

라벨이 firebase인 게시물 표시

firebase functions 위에 올라간 apollo server 에 apollo engine 끼얹기

이전 글에서 계속. https://www.apollographql.com/docs/engine/setup-node.html  보고 진행해보자. 미리 가입하고 키도 받아놓자. ENGINE_API_KEY 를 잘 copy 해놓자. app.use '/graphql',   bodyParser.json()   graphqlExpress {     schema     context: {}     tracing: true     cacheControl: true   } 먼저 /graphql 쪽 graphqlExpress 에 두개의 키(tracing, cacheControl)를 추가하자. npm install --save compression apollo-engine 두 패키지를 설치하고 compression = require 'compression' { Engine } = require 'apollo-engine' 압축과 엔진을 추가하고 engine을 하나 만들자. engine = new Engine   engineConfig:     apiKey: 'service:acidsound-6459:wKt62uPKS9dmxmBhFh-cZA'   endpoint: '/api/graphql'   graphqlPort: process.env.PORT or 80 engine.start() 여기서 graphqlPort를 지정하지 않으면  Error: Neither 'graphqlPort' nor process.env.PORT is set. In order for Apollo Engine to act as a proxy for your GraphQL server, it needs to know which port your GraphQL server...

firebase /w functions + graphQL backend 만들기

persistence 영역을 graphQL 로 일반화 하고 apollo engine 같은 cache를 사용하고 싶다. firebase의 functions를 통해 firebase를 불러오는 건 사실상 이중 작업인 것 같지만 apollo engine이 매우 맘에 들어 끌어들이고 싶다. 먼저 해볼 것은 functions에 graphql을 집어넣고 정적데이터를 읽어오는 것 먼저 로컬에서 구현해본다. 프로젝트 폴더를 생성하고 firebase init functions 부터 하자. 프로젝트를 선택(혹은 생성하고 ? What language would you like to use to write Cloud Functions? JavaScript ✔  Wrote functions/package.json ✔  Wrote functions/index.js 그냥 firebase init 하고 functions를 선택하는 것과는 달리 뭔가 기본 scaffold를 생성해줘서 좋다. {   "functions": {     "source": "functions"   } } 디폴트로 이렇게 해주자. index.coffee 로 get 테스트. exports하는 놈 이름이 functions 이름이 되고 경로도 /[exports한 놈]/ 이 되는 점이 특징이다. functions = require 'firebase-functions' admin = require 'firebase-admin' admin.initializeApp functions.config().firebase exports.addMessage = functions.https.onRequest (req, res)->   original = req.query.text?   admin.firestore()     .collection 'messages'     .add { origin...

firebase 일기(+expo)

firebase instance를 만들자. https://console.firebase.google.com/project/<YOURAPP>-90431/overview 로 들어가보면 Welcome to Firebase! Get started here. 라고 반긴다. 필요한 설정을 복사하자. Add Firebase to your web app 를 눌러 <script src="https://www.gstatic.com/firebasejs/4.6.0/firebase.js"></script> <script>   // Initialize Firebase   var config = {     apiKey: "ㅌㅌㅌㅌㅌㅌㅌㅌ",     authDomain: "ㅅㅅㅅㅅ-90431.firebaseapp.com",     databaseURL: "https://ㅅㅅㅅㅅ-90431.firebaseio.com",     projectId: "ㅅㅅㅅㅅ-90431",     storageBucket: "ㅅㅅㅅㅅ-90431.appspot.com",     messagingSenderId: "11111111111"   };   firebase.initializeApp(config); </script> 이 부분 중 config만 복사. Authentication > sign-in method 에 몇개 연결하고 Template을 한번 슥 본다. 음 다국어 처리가 되있군. 굿. Database, Storage, Hosting, Functions 죄다 켜고. Grow 에 Remote Config라는게 있어서 Software Version 같은 걸 한번 넣어봤다. 프로그래마틱하게도 설정 가능한 거 같다. 잘 모르겠다. https://firebase.g...

Firebase coffeescript snippet

firebase 단순 예제 좋은게 없어서 찾다가 문서보고 하나 짰다. 흔한 Firebase 자료구조.png https://console.firebase.google.com 에서 본 Database 구조가 위와 같을 때 config =   apiKey: '<<<<<<<<<>>>>>>>>>>'   authDomain: '<<<<<<<<<>>>>>>>>>>'   databaseURL: '<<<<<<<<<>>>>>>>>>>'   projectId: '<<<<<<<<<>>>>>>>>>>'   storageBucket: '<<<<<<<<<>>>>>>>>>>'   messagingSenderId: '<<<<<<<<<>>>>>>>>>>' firebase.initializeApp config ref = firebase.database().ref('rooms/muka/messages') # database 경로 ref.on 'child_added', (o) ->   # key:0. val();"text":"블라블라"   # key:1. val();"text":"블라블라"...

Firebase Functions - backend 로직을 구축해보자.

아예 functions라는 이름의 HTTP기반 node.js application 도 올릴 수 있다. 잘하면 meteor도 올릴 수 있을 거 같긴한데 일단 나중에 볼 일이고 https://firebase.google.com/docs/functions/get-started  따라 해보자 먼저 init 부터 $ firebase init functions      🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥  🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥     🔥🔥🔥     🔥🔥🔥🔥🔥🔥  🔥🔥🔥🔥🔥🔥🔥🔥      🔥🔥        🔥🔥  🔥🔥     🔥🔥 🔥🔥       🔥🔥     🔥🔥  🔥🔥   🔥🔥  🔥🔥       🔥🔥      🔥🔥🔥🔥🔥🔥    🔥🔥  🔥🔥🔥🔥🔥🔥🔥🔥  🔥🔥🔥🔥🔥🔥   🔥🔥🔥🔥🔥🔥🔥🔥  🔥🔥🔥🔥🔥🔥🔥🔥🔥  🔥🔥🔥🔥🔥🔥  🔥🔥🔥🔥🔥🔥      🔥🔥        🔥🔥  🔥🔥    🔥🔥  🔥🔥       🔥🔥     🔥🔥 🔥🔥     🔥🔥       🔥🔥 🔥🔥      🔥🔥     ...

Firebase 정적 호스팅

이번 google I/O도 그렇고 꾸준히 firebase를 밀고 있다. 디비 뿐만 아니라 정적 호스팅도 해준다는 소식에 혹 해서 살짝 내용을 살펴보았다. https://firebase.google.com/docs/hosting/quickstart https://console.firebase.google.com/ 먼저 firebase 콘솔로 들어가서 프로젝트를 하나 만들자. Add Project를 누르면 프로젝트 이름과 지역을 설정할 수 있다. 적절히 넣어주고 Create Project하여 프로젝트를 만들고 당연한 이야기지만 0.10.x 이상의 Node.js를 설치한 상태로 firebase-tools를 먼저 설치하자 npm install -g firebase-tools 좀 시간이 걸린다. 다 되면 폴더를 하나 만들고 그 안에서 init으로 초기화를 하자. mkdir exam1 cd exam1 firebase init      🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥  🔥🔥🔥🔥🔥🔥🔥🔥 🔥🔥🔥🔥🔥🔥🔥🔥     🔥🔥🔥     🔥🔥🔥🔥🔥🔥  🔥🔥🔥🔥🔥🔥🔥🔥      🔥🔥        🔥🔥  🔥🔥     🔥🔥 🔥🔥       🔥🔥     🔥🔥  🔥🔥   🔥🔥  🔥🔥       🔥🔥      🔥🔥🔥🔥🔥🔥    🔥🔥  🔥🔥🔥🔥🔥🔥🔥🔥  🔥🔥🔥🔥🔥🔥   🔥🔥🔥🔥🔥🔥🔥🔥  🔥🔥🔥🔥🔥🔥🔥🔥🔥 ...