Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pedalsup/node-boilerplate-ts

Repository files navigation

Node.js TypeScript Backend Boilerplate

Welcome to our Node.js backend boilerplate project built with TypeScript! This boilerplate provides a solid foundation for creating robust and scalable backend applications using Node.js and TypeScript.

Features

  • Express.js: Utilizes Express.js, a fast, unopinionated, minimalist web framework for Node.js, for handling HTTP requests.
  • TypeScript: Written entirely in TypeScript to provide type safety and enhanced development experience.
  • Routing: Organized routing setup for better code organization and readability.
  • Middleware: Middleware setup for handling common functionalities like error handling, logging, etc.
  • Environment Variables: Uses environment variables for configuration management.
  • Linting: Integrated ESLint for code linting to maintain code quality.

Prerequisites

Before getting started, ensure you have the following installed on your machine:

  • Node.js (v14.x or higher)
  • npm (v6.x or higher) or Yarn (v1.22.x or higher)
  • Docker (optional, for containerization)

Getting Started

  1. Clone the repository:

    git clone https://github.com/your-username/your-project.git
  2. Navigate into the project directory:

    cd your-project
  3. Install dependencies:

    Using npm:

    npm install

    Using Yarn:

    yarn
  4. Set up environment variables:

    • Create a .env file in the root of the project.
    • Define your environment variables in the .env file. You can use .env.example as a reference.
  5. Build the project:

    npm run build

    or

    yarn build
  6. Start the server:

    npm run dev

    or

    yarn dev
  7. Access the API:

    Open your web browser or API testing tool and access http://localhost:3000.

Project Structure

.
├── src/                        # Source files
│   ├── config/                 # Configuration files
│   ├── controllers/            # Request handlers/controllers
│   ├── db/                     # Database related files
│   ├── helper/                 # Helper functions
│   ├── middleware/             # Middleware functions
│   ├── models/                 # MongoDB models
│   ├── routes/                 # Route definitions
│   ├── services/               # Business logic services
│   ├── types/                  # Type definitions
│   ├── utils/                  # Utility functions
│   ├── validations/            # Validator files
│   ├── app.ts                  # Express application setup
├── index.ts                    # Entry point of the application
├── .env.example                # Example environment variables file
├── .eslintignore               # ESLint ignore file
├── .eslintrc.js                # ESLint configuration
├── .gitignore                  # Git ignore file
├── .prettierignore             # Prettier ignore file
├── .prettierrc.json            # Prettier configuration file
├── package.json                # Project dependencies and scripts
├── README.md                   # README file
└── tsconfig.json               # TypeScript configuration

Available Scripts

  • npm start or yarn start: Start the server.
  • npm run dev or yarn dev: Start the server in development mode with hot reloading using nodemon.
  • npm run build or yarn build: Build the TypeScript files into JavaScript.
  • npm run lint or yarn lint: Lint the codebase using ESLint.
  • npm test or yarn test: Run tests using Jest.

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request for any improvements or features you'd like to add.

Feel free to customize this README.md template according to your project's specific needs and features. Happy coding!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published