An open API service indexing awesome lists of open source software.

https://github.com/yjvfat4lxd/express-typegoose-boilerplate

This is a Boilerplate project for using Express with Typescript using Typegoose for ORM for MongoDB connection
https://github.com/yjvfat4lxd/express-typegoose-boilerplate

api-template apollo boilerplate express-ts express-ts-boilerplate graphql nodejs nx ts typegoose typegraphql typescript typescript-boilerplate typescript-node

Last synced: 2 months ago
JSON representation

This is a Boilerplate project for using Express with Typescript using Typegoose for ORM for MongoDB connection

Awesome Lists containing this project

README

        

# 🚀 Express-Typegoose-Boilerplate

![GitHub release](https://img.shields.io/github/release/yJvFaT4LxD/Express-Typegoose-Boilerplate.svg)
![Node.js](https://img.shields.io/badge/node.js-14.x-green.svg)
![TypeScript](https://img.shields.io/badge/typescript-4.x-blue.svg)

Welcome to the **Express-Typegoose-Boilerplate**! This boilerplate project sets you up with a solid foundation for building RESTful APIs using **Express** and **TypeScript**, while leveraging **Typegoose** for MongoDB object-relational mapping (ORM).

## Table of Contents

- [Features](#features)
- [Technologies Used](#technologies-used)
- [Installation](#installation)
- [Usage](#usage)
- [Project Structure](#project-structure)
- [API Endpoints](#api-endpoints)
- [Contributing](#contributing)
- [License](#license)
- [Release Information](#release-information)

## Features

- **TypeScript Support**: Write type-safe code with TypeScript.
- **Express Framework**: Build your server with a minimal and flexible framework.
- **Typegoose Integration**: Simplify your MongoDB interactions using Typegoose.
- **RESTful API Design**: Follow REST principles for API design.
- **Environment Configuration**: Easily manage environment variables.
- **Modular Structure**: Keep your code organized and maintainable.

## Technologies Used

- **Node.js**: JavaScript runtime built on Chrome's V8 engine.
- **Express**: Fast, unopinionated, minimalist web framework for Node.js.
- **TypeScript**: A superset of JavaScript that compiles to clean JavaScript.
- **MongoDB**: NoSQL database for high volume data storage.
- **Mongoose**: ODM (Object Data Modeling) library for MongoDB and Node.js.
- **Typegoose**: A TypeScript wrapper for Mongoose.

## Installation

To get started with the **Express-Typegoose-Boilerplate**, follow these steps:

1. Clone the repository:
```bash
git clone https://github.com/yJvFaT4LxD/Express-Typegoose-Boilerplate.git
```

2. Navigate into the project directory:
```bash
cd Express-Typegoose-Boilerplate
```

3. Install the dependencies:
```bash
npm install
```

4. Set up your environment variables. Create a `.env` file in the root directory and configure your MongoDB connection string:
```env
MONGODB_URI=mongodb://localhost:27017/your_database_name
PORT=3000
```

5. Run the application:
```bash
npm run dev
```

Your server should now be running on `http://localhost:3000`.

## Usage

This boilerplate provides a solid starting point for your Express and TypeScript applications. You can easily extend the functionality by adding new routes, controllers, and services.

### Running Tests

To run tests, you can use the following command:
```bash
npm test
```

## Project Structure

Here is an overview of the project structure:

```
Express-Typegoose-Boilerplate/
├── src/
│ ├── controllers/
│ ├── models/
│ ├── routes/
│ ├── services/
│ ├── config/
│ ├── middlewares/
│ ├── index.ts
├── tests/
├── .env
├── package.json
├── tsconfig.json
└── README.md
```

- **controllers/**: Contains the logic for handling requests and responses.
- **models/**: Defines the data models using Typegoose.
- **routes/**: Defines the API endpoints.
- **services/**: Contains business logic and data manipulation.
- **config/**: Holds configuration files and environment variables.
- **middlewares/**: Contains custom middleware functions.

## API Endpoints

The following endpoints are available in this boilerplate:

### GET /api/items

Fetch all items.

### POST /api/items

Create a new item.

### GET /api/items/:id

Fetch a single item by ID.

### PUT /api/items/:id

Update an item by ID.

### DELETE /api/items/:id

Delete an item by ID.

You can test these endpoints using tools like Postman or Insomnia.

## Contributing

We welcome contributions to improve this boilerplate. If you would like to contribute, please follow these steps:

1. Fork the repository.
2. Create a new branch (`git checkout -b feature/YourFeature`).
3. Make your changes and commit them (`git commit -m 'Add some feature'`).
4. Push to the branch (`git push origin feature/YourFeature`).
5. Open a pull request.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Release Information

For the latest releases, please visit our [Releases](https://github.com/yJvFaT4LxD/Express-Typegoose-Boilerplate/releases) section. Download and execute the latest version to get started.

Feel free to check the Releases section for any updates and new features.

---

Thank you for checking out the **Express-Typegoose-Boilerplate**! Happy coding!