First attempt to use TDD (Test Driven Development) in Node.js.
Hoaxify is a backend application built with Node.js and Express, demonstrating the implementation of TDD principles. It uses SQLite for the database and Sequelize as the ORM.
- Node.js: Runtime environment.
- Express: Web framework for Node.js.
- Sequelize: Promise-based Node.js ORM.
- SQLite: Self-contained, serverless, zero-configuration, transactional SQL database engine.
- Jest: JavaScript Testing Framework.
- Bcrypt: Library to help hash passwords.
- Node.js installed on your machine.
- Clone the repository:
git clone <repository_url>
- Navigate to the project directory:
cd hoaxify - Install dependencies:
npm install
To start the server in development mode with nodemon:
npm startThe server runs on http://localhost:3000 (or the configured port).
This project uses Jest for testing. To run the tests:
npm testThis runs jest in watch mode.
Files: src/user/UserRouter.js, src/user/UserService.js
- URL:
/api/v1/users - Method:
POST - Description: Registers a new user.
- Request Body:
{ "username": "user1", "email": "user1@mail.com", "password": "Password1" } - Success Response:
- Code: 200 OK
- Content:
{ "message": "User created" }
hoaxify/
├── src/
│ ├── config/ # Database configuration
│ ├── user/ # User module (Model, Router, Service)
│ └── app.js # Express app setup
├── _test_/ # Tests directory
├── index.js # Entry point
├── package.json # Dependencies and scripts
└── readMe.md # Project documentation