Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mugarate12/basic-node-ts-config
NPM module to get a Basic Nodejs Configuration with API using Express and Typescript
https://github.com/mugarate12/basic-node-ts-config
docer-compose docker express node-js redis typescript
Last synced: 21 days ago
JSON representation
NPM module to get a Basic Nodejs Configuration with API using Express and Typescript
- Host: GitHub
- URL: https://github.com/mugarate12/basic-node-ts-config
- Owner: mugarate12
- Created: 2022-09-04T06:52:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-06T13:05:30.000Z (over 1 year ago)
- Last Synced: 2024-12-01T09:13:57.208Z (about 1 month ago)
- Topics: docer-compose, docker, express, node-js, redis, typescript
- Language: TypeScript
- Homepage:
- Size: 231 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Basic Configuration to Nodejs With Express and Typescript
> This module serving a basic structure and configuration of nodejs API with express and typescript
## Summary
- [Getting Started](#getting-started)
- [Usage](#usage)
- [Folder Structure](#folder-structure)
- [Basic Scripts In Project](#basic-scripts-in-project)
- [Docker Scripts In Project](#docker-scripts-in-project)
- [Future Features](#future-features)## Getting Started
### Prerequisites
- [Nodejs](https://nodejs.org/en/)
- [NPM](https://www.npmjs.com/get-npm)
- [Redis](https://redis.io/)
- [Docker](https://www.docker.com/get-started) (Optional)## Usage
- Use this command in terminal and get initial structure, modules and development ambient to start your nodejs application
```shell
npx create-node-basic [YOUR_PROJECT_NAME]
```## Folder Structure
- Your project get this structure
```
project
│ .env.example
│ .gitignore
│ .dockerignore
│ CHANGELOG.md
│ README.md
│ docker-compose.yml
│ docker-compose.test.yml
│ docker-compose.dev.yml
│ Dockerfile
│ Dockerfile.test
│ Dockerfile.dev
│ babel.config.js
│ package-lock.json
│ package.json
│ tsconfig.json
│ tsconfig.spec.json
│ pm2.json
│ nginx
| │ default.conf
| │ Dockerfile
│ docs
| │ docs.yaml
│ __tests__
│ └───unit
| │ | example.test.ts
| │ | redis.test.ts
│ └───integration
| │ | example.test.ts
└───src
| | app.ts
| | server.ts
│ └───config
│ | │ redisClient.ts
│ | │ index.ts
│ └───controllers
│ | │ ExampleController.ts
│ | │ index.ts
│ └───services
│ | │ Example.services.ts
│ | │ index.ts
│ └───routes
│ | │ example.routes.ts
│ | │ index.ts
| └───utils
│ │ createToken.ts
│ │ handleError.ts
│ │ index.ts
```## Basic Scripts In Project
- Your package.json have initial commands to build, run, test and create server to development
build your project:
```shell
npm run build
```build your project and immediately run your app builded:
```shell
npm start
```run project in production mode with pm2:
```shell
npm run start:pm2
```run project in development build:
```shell
npm run dev
```run all of tests in project:
```shell
npm run test
```
> Test your application run correctlly to send HTTP GET to localhost:8000## Docker Scripts In Project
run your project in docker to production (docker-compose -f ./docker-compose.yml up):
```shell
npm run docker:prod
```run your project in docker to development (docker-compose -f ./docker-compose.dev.yml up):
```shell
npm run docker:dev
```run your project in docker to test (docker-compose -f ./docker-compose.test.yml up):
```shell
npm run docker:test
```run your project in docker to production (docker-compose -f ./docker-compose.yml up --build):
```shell
npm run docker:prod:build
```run your project in docker to development (docker-compose -f ./docker-compose.dev.yml up --build):
```shell
npm run docker:dev:build
```run your project in docker to test (docker-compose -f ./docker-compose.test.yml up --build):
```shell
npm run docker:test:build
```## Future Features
- [ ] Explain how design patters used in your initial configuration of project
- [ ] Explain how to use your initial configuration of project
- [x] Add options to get initial Dockerfile and docker-compose.yml to run your project in docker
- [x] Use Redis as cache
- [x] Use pm2 to run your project in production mode
- [x] Use Nginx as reverse proxy
- [x] Use Swagger to document your API👔 [Linkedin](https://www.linkedin.com/in/mateus-cardoso-dos-santos-19a68a181/)