A boilerplate project for building a backend server with TypeScript and Express, integrated with MongoDB and Redis. Includes middleware for JWT-based authentication and is fully Docker-compatible.
- ⚙️ TypeScript & Express setup
- 🛡 JWT authentication middleware
- 🗃 MongoDB integration
- 🚀 Redis caching
- 🐳 Docker support
- 📁 Environment-based configuration
Ensure the following are installed on your machine:
# 1. Clone the repository
git clone https://github.com/your-username/starter-typescript-server.git
# 2. Navigate to the project folder
cd starter-typescript-server
# 3. Install dependencies
npm install
# 4. Start the development server
npm run dev
Set up your .env file in the root directory with the following structure:
# Server
PORT=3000
# MongoDB
MONGO_URI=mongodb://localhost:27017
MONGO_DB_NAME=your_database_name
# Redis
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=
# JWT
JWT_SECRET=your_secret_key
docker build --no-cache -t starter-typescript-server:staging .
Ensure you have an .env.staging file in your project root:
# Server
PORT=3000
# MongoDB
MONGO_URI=mongodb://host.docker.internal:27017
MONGO_DB_NAME=staging
# Redis
REDIS_HOST=host.docker.internal
REDIS_PORT=6379
REDIS_PASSWORD=
# JWT
JWT_SECRET=your_secret_key
Then run:
docker run --env-file .env.staging -p 3000:3000 starter-typescript-server:staging
-
npm run dev
– Start server in development mode -
npm run build
– Compile TypeScript to JavaScript -
npm start
– Run compiled app