Diary is a web application where you can let your emotions fly, by writing them in your personal and private diary. After that, just download it. You can even print it then.
- Login/Register
- Write/edit diary
- See profile info
- Edit profile info
- Download diary in pdf
- All diary content is encrypted
- Automatic formating of content is pages on diary save
- Responsive design
- Server side rendering
- Change password
- Forgot password
- Delete account
- Customize your diary design
- Google, Facebook auth
- More testing
- Rich text editor (maybe)
- Recaptcha
- Analytics
- Next
- Node
- Express
- Redux Toolkit
- Styled Components
- Typescript
- Json web token based auth with refresh tokens
- Postgresql
- Sequelize
- Jest, Mocha
- Docker
You can interact with the project here.
Requires Node.js v14+ to run ,typescript and mongodb. This only runs the frontend. To run the frontend please visit this
Before any of that you will need to create a .env file in the root directory with the following variables:
SECRET= jwt secret
REFRESH_SECRET=jwt refresh token secret
DB_HOST= host of db
DB_USERNAME= username of db
DB_PASSWORD= password of db
DATABASE_NAME= name of db
DIARY_SECRET= secret for encrypting diary content
EMAIL_ADRESS= gmail email adress
REFRESH_TOKEN_EMAIL= refresh token linked to gmail account
CLIENT_ID_EMAIL= client id for gmail account
DELETE_TOKEN= jwt secret for delete account
RESET_TOKEN= jwt secret for reset password
npm i
npm run start
Or by using docker. THE DB IS NOT PART OF DOCKER. YOU WILL NEED TO HAVE ONE INSTALLED ON YOUR MACHINE
docker build -t backend-diary .
docker run --user=node --volume=YOUR ABSOLUTE PATH TO THE FOLDER WHERE IMAGES WILL BE STORED:/usr/src/app/dist/static/uploads/images:rw --network=host --privileged --restart=unless-stopped --detach=true --name=backend-diary backend-diary
You can create an account
Required:
- fullName - user's full name
- username: the username of the user
- password: the password of the user
- email: the email of the user
It could be a json with the following syntax, or with no response at all:
{
message ?: string,
}
The response headers will have 2 more proprieties if everything is succesfull: x-token
and x-refresh-token
.
You login
Required:
- username: the username of the user
- password: the password of the user
It will be a json with the following syntax:
{
message: string,
id?: number,
fullName?: string,
email?: string;
imageURL?: string;
}
The response headers will have 2 more proprieties if everything is succesfull: x-token
and x-refresh-token
.
You get the user info based on token
Required:
- headers:
- x-token: the token auth
Optional:
- headers:
- x-refresh-token: if the token is expired use this to generate a new one
It will be a json with the following syntax:
{
message: string,
id?: number,
fullName?: string,
email?: string;
imageURL?: string;
}
The response headers will have 2 more proprieties if everything is succesfull: x-token
and x-refresh-token
.
Update the user info
Required:
- At least one of the optional parameteres
Optional:
- username
- fullName
- imageName - if you want to change the image, you first need to call another endpoint to upload the image
It could be a json with the following syntax, or with no response at all:
{
message?: string,
}
Sends an email with a delete account link to the email linked with the account
Required:
- password - the password of the account
It will be a json with the following syntax:
{
message: string,
}
Sends an email with a reset password link to the email linked with the account
none
It will be a json with the following syntax:
{
message: string,
}
After recevieng an email with a link that calls this endpoint, you can reset your password.
Required:
- newPassword - your new password
- repeatedNewPassword - the same new password
- token - the token from the url received on email
It will be a json with the following syntax:
{
message: string,
}
After recevieng an email with a link that calls this endpoint, you can delete your account.
Required:
- token - the token from the url received on email
It will be a json with the following syntax:
{
message: string,
}
Send me an email
Required:
- email: The user's email;
- fullName: The user's fullName;
- subject: The user's subject;
- message: The user's message;
It will be a json with the following syntax:
{
message: string,
}
Get the diary of an user
none
It will be a json array with the following syntax:
[
{
id: string,
updatedAt: Date,
createdAt: Date,
userId: string,
content: string,
},
];
Update the diary.
Required:
Representing an array of diaryEntries that you wish to change
[{
- data: Date;
- id: number;
- content: string;
- date: Date;
- isNewEntry: boolean,
}]
It will be a json with the following syntax:
{
message: string,
}
Download your diary in pdf
none
It will be a pdf.
Upload a photo for the profile picture.
It's a form-data request
Required:
file: the actual file in png, jpg or webp
A string with the photo name.
- MIT License
- Copyright 2022 © Chirilov Narcis