https://github.com/4lessandrodev/cron_job_to_send_emails
Uma pequena brincadeira com cronjobs. Buscar notificações em duas tabelas do banco SQL e enviar os dados por email em um horário programado
https://github.com/4lessandrodev/cron_job_to_send_emails
Last synced: 8 months ago
JSON representation
Uma pequena brincadeira com cronjobs. Buscar notificações em duas tabelas do banco SQL e enviar os dados por email em um horário programado
- Host: GitHub
- URL: https://github.com/4lessandrodev/cron_job_to_send_emails
- Owner: 4lessandrodev
- Created: 2021-07-06T20:57:02.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-09T00:34:18.000Z (almost 5 years ago)
- Last Synced: 2025-10-09T15:48:44.799Z (9 months ago)
- Language: JavaScript
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cron job for send notification
### Get all notification on database
Requirements
- make sure you have a database with the table as in the script example `migration.sql`
- make sure you have entered the credentials in the .env file
- make sure you have nodeJs installed
- make sure you have installed all dependencies `yarn intall`
- make sure your user table on column `notification_mail_preferences` look like the exemple bellow
- make sure you have a valid email user account
```json
{
"late_task_follower": true,
"late_task_responsible": true
}
```
- make sure you have set the default cron
- you can use Cronhub to create your pattern
https://crontab.cronhub.io/
---
## How to run this project?
> ⚠️ **You can jump step one to seven**: If you Import `getData` function from `data.fake.js` instead `data.js` on `index.js`
- Run optionally docker compose `docker-compose up -d` or if you have postgressql installed on you computer just ignore this step
- Connect to your postgres `psql -U postgres -h localhost -p 5432 -d test_cron_db`
- Create your database `CREATE DATABASE test_cron_db;`
- Create valid fake email (you can use https://temp-mail.org/') and update them on migration.sql script line 33
- Create your table: Copy the commands script on migration.sql and paste on your terminal
- Check if tables were created: `\dt`
- Exit your postgres terminal connection: `\q`
- Create your `.env` file with your credentials
- You may use a fake smtp email service like `mailtrap` https://mailtrap.io/fake-smtp-server/
- `$ yarn start`
- Wait until timer match. Default timer is 5 minutes