Skip to content

Instantly share code, notes, and snippets.

@doyle-flutter
Last active October 16, 2024 03:02
Show Gist options
  • Save doyle-flutter/8970c926b6981143d0c59dcd4ce8e34d to your computer and use it in GitHub Desktop.
Save doyle-flutter/8970c926b6981143d0c59dcd4ce8e34d to your computer and use it in GitHub Desktop.
firebase data connect & expressjs - firebase admin
const express = require('express');
const app = express();
const serviceAccount = require([path/file_name.json]); /// Firebase -> 프로젝트 설정 -> 서비스 계정 -> 비공개 키 생성
const admin = require('firebase-admin');
const { getDataConnect } = require('firebase-admin/data-connect');
const firebaseApp = admin.initializeApp({credential: admin.credential.cert(serviceAccount)});
const serviceId = "[Connect-ServiceID]"; // 영상 내 확인
const location = "[LOCATION]"; // 영상 내 확인
const dataConnect = getDataConnect({serviceId,location});
app.listen(8000);
app.get("/", async (req,res) => {
const query = `query {
users {
id
uid
name
address
}
}`;
const connectData = await dataConnect.executeGraphqlRead(query);
res.json({connectData});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment