Forum API is a RESTful API built using Javascript and Node.js, leveraging the Hapi framework. It provides features for creating user accounts, managing threads, adding comments, liking comments, and replying to comments. The project utilizes PostgreSQL as a relational database, JWT for authentication, and follows the principles of clean architecture.
- JavaScript : The primary programming language
- Node.js : The runtime environment for executing JavaScript code.
- Hapi Framework : A powerful and flexible framework for building web applications.
- PostgreSQL (Relational Database) : A relational database management system for data storage.
- JWT (JSON Web Tokens) for User Authentication
-
User Accounts:
- Create user accounts with secure authentication using JWT.
-
Threads:
- Create and manage discussion threads.
-
Comments:
- Add comments to threads.
- Like comments.
- Reply to comments.
-
Clone the repository:
git clone https://github.com/muhariananda/forum-api.git cd forum-api
-
Install dependencies
npm install
-
Database setup
- Create a PostgreSQL databases for application and test, then update the configuration in
config/database.js
.
- Create a PostgreSQL databases for application and test, then update the configuration in
-
Environment variables
- Create a
.env
file based on the.env.example
file and configure the required variables.
- Create a
-
Run Migration
npm run migrate up
-
Run the application
npm run start
-
Authentication
- Obtain a JWT token by authenticating with your user credentials.
-
API Endpoint
- Refer to the API documentation for detailed information on available endpoints and their usage.
The project includes both unit tests and integration tests, following Test-driven Development (TDD) practices.
-
Run migration for database test
npm run migrate:test up
-
Run test
npm run test
-
Run test coverage and watch
npm run test:watch
Happy coding! ❤️ 🖥️