Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vinicamposdev/clean-ts-api
NodeJs API using Typescript, TDD, DDD, Clean Architecture, Design Patterns, and SOLID principles
https://github.com/vinicamposdev/clean-ts-api
clean-architecture ddd design-patterns mongodb solid tdd typescript
Last synced: 12 days ago
JSON representation
NodeJs API using Typescript, TDD, DDD, Clean Architecture, Design Patterns, and SOLID principles
- Host: GitHub
- URL: https://github.com/vinicamposdev/clean-ts-api
- Owner: vinicamposdev
- Created: 2021-01-22T14:52:05.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-04-21T17:42:33.000Z (almost 2 years ago)
- Last Synced: 2024-11-20T16:55:35.859Z (2 months ago)
- Topics: clean-architecture, ddd, design-patterns, mongodb, solid, tdd, typescript
- Language: TypeScript
- Homepage:
- Size: 841 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.com/vinicamposdev/clean-ts-api.svg?branch=main)](https://travis-ci.com/vinicamposdev/clean-ts-api)
[![Coverage Status](https://coveralls.io/repos/github/vinicamposdev/clean-ts-api/badge.svg?branch=main)](https://coveralls.io/github/vinicamposdev/clean-ts-api?branch=main)## Up & Running
1. Install local dependencies:
```terminal
npm install
```2. Tests run with sufix unit or integration depending on what will be tested:
```terminal
npm test:unit
npm test:integration
```## Scripts
| Script | Description |
| ----------------------------- | ------------------------------------------------------------- |
| `npm run start` | Run production server |
| `npm run debug` | Run dev server |
| `npm run build` | Generates production build |
| `npm run build:watch` | Run unit tests in watch mode |
| `npm run up` | Run container with development env |
| `npm run down` | Stop containers |
| `npm run test` | Run all tests |
| `npm run test:unit` | Run unit tests |
| `npm run test:integration` | Run integration tests |
| `npm run test:staged` | Run unit and integration tests once (great to be used in CI) |
| `npm run test:ci` | Run Covererage test (great to be used in CD) |
| `npm run test:coveralls` | Run coveralls to publish coverage |## Tree structure
This project uses Clean Architecture and some ideas from Domain Driven Desing with Object Oriented Programming.
```terminal
.
├── src
│ ├── data
│ │ ├── protocols
│ │ └── usecases
│ ├── domain
│ │ ├── models
│ │ └── usecases
│ ├── infra
│ │ ├── cryptography
│ │ ├── db
│ │ └── validators
│ ├── main
│ │ ├── adapters
│ │ ├── config
│ │ ├── factories
│ │ │ └── controllers
│ │ └── server.ts
│ ├── presentation
│ └── validation
├── tests
├── jest-integration-config.js
├── jest-unit-config.js
└── jest.config.js
```| Directory / File | Description |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `src` | All source code write in TypeScript must be in this directory |
| `tests` | All test files must be in this directory |
| `src/main/server.ts` | Main entry point for initial configuration of the project. **Do not edit this file.** Start with `src/app.ts`. |
| `src/main/config/env.ts` | List of Environment Variables. |
| `jest-integration-config.js` | Jest configuration file for integration tests |
| `jest-unit-config.js` | Jest configuration file for unit tests |
| `jest.config.js` | Main Jest configuration file |## Important usage information
### Developer workflow
From Clean Architecture recommendations, there is a layer order to develop. The rule is:
1. Domain
- 1.1 models
- 1.2 usecases
2. Data
- 2.1 usecases
- 2.2 protocols
3. Infra
- 3.1 db repositories
- 3.2 criptography / validators
4. Presentation
- 4.1 controllers
5. Validation
6. Main
- 6.1 routes
- 6.2 factories controllers
- 6.3 factories usecases
- 6.4 adapters
- 6.4 config### Environment Variables
Just put all your env vars on file `src/main/config/env.ts`.
### Global import
All files and dirs inside `src` directory can be imported using `@/`.
Prefer using this way over local import (`../../`).## License
MIT