Reputation: 76
In firebase, How can I create a realtime-database from nodejs code,
I already realize created a GCP, and add firebase with the next code,
private async getAuthToken(file : string) {
const auth = new google.auth.GoogleAuth({
keyFile: file,
scopes: scopes,
});
return auth;
}
private async createCGP(auth:any, resource: any) {
const request = {
resource: resource,
auth: auth
};
try {
const response = (await cloudresourcemanager.projects.create(request)).data;
return { success: true, resp: response };
} catch (err) {
return { success: false, resp: err, msg: 'error on create GCP' };
}
}
private async addFirebaseToCGP(auth:any, projectId:any, resource: any) {
const request = {
"project": 'projects/' + projectId,
"resource":resource,
auth: auth
};
try {
const response = (await firebase.projects.addFirebase(request)).data;
console.log(response.data);
return { success: true, resp: response };
} catch (err) {
return { success: false, resp: err , msg: 'error on add firebase'};
}
}
private async getOperationStatus(auth:any, operationName:any) {
const request = {
name: operationName,
auth: auth,
};
try {
const response = (await cloudresourcemanager.operations.get(request)).data;
return { success: true, resp: response };
} catch (err) {
return { success: false, resp: err, msg: 'error on get operation' };
}
}
now I need to create a real-time database for my project.
Do you have any suggestions? , I didn't find any documentation only this link but it doesn't work
Upvotes: 1
Views: 51
Reputation: 4174
Realtime Database is a part of the Firebase suite of tools and while managed on top of the GCP service, uses its own set of modules.
With node, this is often done with the admin-sdk but this can leave security vulnerabilities if this is a client app.
Admin-sdk setup with Realtime DB
On the other hand, the web packs can work in node as well
Upvotes: 1