This application is smart. Daily exercises, encouragement, psychology facts, and more. Sent straight to your email when you least expect it. This isn't a counseling session. This isn't a therapy system. It's the best first step towards a healthier brain. When a user registers with his credentials (email and password inclusive) the application sends a periodic email to the user with mental health support in mind.
- A user can register to the service
- A user receives random mental health tips
- No email message is repeated
- When the number of messages in the database is exhausted, the email stops
- A user can pause/restart the email message
- A user can recover forgotten passport
- A user can change his email for the message at any time
- A user can login and be authenticated and authorized for some capabilities
- There are two categories of users: admin and user. They have different authorizations
- A user can delete his account
- A user can change his name provided he is logged in
- A user can re-subscribe to the email messaging service when current subscription exhausts
- Very secure
- NodeJS
- Express
- MongoD
- Google APIs
- Node Mailer
- Mocha
- Chai
Run git clone https://github.com/HENRYKC24/Email-Schedule-App.git
in your terminal
Run cd Email-Schedule-App
to navigate to the project folder
Run npm install
from the command line to install all dependencies
You need to set up the below environment variable: See this
For MongoDB Config See this
- MONGODB_REMOTE_SERVER
- MONGODB_PASSWORD
- PORT
- COOKIE_EXPIRES_IN
For Google Mail API See this
- CLIENT_SECRET
- CLIENT_ID
- REFRESH_TOKEN
For JSON Web Token (JWT) See this
- JWT_SECRET
- JWT_EXPIRES_IN
When all these are set,
Run npm run start:dev
to start the local server in development environment
OR:
Run npm run start:prod
to start the local server in production environment
Run npm test
from the terminal
All responses come in standard JSON.
Note: The token is intentionally added to some responses to ease testing purposes with Postman API Tool. PLEASE, TEST THE ENDPOINTS WITH POSTMAN APPLICATION
http code 500
{
"status": "fail",
"message": "Internal server error"
}
http code 200
{
"status": "success",
"dataCount": 2,
"data": {}
}
https://henrykc-mail-scheduler.herokuapp.com/
Response:
{
"status": "success",
"message": "Welcome to Cope Notes Mental Health Support API service!",
}
https://henrykc-mail-scheduler.herokuapp.com/api/v1/users/signup
- Place this code in the
Tests
tabpm.environment.set("jwt", pm.response.json().token);
{
"name": "John Doe",
"email": "example1@gmail.com",
"password": "password12345",
"passwordConfirm": "password12345"
}
The above endpoint with the payload returns the user as a response
Response:
{
"status": "success",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"data": {
"user": {
"role": "user",
"active": true,
"messagePaused": true,
"messagesLeft": -1,
"sentMessageIds": [],
"_id": "62f62257d2296048c1fa7ef8",
"name": "John Doe",
"email": "example1@gmail.com",
"__v": 0
}
}
}
https://henrykc-mail-scheduler.herokuapp.com/api/v1/users/login
- Place this code in the
Tests
tabpm.environment.set("jwt", pm.response.json().token);
{
"email": "example1@gmail.com",
"password": "password12345"
}
The above endpoint with the payload returns the user as a response
Response:
{
"status": "success",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"data": {
"user": {
"role": "user",
"messagePaused": false,
"messagesLeft": -1,
"sentMessageIds": [],
"_id": "62f5fb3e72e354f248aa17eb",
"name": "John Doe",
"email": "example1@gmail.com",
"__v": 0
}
}
}
https://henrykc-mail-scheduler.herokuapp.com/api/v1/users/forgot-password
Hint: No authentication required.
{
"email": "example1@gmail.com"
}
The above endpoint sends an email with a link to recover/change the password to the provided email in the payload.
https://henrykc-mail-scheduler.herokuapp.com/api/v1/users/reset-password/:token
- Place this code in the
Tests
tabpm.environment.set("jwt", pm.response.json().token);
Hint: The above endpoint will be automatically generated from the email send during forgot password process. It is a post request that require a payload. Copy the link from your email and paste it in Postman
{
"password": "password12",
"passwordConfirm": "password12"
}
Response:
{
"status": "success",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"data": {
"user": {
"role": "user",
"messagePaused": false,
"messagesLeft": -1,
"sentMessageIds": [],
"_id": "62f5fb3e72e354f248aa17eb",
"name": "John Doe",
"email": "example1@gmail.com",
"__v": 0
}
}
}
https://henrykc-mail-scheduler.herokuapp.com/api/v1/users
- In the
Authorization
tab, selectBearer Token
in theType
field; - Place this code in the
Tests
tabpm.environment.set("jwt", pm.response.json().token);
Hint: You must be logged in before you can access this route. No payload is required.
Response:
{
"status": "success",
"message": "You successfully logged out",
"token": "eyJhbGciOiJIUzI1NiIsInR..."
}
https://henrykc-mail-scheduler.herokuapp.com/api/v1/users
- In the
Authorization
tab, selectBearer Token
in theType
field;
Hint: You must be logged in and also an admin before you can access this route. No payload is required.
The above endpoint returns all registered users as a response
Response:
{
"status": "success",
"dataCount": 3,
"data": {
"users": [
{
"role": "admin",
"messagePaused": false,
"messagesLeft": 0,
"sentMessageIds": [],
"_id": "62f5fb3e72e354f248aa17eb",
"name": "Changed Name",
"email": "example1@gmail.com",
"__v": 0
},
{
"role": "admin",
"messagePaused": false,
"messagesLeft": 0,
"sentMessageIds": [],
"_id": "62f6207791323129f0d65448",
"name": "John Doe",
"email": "example2@gmail.com",
"__v": 0
},
{
"role": "user",
"messagePaused": true,
"messagesLeft": -1,
"sentMessageIds": [],
"_id": "62f62257d2296048c1fa7ef8",
"name": "John Doe",
"email": "example3@gmail.com",
"__v": 0
}
]
}
}
https://henrykc-mail-scheduler.herokuapp.com/api/v1/users/:id
- In the
Authorization
tab, selectBearer Token
in theType
field;
Hint: You must be logged in and also an admin before you can access this route. No payload is required.
The above endpoint returns a user as a response
Response:
{
"status": "success",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"data": {
"user": {
"role": "user",
"messagePaused": false,
"messagesLeft": -1,
"sentMessageIds": [],
"_id": "62f5fb3e72e354f248aa17eb",
"name": "John Doe",
"email": "example1@gmail.com",
"__v": 0
}
}
}
https://henrykc-mail-scheduler.herokuapp.com/api/v1/users/update-password
- In the
Authorization
tab, selectBearer Token
in theType
field; - Place this code in the
Tests
tabpm.environment.set("jwt", pm.response.json().token);
Hint: You must be logged in before you can change your password.
{
"passwordCurrent": "password12345",
"password": "password12345change",
"passwordConfirm": "password12345change"
}
The above endpoint returns a user as a response
Response:
{
"status": "success",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYyZjVmYjNlNzJlMzU0ZjI0OGFhMTdlYiIsImlhdCI6MTY2MDMxNTgxMywiZXhwIjoxNjY4MDkxODEzfQ.-oRibPCC-LC-gjFUzfh0x8_nroQDrdblVRdqKjtIFKI",
"data": {
"user": {
"role": "admin",
"messagePaused": false,
"messagesLeft": 0,
"sentMessageIds": [],
"_id": "62f5fb3e72e354f248aa17eb",
"name": "Changed Name",
"email": "henrykc24@yahoo.com",
"__v": 0,
"passwordResetExpires": "2022-08-12T07:40:15.286Z",
"passwordResetToken": "0cd23722d7d38c79205c...",
"passwordChangedAt": "2022-08-12T14:50:11.844Z"
}
}
}
https://henrykc-mail-scheduler.herokuapp.com/api/v1/users/update-user
- In the
Authorization
tab, selectBearer Token
in theType
field;
Hint: You must be logged in before you can change your name or email.
{
"email": "henrykc25@yahoo.com"
}
The above endpoint returns a user as a response
Response:
{
"status": "success",
"data": {
"user": {
"role": "admin",
"messagePaused": false,
"messagesLeft": 0,
"sentMessageIds": [],
"_id": "62f5fb3e72e354f248aa17eb",
"name": "Changed Name",
"email": "henrykc25@yahoo.com",
"__v": 0,
"passwordResetExpires": "2022-08-12T07:40:15.286Z",
"passwordResetToken": "0cd23722d7d38c79...",
"passwordChangedAt": "2022-08-12T14:50:11.844Z"
}
}
}
https://henrykc-mail-scheduler.herokuapp.com/api/v1/users/pause-message
- In the
Authorization
tab, selectBearer Token
in theType
field;
Hint: You must be logged in before you can pause receiving email for mental health tips. No payload is required
The above endpoint returns a message that your message service has been paused.
Response:
{
"status": "success",
"message": "Email messages paused successfully."
}
https://henrykc-mail-scheduler.herokuapp.com/api/v1/users/continue-message
- In the
Authorization
tab, selectBearer Token
in theType
field;
Hint: You must be logged in before you can continue a paused email for mental health tips. No payload is required
The above endpoint returns a message that your paused service has been resumed.
Response:
{
"status": "success",
"message": "Email messages has successfully continued."
}
https://henrykc-mail-scheduler.herokuapp.com/api/v1/users/re-subscribe
- In the
Authorization
tab, selectBearer Token
in theType
field;
Hint: You must be logged in before you can re-subscribe email for mental health tips. No payload is required
The above endpoint returns a success or failure message.
Response: - Success
{
"status": "success",
"message": "You have successfully re-subscribed!"
}
Response: - Failure
{
"status": "fail",
"message": "You already have an active subscription. Please, check if message service is paused!"
}
π€ Henry Kc
- GitHub: @githubhandle
- Twitter: @twitterhandle
- LinkedIn: LinkedIn
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
Give a βοΈ if you like this project!
- I remain indebted to all software engineers across the world for helping me in one way or the other in the project and in my career.
This project is MIT licensed.