Skip to content

Conversation

@Smeet-Shah
Copy link
Contributor

@Smeet-Shah Smeet-Shah commented Oct 28, 2025

Notion ticket link

Seeding Script

Builds on from #143 and 53391bf.

Implementation description

  • Setup config.js file on the backend for seed scripting
  • Added new script commands
  • Added mock data for users, pets, tasks and task templates (seperate files for cohesivness)
  • Added/created firebase emulator to now be able to properly mock the firebase authentication process and provide consistent UIDs
  • Added emulator via firebase-emulator service on the docker

Steps to test

  1. docker-compose up -d --build
  2. docker-compose exec ts-backend yarn seed:auth
  3. docker-compose exec ts-backend yarn migrate
  4. docker-compose exec ts-backend yarn seed (this will seed)
image image

What should reviewers focus on?

  • Now we're able to test sign in with curl -s -X POST ... and test protected API point withs ID tokens and even refresh tokens

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have run the appropriate linter(s)
  • I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR

"https://securetoken.googleapis.com/v1/token";
const FIREBASE_OAUTH_SIGN_IN_URL =
"https://identitytoolkit.googleapis.com/v1/accounts:signInWithIdp";
const IDENTITYTOOLKIT_PASSWORD_PATH =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have not tested yet, but concerned about this change. Please explain your thought process (next time include this in PR description)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was strictly a matter of making things more readable, it's not a change that is necessary but I added for sake of usability in the future

@sthuray
Copy link
Collaborator

sthuray commented Oct 29, 2025

Also,

  1. please complete PR checklist
  2. please include screenshots of expected testing results

Copy link
Collaborator

@sthuray sthuray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't taken a closer look at code yet--would like to see clear documentation and refactoring before that.

Left some notes on what can be documented/refactored, please use your best judgement

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document code blocks for clarity


const auth = admin.auth();

const USERS = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Place mock data elsewhere and then import for easy editing of mock data

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do and will do!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document purpose of file somewhere
Idea: in seeders, create a mock data folder that holds .json files. Then add a documentation file in the folder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one isn't necessarily needed as it will generate when testing, I can include this in the .gitignore

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document file + rename functions for clarity

const EMULATOR_HOST = process.env.FIREBASE_AUTH_EMULATOR_HOST; // e.g. "host.docker.internal:9099"
const USING_EMULATOR = Boolean(EMULATOR_HOST);
const API_KEY = USING_EMULATOR
? process.env.FIREBASE_WEB_API_KEY || "fake-api-key"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is "fake-api-key" still suppposed to be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, left it as a place-holder for now, was planning to remove after testing went well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document purpose of each emulator

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document purpose of firebase-emulator service

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! I have documentation for this already on the notion ticket itself, but I can make it more thorough if need be.

@sthuray sthuray requested review from Artyom-G and rajshah6 October 30, 2025 23:28
@sthuray sthuray marked this pull request as draft November 3, 2025 18:03
@sthuray sthuray marked this pull request as ready for review November 7, 2025 01:10
sthuray
sthuray previously requested changes Nov 7, 2025
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.gitignore

@zyrephus
Copy link
Contributor

zyrephus commented Feb 1, 2026

lgtm

Changed pets seeder to delete all pets instead of filtering by hardcoded names from fixtures. This prevents accidental deletion of real pets that share names with seed data.
@zyrephus zyrephus dismissed sthuray’s stale review February 3, 2026 21:49

Addressed changes

@zyrephus zyrephus self-requested a review February 3, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants