Giter Club home page Giter Club logo

express-firebase-functions's Introduction

Firebase functions

Firebase 프로젝트를 사용할 때 단순 쿼리 외 api가 필요한 경우 Express 서버를 사용해 로직을 작성할 수 있는 보일러플레이트

src
├── apis
│   ├── auth
│   └── domain
├── config
├── firebase
└── index.ts
  • index.ts에 필요한 라우터를 추가해서 사용

  • apis/ 아래의 도메인 로직은 프로젝트에 맞추어 개발


사용 방법

초기 세팅

.env

KAKAO_KEY=
KAKAO_REDIRECT_URI=
SERVICE_ACCOUNT_ID=[admin ID]   # 카카오 로그인을 구현하지 않는다면 이것만 있어도 됨

.firebaserc

{
  "projects": {
    "default": [project name]
  }
}

실행 및 배포

yarn serve

  • Emulator를 실행하고 로컬에서 Express 서버를 테스트 할 수 있음

    ┌─────────────────────────────────────────────────────────────┐
    │ ✔  All emulators ready! It is now safe to connect your app. │
    │ i  View Emulator UI at http://127.0.0.1:4000/               │
    └─────────────────────────────────────────────────────────────┘
    
    ┌───────────┬────────────────┬─────────────────────────────────┐
    │ Emulator  │ Host:Port      │ View in Emulator UI             │
    ├───────────┼────────────────┼─────────────────────────────────┤
    │ Functions │ 127.0.0.1:5001 │ http://127.0.0.1:4000/functions │
    └───────────┴────────────────┴─────────────────────────────────┘
    Emulator Hub running at 127.0.0.1:4400
    Other reserved ports: 4500
  • Emulator 로그에 이렇게 나온다면 정상 동작하며 Postman 등으로 로컬에서 테스트 가능

    Watching "/[path]/functions" for Cloud Functions...
    
    Loaded functions definitions from source: api.
    
    http function initialized (http://127.0.0.1:5001/[project name]/[region]/api).

yarn deploy

  • 프로젝트 서버에 배포

  • 터미널 또는 Firebase 콘솔에서 경로 확인

    i  functions: creating Node.js 18 function api(us-central1)...
    ✔  functions[api(us-central1)] Successful create operation.
    Function URL (api(us-central1)): https://[path]/api
    i  functions: cleaning up build files...
    
    ✔  Deploy complete!
    
    Project Console: https://console.firebase.google.com/project/[project name]/overview
    ✨  Done in 113.20s.
  • 안되는거 아닌가 싶게 에러도 많이 나고 오래 걸리지만 로컬에서 동작한다면 문제 없는거니까 여러번 해보기

express-firebase-functions's People

Contributors

se030 avatar

Watchers

 avatar

express-firebase-functions's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.