Here you will find the simple frontend application: https://github.com/said7388/next-blog-app
You will find the Postman API's documentation in the following link: https://documenter.getpostman.com/view/19954195/2sA2rAyhgB.
In this documentation, you will see the API's payload and response examples.
You will find the database diagram design in the following link: https://dbdiagram.io/d/Blog-App-65d3128aac844320ae73c436
First, Create an .env
file from .env.example
and update the environment variables. After successfully creating an account or login update the JWT_TOKEN
variable for the testing.
JWT_SECRTE =
DB_PORT =
DB_HOST =
DB_NAME =
DB_USER =
DB_PASS =
PORT =
BACKEND_HOST =
JWT_TOKEN =
To create all tables in the database run the following command in project root directory.
node migration/db.ts
Install the application dependencies using npm
or yarn
:
npm install
# or
yarn install
Then, run the development server:
npm run server
# or
yarn server
After successfully creating an account or login update the JWT_TOKEN
variable for the testing. Before running the tests you should create data for post, comment, and reaction. Create some data with another user account and use it to run the tests for unauthorised access errors.
Please update variables values in post.test.ts
, comment.test.ts
and reaction.test.ts
file.
const validPostId = 1; // an existing post
const invalidPostId = 2; // a not existing post
const otherUserPostId = 4; // a post created by another user
const validCommentId = 3; // an existing comment
const invalidCommentId = 5; // a not existing comment
const otherUserCommentId = 4; // a comment created by another user
Then, run the following command to test the application:
npm test
# or
yarn test