This project is a video storage Service with REST APIs, which has CRUD implementation as described in the Open API definition. The endpoints of the server are exposed to the host machine. There three main components in this project:
- Server - The server is implemented using Node.js and Express.js. The server is responsible for handling the requests and responses from the client. The server is also responsible for handling the database connection and operations.
- Database - The database is implemented using PostgreSQL. The database is responsible for storing the video files and their metadata.
- Redis - Redis is used as a cache for the database. The cache is used to store the video files and their metadata. The cache is used to reduce the number of database queries.
The project is structured as follows:
.
βββ README.md
βββ docker-compose.yml
βββ docker-compose.ci.yml
βββ Dockerfile
βββ package.json
βββ yarn.lock
βββ tsconfig.json
βββ scripts
β βββ init_db.sh # Initialize the database with the schema and roles for the application
β βββ start.sh # Start the application and run the migrations if needed
βββ src # Core source code of the application (TypeScript)
β βββ configs # Configuration files for the application and database connection
β β βββ CrudInterface.ts # Interface for CRUD operations
β β βββ RouteConfig.tsn # Route configuration
β β βββ ServerConfig.ts # Server configuration
β β βββ db # Database configuration files (TypeORM)
β β βββ migrations # Database migrations
β β β βββ 1645134357970-init.ts # Initial migration to create tables
β β βββ sql
β β β βββ init_video_storage.sql # SQL script to create tables
β β βββ VideoStorageDataSource.ts # Database connection
β βββ controllers # Controllers for the API endpoints (TypeScript)
β β βββ v1 # Controllers for the v1 API version (TypeScript)
β β βββ VideoController.ts # Controller for video file operations (CRUD)
β βββ daos # Data access objects for database operations (CRUD)
β β βββ v1 # Data access objects for the v1 API version (TypeScript)
β β βββ VideoFileDao.ts # Data access object for video file operations (CRUD) (TypeScript)
β βββ dtos # Data transfer objects for the API endpoints (TypeScript)
β β βββ v1 # Data transfer objects for the v1 API version (TypeScript)
β β βββ VideoFileDto.ts # Data transfer object for video file operations (CRUD) (TypeScript)
β βββ entities # Database entities (TypeScript)
β β βββ v1 # Database entities for the v1 API version (TypeScript)
β β βββ VideoFile.ts # Database entity for video file operations (CRUD) (TypeScript)
β βββ middlewares # Middlewares for the API endpoints (TypeScript)
β β βββ v1 # Middlewares for the v1 API version (TypeScript)
β β β βββ VideoFileMiddleware.ts # Middleware for video file operations (CRUD) (TypeScript)
β β βββ CLSMiddleware.ts # Middleware for CLS-hooked and bind the request ID to the logger (TypeScript)
β β βββ LoggerMiddleware.ts # Middleware for logging the API endpoints (TypeScript)
β βββ routes # Routes for the API endpoints (TypeScript)
β β βββ v1 # Routes for the v1 API version (TypeScript)
β β βββ VideoFileRoute.ts # Routes for video file operations (CRUD) (TypeScript)
β βββ services # Services for the API endpoints (TypeScript)
β β βββ v1 # Services for the v1 API version (TypeScript)
β β βββ VideoFileService.ts # Service for video file operations (CRUD) (TypeScript)
β βββ swagger # OpenAPI specification for the API endpoints (TypeScript)
β β βββ v1 # OpenAPI specification for the v1 API version (TypeScript)
β β βββ api.yaml # OpenAPI specification for the API endpoints (TypeScript)
β βββ utils # Utility functions (TypeScript)
β β βββ Constants.ts # Constants for the application (TypeScript)
β β βββ CustomResponse.ts # Custom response for the application (TypeScript)
β β βββ HelperFunctions.ts # Helper functions for the application (TypeScript)
β β βββ Logger.ts # Logger for the application (TypeScript)
β β βββ Redisclient.ts # Redis client for the application (TypeScript)
β β βββ VideoFileHandler.ts # Handler for video file operations such as upload, download, delete (TypeScript)
βββ test # Test files for the application (TypeScript)
β βββ tester.json # Postman collection for testing the API endpoints
βββ .dockerignore # Docker ignore file for the application
βββ .gitignore # Git ignore file for the application
βββ .yarnclean # Yarn clean file for the application
βββ docker-compose.yml # Docker compose file for the application
βββ Dockerfile # Docker file for the application
βββ package.json # Package file for the application
βββ tsconfig.json # TypeScript configuration file for the application
βββ yarn.lock # Yarn lock file for the application
βββ .env # Environment variables for the application
- Node.js
- TypeScript
- Express
- PostgreSQL
- TypeORM
- Redis
- Docker
- OpenAPI
- Swagger UI
- Multer
- Morgan
- Winston
- CLS-hooked
To start the project with Docker Compose, run:
docker-compose up --buildTo view the Swagger UI:
- Run the project with Docker Compose
- Go to http://localhost:8080
Marius Ngaboyamahina, Senior Software Engineer LinkedIn: Marius Ngaboyamahina