Skip to content

Intracom will be an open-source internal communication tool designed to be economically accessible and customizable for startups, nonprofits, and small companies.

License

Notifications You must be signed in to change notification settings

project-ascend-io/intracom-be-06-2024

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Express TypeScript Boilerplate 2024

Build Express Application CodeQL Docker Image CI Release

🌟 Introduction

Welcome to the Express TypeScript Boilerplate 2024 – a streamlined, efficient, and scalable foundation for building powerful backend services. This boilerplate merges modern tools and practices in Express.js and TypeScript, enhancing productivity, code quality, and performance.

💡 Motivation and Intentions

Developed to streamline backend development, this boilerplate is your solution for:

  • ✨ Reducing setup time for new projects.
  • 📊 Ensuring code consistency and quality.
  • ⚡ Facilitating rapid development with cutting-edge tools.
  • 🛡️ Encouraging best practices in security, testing, and performance.

🚀 Features

  • 📁 Modular Structure: Organized by feature for easy navigation and scalability.
  • 💨 Faster Execution with tsx: Rapid TypeScript execution with esbuild, complemented by tsc for type checking.
  • 🌐 Stable Node Environment: Latest LTS Node version in .nvmrc.
  • 🔧 Simplified Environment Variables with Envalid: Centralized and easy-to-manage configuration.
  • 🔗 Path Aliases: Cleaner code with shortcut imports.
  • 🔄 Dependabot Integration: Automatic updates for secure and up-to-date dependencies.
  • 🔒 Security: Helmet for HTTP header security and CORS setup.
  • 📊 Logging: Efficient logging with pino-http.
  • 🧪 Comprehensive Testing: Robust setup with Vitest and Supertest.
  • 🔑 Code Quality Assurance: Husky and lint-staged for consistent quality.
  • ✅ Unified Code Style: ESLint and Prettier for a consistent coding standard.
  • 📃 API Response Standardization: ServiceResponse class for consistent API responses.
  • 🐳 Docker Support: Ready for containerization and deployment.
  • 📝 Input Validation with Zod: Strongly typed request validation using Zod.
  • 🧩 API Spec Generation: Automated OpenAPI specification generation from Zod schemas to ensure up-to-date and accurate API documentation.

🛠️ Getting Started

Step 1: 🚀 Initial Setup

  • Clone the repository: git clone https://github.com/edwinhern/express-typescript-2024.git
  • Navigate: cd express-typescript-2024
  • Install dependencies: npm ci

Step 2: ⚙️ Environment Configuration

  • Create .env: Copy .env.template to .env
  • Update .env: Fill in necessary environment variables

Step 3: 🏃‍♂️ Running the Project

  • Development Mode: npm run dev
  • Building: npm run build
  • Production Mode: Set .env to NODE_ENV="production" then npm run build && npm run start

📁 Project Structure

.
├── api
│   ├── healthCheck
│   │   ├── __tests__
│   │   │   └── healthCheckRouter.test.ts
│   │   └── healthCheckRouter.ts
│   └── user
│       ├── __tests__
│       │   ├── userRouter.test.ts
│       │   └── userService.test.ts
│       ├── userModel.ts
│       ├── userRepository.ts
│       ├── userRouter.ts
│       └── userService.ts
├── api-docs
│   ├── __tests__
│   │   └── openAPIRouter.test.ts
│   ├── openAPIDocumentGenerator.ts
│   ├── openAPIResponseBuilders.ts
│   └── openAPIRouter.ts
├── common
│   ├── __tests__
│   │   ├── errorHandler.test.ts
│   │   └── requestLogger.test.ts
│   ├── middleware
│   │   ├── errorHandler.ts
│   │   ├── rateLimiter.ts
│   │   └── requestLogger.ts
│   ├── models
│   │   └── serviceResponse.ts
│   └── utils
│       ├── commonValidation.ts
│       ├── envConfig.ts
│       └── httpHandlers.ts
├── index.ts
└── server.ts

Installing intracom-be-06-2024

Objective: This SOP outlines the steps to install and set up the intracom-be-06-2024 application.


Prerequisites:

  • SSH access
  • Git installed
  • Node.js and npm installed
  • Docker Desktop installed
  • MongoDB community server image available on Docker Hub

Steps:

  1. Setup SSH Key:

    • Generate an SSH key if you don't have one: ssh-keygen -t rsa -b 4096 -C "[email protected]"
    • Add the SSH key to your SSH agent: eval "$(ssh-agent -s)" and ssh-add ~/.ssh/id_rsa
    • Add the SSH key to your GitHub account.
  2. Clone the Repository:

    • Clone the intracom-be-06-2024 repository:
      git clone https://github.com/project-ascend-io/intracom-be-06-2024
      cd intracom-be-06-2024
  3. Install Dependencies:

    • Navigate to the project directory and run:
      npm install
  4. Setup Environment Variables:

    • Create a .env file in the root directory of your project with the following content that matches the .env.template:

      NODE_ENV=development
      PORT=8080
      HOST=localhost
      
      # CORS Settings
      CORS_ORIGIN=http://localhost:*
      
      # Rate Limiting
      COMMON_RATE_LIMIT_WINDOW_MS=1000
      COMMON_RATE_LIMIT_MAX_REQUESTS=20
      
      # MongoDB Settings
      MONGO_INITDB_DATABASE=intracom_database
      MONGO_INITDB_ROOT_USERNAME=root
      MONGO_INITDB_ROOT_PASSWORD=root
      MONGODB_USER=<username>
      MONGODB_PASSWORD=<password>
      MONGODB_CONNECTION_STRING=mongodb://root:root@localhost:27017/
      
  5. Install and Run Docker Desktop:

  6. Run Docker Compose:

    • Change directories to the database directory:

      cd database
    • Run the docker-compose command:

       docker-compose up -d --build
  7. Setup MongoDB Replica Set:

    • Check to make sure your Docker containers are running:
       docker ps
    • Connect to mongo1 container:
      docker exec -it mongo1 mongosh -u root -p root
    • Run replica set initiation command:
      rs.initiate({_id:'rs0',members:[{_id:0,host:'host.docker.internal:27017',priority:1},{_id:1,host:'host.docker.internal:27018',priority:0.5},{_id:2,host:'host.docker.internal:27019',priority:0.5}]})
    • Verify Replica Set Configuration:
      rs.status()
    • You should see an output with information from the initiate command you used to set up the replica set.
  8. Run the Application:

    • Start the application with:
      npm run dev
  9. Access the Application:

    • Open your browser and navigate to http://localhost:8080 to see the running application.

For further details or troubleshooting, please refer to the respective documentation of each tool used.

About

Intracom will be an open-source internal communication tool designed to be economically accessible and customizable for startups, nonprofits, and small companies.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages