Frequently Asked Questions
dbAuth provides a built-in authentication system integrated with a database. It simplifies user signup, login, logout, and session management within your RedwoodJS application.
Use RedwoodJS's GraphQL API to create reminders with a scheduled time, which are then processed by a background job using node-cron or an external scheduler in production. The job queries for due reminders and sends them via the Plivo SMS API.
Plivo is a communications platform that handles sending the actual SMS messages. The RedwoodJS app interacts with Plivo's API to dispatch scheduled reminders as SMS.
The scheduler uses UTC to accurately compare the scheduledAt timestamp (stored in UTC in the database) with the server's current time, ensuring reminders are sent at the correct moment regardless of server location.
An external scheduler (like Vercel Cron Jobs or AWS EventBridge Scheduler) is strongly recommended for production serverless deployments because node-cron isn't suitable for ephemeral serverless functions.
Yes, Prisma supports various databases (MySQL, SQLite, etc.). Ensure the DATABASE_URL in your .env file is correctly configured for the chosen database.
Create a RedwoodJS app, set up a PostgreSQL database (e.g., using Docker), install necessary libraries (node-cron, plivo), configure environment variables (database, Plivo), and implement the reminder model and services.
Prisma is an ORM that simplifies database interactions. It's used to model the reminder data, manage database migrations, and provide type-safe access to the database within the RedwoodJS services.
Use the createReminder GraphQL mutation, providing the message, recipient phone number, and scheduled time in UTC. The app will handle storing and processing the reminder.
Reminders have three statuses: PENDING (waiting to be sent), SENT (successfully delivered), and FAILED (an error occurred during sending).
node-cron depends on a continuously running process, which doesn't align with the ephemeral nature of serverless functions. Serverless environments require an external scheduler to trigger the reminder processing logic.
Use Redwood's requireAuth function and filter database queries by the current user's ID to ensure users can only access and manage their own reminders.
The @@index attribute creates database indexes to optimize query performance. In the reminder schema, indexes on status and scheduledAt, and userId improve the efficiency of fetching due reminders and reminders by user.
After setting up the project, run yarn rw dev to start the development server. The frontend will be accessible on port 8910, the API on 8911, and the GraphQL Playground on 8911/graphql.