How to install Rowy easily
What is Rowy?
I stumbled upon Rowy a couple of days ago and was astonished by the quality of this tool. And once I started to see how one could easily deploy a new instance of Rowy by self hosting everything directly in Cloud Run, I was then sure.
This tool was made with modern development techniques and I had to try it with one of my own Firebase project.
Rowy is a tool to map your Firestore data to something more usable, like common SQL tables, for administration. But what makes it extremely powerful are all the added extensions and Webhooks (I'll cover this on a future tutorial so don't hesitate to subscribe to the free newsletter to get all my last articles or follow me on Twitter).
How to install it
Going on Rowy's website gives you all the information to start quickly. Don't forget to activate Google Sign In on your Firebase Project (we get so used to tick checkboxes without reading them ...).
Once it's done, you'll first have to add your Rowy URL to the list of authorised domains. Go to the Authentication settings and add your domain. It should be in the form of project-id.rowy.app.
Then after reloading the page you can finally connect with your Google Account. Unfortunately, this is where the onboarding misses a couple of steps. In order to add yourself as the first admin, you have to execute a small script. Rowy provides a version on its website, by I've written the same script in Typescript in order to make it easier to run.
Create 2 files in a folder:
index.ts
import admin from "firebase-admin";
const projectId = "YOUR_PROJECT_ID";
const serviceAccountPath =
"./YOUR_SERVICE_ACCOUNT.json";
const adminEmail = "YOUR_EMAIL";
console.log(`Running on ${projectId}`);
// ? Import your service account key file.
const serviceAccount = require(serviceAccountPath);
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: `https://${projectId}.firebaseio.com`,
});
export const auth = admin.auth();
const setClaims = async (email: string, claims: { roles: string[] }) => {
const user = await auth.getUserByEmail(email);
auth.setCustomUserClaims(user.uid, claims);
};
// ? Call the setClaims function. Set the email and roles here.
setClaims(adminEmail, {
roles: ["ADMIN"],
});
package.json
{
"dependencies": {
"firebase-admin": "^9.0.0"
},
"devDependencies": {
"ts-node": "^10.4.0",
"typescript": "^4.5.4"
}
}
Then add in the same folder the service account JSON for Firebase (click on Generate new private key) and modify the 3 variables of the .ts file with the proper values. Then you simply have to run:
npm install
./node_modules/.bin/ts-node index.ts
Now you should be able to log again into Rowy with your custom claims and enjoy your Firestore database in a new way!
Final thoughts
It's only been a couple of weeks since I discovered Rowy but I already fell in love with the tool for so many reasons. If you wanna keep discovering how to better manage your Firestore database, subscribe to my newsletter to know when a new article will be released! You can also drop me a message on Twitter if anything wasn't clear about this article.
Thanks for reading and see you soon ?