This repository contains a web server written in TypeScript using Node.js, Nest.js, MongoDB, Typesense, and containerized with Docker.
- NodeJS - JavaScript runtime environment.
- NestJS - Web framework for NodeJS.
- Typescript - Strongly typed programming language.
- MongoDB - Document-oriented database.
- Typesense - Open source search engine
- Docker - Open source containerization platform.
- Nginx - Open-source web server, used in this project as API Gateway
Before running the server, you need to set some environment variables in the .env
file at the root of the cloned repository.
- MONGODB_URI - MongoDB connection string
- MONGODB_DB - Name of the database
- TYPESENSE_URI - Typesense connection string
- TYPESENSE_API_KEY - Typesense API key (defined in docker-compose)
- Clone or copy the repository.
- Navigate to the repository.
- Run the Docker container.
docker compose up
The server should now be running on the 80 port.
This server provides the following endpoints:
POST /api/user
: Add a new user.GET /api/user/:id
: Get user by idGET /api/user
: Get all usersDELETE /api/user
: Delete userPOST /api/article
: Add a new article.GET /api/article/:id
: Get article by idGET /api/article
: Get all articleDELETE /api/article
: Delete articlePOST /api/comment
: Add a new comment.GET /api/comment/:id
: Get comment by idGET /api/comment
: Get all commentsDELETE /api/comment
: Delete commentGET api/article/search?text=
: Search all articles for provided text
Additional endpoints:
POST /api/content/restore
: Drop all data and load content from a filePOST /api/content/load
: Load content from a file to expand the current values
To use the server, you can send HTTP requests to these endpoints. The repository includes an IntelliJ IDEA REST configuration file with sample requests that you can use as a reference.
Drop database and clear Typesense index
npm run execute drop-db
Load all database records and save stringified
npm run execute save-db
This project is licensed under the MIT License.