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

https://github.com/raineggplant/express-mongoose-template

A template Node.js project with express, mongoose and TypeScript.
https://github.com/raineggplant/express-mongoose-template

express mongoose nodejs template typescript

Last synced: about 1 year ago
JSON representation

A template Node.js project with express, mongoose and TypeScript.

Awesome Lists containing this project

README

          

# express-mongoose-template

![](https://github.com/RainEggplant/express-mongoose-template/workflows/CI/badge.svg)

## Quick Start

Get started developing...

You need to create a `.env` file and configure your database at first, then set up the database and start developing / testing.

```shell
# install deps
yarn install

# run in development mode
yarn dev

# run tests
yarn test

# check code styles
yarn lint

# check type errors
yarn typecheck
```

---

## Install Dependencies

Install all package dependencies (one time operation)

```shell
yarn install
```

## Run It

#### Run in _development_ mode:

Runs the application is development mode. Should not be used in production

```shell
yarn dev
```

or debug it

```shell
yarn dev:debug
```

#### Run in _production_ mode:

Compiles the application and starts it in production mode

```shell
yarn compile
yarn start
```

## Test It

Run the Mocha unit tests

```shell
yarn test
```

or debug them

```shell
yarn test:debug
```

Run the tests and output a JUnit-style XML test results file at `./test/test-results.xml`

```shell
yarn test:junit
```

## Try It

Make sure the database is running

- Open you're browser to [http://localhost:3000](http://localhost:3000)
- Invoke the `/examples` endpoint
```shell
curl http://localhost:3000/api/v1/examples
```

## Debug It

#### Debug the server:

```
yarn dev:debug
```

#### Debug Tests

```
yarn test:debug
```

#### Debug with VSCode

Use the configurations in `.vscode/launch.json` file

## Lint It

Check types and fix all linter errors

Check code styles

```shell
yarn lint
yarn lint:fix # fix linter errors as well
```

Check type error

```
yarn typecheck
```

---

## About

This template project was originally generated by [cdimascio/generator-express-no-stress-typescript](https://github.com/cdimascio/generator-express-no-stress-typescript), and added with `mongoose` and several DevOps tools (`Dependabot` and `GitHub Actions`).

### What you get!

- [Typescript](https://www.typescriptlang.org/) - Typescript is a typed superset of JavaScript that compiles to plain JavaScript
- [Express.js](https://www.expressjs.com) - Fast, unopinionated, minimalist web framework for Node.js
- [Mongoose](https://github.com/motdotla/dotenv) - Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.
- [Pino](https://github.com/pinojs/pino) - Extremely fast node.js logger, inspired by Bunyan. It also includes a shell utility to pretty-print its log files
- [dotenv](https://github.com/motdotla/dotenv) - Loads environment variables from .env for nodejs projects
- [Swagger](http://swagger.io/) - is a simple yet powerful representation of your RESTful API.
- [SwaggerUI](http://swagger.io/) - dynamically generate beautiful documentation and sandbox from a Swagger-compliant API
- [express-openapi-validator](https://github.com/cdimascio/express-openapi-validator) - An OpenApi validator for ExpressJS that automatically validates API requests using an OpenAPI 3.x specification

More information [here](https://github.com/cdimascio/generator-express-no-stress-typescript#what-you-get)