This service main functionality is to send email asynchronously using worker. The detail information about this service is listed below:
- Language:
PHP8.3
- Dependency Management:
composer
- Database:
PostgreSQL
- Protocol:
HTTP
- Queue:
Redis
- Oauth2 Provider:
Okta
https://www.okta.com/
Run .sql
script manually one by one with ordering by prefix e.g 000001_, 000001_, etc
or
- Installation source
- WINDOWS:
scoop install migrate
- MAC:
brew install golang-migrate
- LINUX:
$ curl -L https://packagecloud.io/golang-migrate/migrate/gpgkey| apt-key add - $ echo "deb https://packagecloud.io/golang-migrate/migrate/ubuntu/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/migrate.list $ apt-get update $ apt-get install -y migrate
- WINDOWS:
- Add database config into
.env
file. Ensure following variables exist and don't forget to fill the value:DB_HOST= DB_PORT= DB_DATABASE= DB_USERNAME= DB_PASSWORD=
- Execute Migration
- Up:
make migrate-up
- Down:
make migrate-down
- Up:
POST /register
Parameter | Type | Description |
---|---|---|
email |
string |
Required. user email |
password |
string |
Required. user password |
POST /login
Parameter | Type | Description |
---|---|---|
email |
string |
Required. user email |
password |
string |
Required. user password |
GET /client
GET /client-okta
POST /email
header Authorization: Bearer {{access_token}}
Parameter | Type | Description |
---|---|---|
is_html |
boolean |
Optional. default value false |
email_to |
string |
Required. Target email to whom the email will be sent |
subject |
string |
Required. Email subject |
body |
string |
Required. Email body that can be in HTML format by setting is_html to true |
example
{
"is_html": "true",
"email_to": "[email protected]",
"subject": "testing subject",
"body": "<br>Hello World<br>"
}
- Install
docker
alongsidecompose
plugin https://docs.docker.com/compose/install/
- Create
.env
and fill it with correct value. Refer to.env.example
- Build image
php:base-image
docker build -t php:base-image .
- Run docker compose
docker-compose up -d
- Execute database migration here
- Open client page in your browser to get bearer token 5.1 Visit http://localhost:8080/client for testing client, or 5.2 Visit http://localhost:8080/client-okta if using okta user
- Copy bearer token
Bearer {{ token }}
- Execute this example curl in your Postman or terminal. Don't forget to change the token value with the one from step 6
curl -L 'http://localhost:8080/email' \ -H 'Authorization: Bearer {{ token }}' \ -H 'Content-Type: application/json' \ --data-raw '{ "is_html": "true", "email_to": "[email protected]", "subject": "testing subject final", "body": "<br>Hello World! Nice to meet you<br>" }'