Conversation
Secret/prod
Secret/prod
Secret/prod
Secret/prod
removed server.js bug
verify if server user preferences are passed down successfully
Secret/prod
# Conflicts: # server/controllers/recipesController.js
Secret/prod
Secret/prod
updated firestoredata.js to remove config json files
removed debug
Secret/netlify func
|
Can you please create a design document (eg. In a docs folder) that also describes how this change fits in the big picture? Cursor AI or Copilot is great for this |
Update/netlify functions
removed unused functions
nicmart-dev
left a comment
There was a problem hiding this comment.
Thanks for the improvements! I spotted a few blockers, using Cursor Agents:
1. server/controllers/databaseController.js: keep the Firebase service account out of git
const feedmenowAccount = (() => {
const raw = process.env.FEEDMENOW_RECIPES_SERVICE_ACCOUNT;
if (!raw) {
throw new Error('FEEDMENOW_RECIPES_SERVICE_ACCOUNT env var is required');
}
const parsed = JSON.parse(raw);
parsed.private_key = parsed.private_key?.replace(/\\n/g, '\n');
return parsed;
})();
2. server/controllers/databaseController.js: avoid double-initializing Firebase apps
feedmenowAccount.private_key_id = process.env.FEEDMENOW_RECIPES_KEY_ID;
feedmenowAccount.private_key = process.env.FEEDMENOW_RECIPES_KEY?.replace(/\\n/g, '\n');
const feedmenowRecipesApp =
admin.apps.find((app) => app.name === 'FeedMeNowRecipes') ??
admin.initializeApp({ credential: cert(feedmenowAccount) }, 'FeedMeNowRecipes');
3. server/controllers/recipesController.js: guard when Airtable returns no records so polling clients don’t crash
const record = responseAirtable.data.records?.[0];
if (!record) {
return res.status(404).json({ error: 'Recipe request not found.' });
}
if(record.fields.status == "Success") {
const firestoreID = record.fields.firestoreID.slice(0, -1);
4. client/src/pages/Home/Home.jsx: default the cached recipes to an empty array
const existingRecipes = JSON.parse(localStorage.getItem('recipes') ?? '[]');
existingRecipes.unshift({prompt: responseReady.data.prompt, dishes: responseReady.data.dishes});
5. client/src/pages/RecipeSuggestions.jsx: register the document click handler inside useEffect with cleanup
const mouseClickFunction = (promptitem) => {
if(document.querySelector(`#nav-${promptitem}`)) {
document.querySelector(`#nav-${promptitem}`).classList.add("hidden");
}
setShowPromptMenu(-1);
};
useEffect(() => {
const handleDocumentClick = () => mouseClickFunction(showPromptMenu);
document.addEventListener("click", handleDocumentClick);
return () => document.removeEventListener("click", handleDocumentClick);
}, [showPromptMenu]);
Addressing these keeps secrets out of git, prevents Firebase init errors, and makes the polling flow resilient.
added new route for server that would check airtable database for status of the promptID generated data.
the client now asks the server for several intervals for the data of generated recipes until the time runs out or it gets an answer.
server will ask for firestore json if airtable item will tell it that the n8n workflow has generated the recipe.
Server is set to work with n8n workflow 2.0
This update is for ability of the server api to be able to run on short lived serverless functions, like netlify functions.