Skip to content

Commit b3687ca

Browse files
committed
Initial Architecture Design using Nestjs
0 parents  commit b3687ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+24901
-0
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
max_line_length = off
13+
trim_trailing_whitespace = false

.eslintrc.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": ["**/*"],
4+
"plugins": ["@nrwl/nx"],
5+
"overrides": [
6+
{
7+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
8+
"rules": {
9+
"@nrwl/nx/enforce-module-boundaries": [
10+
"error",
11+
{
12+
"enforceBuildableLibDependency": true,
13+
"allow": [],
14+
"depConstraints": [
15+
{
16+
"sourceTag": "*",
17+
"onlyDependOnLibsWithTags": ["*"]
18+
}
19+
]
20+
}
21+
]
22+
}
23+
},
24+
{
25+
"files": ["*.ts", "*.tsx"],
26+
"extends": ["plugin:@nrwl/nx/typescript"],
27+
"rules": {}
28+
},
29+
{
30+
"files": ["*.js", "*.jsx"],
31+
"extends": ["plugin:@nrwl/nx/javascript"],
32+
"rules": {}
33+
}
34+
]
35+
}

.gitignore

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
8+
# dependencies
9+
/node_modules
10+
11+
# IDEs and editors
12+
/.idea
13+
.project
14+
.classpath
15+
.c9/
16+
*.launch
17+
.settings/
18+
*.sublime-workspace
19+
20+
# IDE - VSCode
21+
.vscode/*
22+
!.vscode/settings.json
23+
!.vscode/tasks.json
24+
!.vscode/launch.json
25+
!.vscode/extensions.json
26+
27+
# misc
28+
/.sass-cache
29+
/connect.lock
30+
/coverage
31+
/libpeerconnection.log
32+
npm-debug.log
33+
yarn-error.log
34+
testem.log
35+
/typings
36+
37+
# System Files
38+
.DS_Store
39+
Thumbs.db

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Add files here to ignore them from prettier formatting
2+
3+
/dist
4+
/coverage

.prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

.vs/slnx.sqlite

88 KB
Binary file not shown.

README.md

+178
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
<div id="top"></div>
2+
<!--
3+
*** Thanks for review Nestjs Microservices project
4+
-->
5+
6+
<!-- PROJECT SHIELDS -->
7+
<!--
8+
*** A micro-services solution using Nestjs
9+
-->
10+
[![Issues][issues-shield]][issues-url]
11+
[![MIT License][license-shield]][license-url]
12+
[![LinkedIn][linkedin-shield]][linkedin-url]
13+
14+
<!-- PROJECT LOGO -->
15+
<br />
16+
<div align="center">
17+
<a href="//github.com/imatiqul/nestjs-microservices">
18+
<img src="//docs.nestjs.com/assets/logo-small.svg" alt="Logo" width="80" height="80">
19+
</a>
20+
21+
<h3 align="center">Nestjs Microservices</h3>
22+
23+
<p align="center">
24+
Sample Nestjs Microservices application, based on a simplified Vertical Slice Architecture and best practices using Nestjs and Nodejs.
25+
<br />
26+
<a href="#getting-started"><strong>Explore the docs »</strong></a>
27+
<br />
28+
<br />
29+
<a href="//github.com/imatiqul/nestjs-microservices/issues">Report Bug</a>
30+
·
31+
<a href="//github.com/imatiqul/nestjs-microservices/issues">Request Feature</a>
32+
</p>
33+
</div>
34+
35+
<!-- TABLE OF CONTENTS -->
36+
<details>
37+
<summary>Table of Contents</summary>
38+
<ol>
39+
<li>
40+
<a href="#about-the-project">About The Project</a>
41+
<ul>
42+
<li><a href="#built-with">Built With</a></li>
43+
</ul>
44+
</li>
45+
<li>
46+
<a href="#getting-started">Getting Started</a>
47+
<ul>
48+
<li><a href="#prerequisites">Prerequisites</a></li>
49+
<li><a href="#how-to-run">How to Run</a></li>
50+
</ul>
51+
</li>
52+
<li><a href="#usage">Usage</a></li>
53+
<li><a href="#roadmap">Roadmap</a></li>
54+
<li><a href="#contributing">Contributing</a></li>
55+
<li><a href="#license">License</a></li>
56+
<li><a href="#contact">Contact</a></li>
57+
<li><a href="#acknowledgments">Acknowledgments</a></li>
58+
</ol>
59+
</details>
60+
61+
<!-- ABOUT THE PROJECT -->
62+
## About The Project
63+
64+
While designing architecture of REST API using Nestjs, we need to consider following areas
65+
| Areas | Node.js |
66+
| ----- | ----- |
67+
| API Security | Nestjs JwtModule |
68+
| API Versioning | Nestjs URL Versioning |
69+
| API Validation | Nestjs ValidationPipe |
70+
| API Documentation | Nestjs OpenApi |
71+
| Using DTOs (Object to Object Mapper) | TypeORM |
72+
| CORS Policy | Nestjs CORS |
73+
| Health Check | Healthchecks (Terminus) |
74+
| Dependency Injection | Built-in DI |
75+
| Logging | Nestjs-OpenTelemetry |
76+
| ORM | TypeORM |
77+
| CQRS pattern | Nestjs CQRS |
78+
| JSON Serialization | class-transformer |
79+
| Cross-cutting API calls | Nestjs ClientProxy |
80+
| Handle Errors Globally | useGlobalFilters |
81+
| Keep common code paths fast | Middleware |
82+
| Caching | Nestjs Caching |
83+
| Data Protection | Nestjs Security |
84+
| Avoid blocking calls | Asynchronous providers |
85+
| Complete long-running Tasks outside of HTTP requests | Nestjs Schedule |
86+
87+
Here's why:
88+
* Vertical Slice Architecture
89+
* Best practices for Microservices
90+
* Low Code
91+
*
92+
93+
<p align="right">(<a href="#top">back to top</a>)</p>
94+
95+
### Built With
96+
97+
This section should list any major frameworks/libraries used to bootstrap the project.
98+
99+
* [Nest Plugin](https://nx.dev/nest/overview)
100+
* [Nestjs](https://nestjs.com/)
101+
* [Node.js](https://nodejs.org/en/)
102+
* [Yarn](https://yarnpkg.com/)
103+
104+
<p align="right">(<a href="#top">back to top</a>)</p>
105+
106+
<!-- GETTING STARTED -->
107+
## Getting Started
108+
109+
Instructions on setting up the project locally.
110+
111+
### Prerequisites
112+
* Node.js
113+
* npm
114+
```sh
115+
npm install npm@latest -g
116+
```
117+
* yarn
118+
```sh
119+
npm install yarn -g
120+
```
121+
122+
### How to Run
123+
124+
_Below is the instructions of how you can install and run the app._
125+
126+
1. Clone the repo
127+
```sh
128+
git clone https://github.com/imatiqul/nestjs-microservices.git
129+
```
130+
2. Run project
131+
```sh
132+
cd mf-basket-app
133+
yarn
134+
yarn start
135+
```
136+
<p align="right">(<a href="#top">back to top</a>)</p>
137+
138+
<!-- USAGE EXAMPLES -->
139+
## Usage
140+
141+
<p align="right">(<a href="#top">back to top</a>)</p>
142+
143+
<!-- ROADMAP -->
144+
## Roadmap
145+
146+
<p align="right">(<a href="#top">back to top</a>)</p>
147+
148+
<!-- CONTRIBUTING -->
149+
## Contributing
150+
151+
1. Fork the Project
152+
2. Create your Feature Branch (`git checkout -b feature/mf-feature`)
153+
3. Commit your Changes (`git commit -m 'Add some mf-feature'`)
154+
4. Push to the Branch (`git push origin feature/mf-feature`)
155+
5. Open a Pull Request
156+
157+
<p align="right">(<a href="#top">back to top</a>)</p>
158+
159+
<!-- LICENSE -->
160+
## License
161+
162+
Distributed under the MIT License. See `LICENSE.txt` for more information.
163+
164+
<p align="right">(<a href="#top">back to top</a>)</p>
165+
166+
<!-- CONTACT -->
167+
## Contact
168+
169+
ATIQUL ISLAM - [@ATIQ](https://imatiqul.com/) - [email protected]
170+
171+
Project Link: [https://github.com/imatiqul/nestjs-microservices](https://github.com/imatiqul/nestjs-microservices)
172+
173+
<p align="right">(<a href="#top">back to top</a>)</p>
174+
175+
<!-- ACKNOWLEDGMENTS -->
176+
## Acknowledgments
177+
178+
<p align="right">(<a href="#top">back to top</a>)</p>

apps/.gitkeep

Whitespace-only changes.

apps/eshop/.eslintrc.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}

apps/eshop/jest.config.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
displayName: 'eshop',
3+
preset: '../../jest.preset.js',
4+
globals: {
5+
'ts-jest': {
6+
tsconfig: '<rootDir>/tsconfig.spec.json',
7+
},
8+
},
9+
testEnvironment: 'node',
10+
transform: {
11+
'^.+\\.[tj]s$': 'ts-jest',
12+
},
13+
moduleFileExtensions: ['ts', 'js', 'html'],
14+
coverageDirectory: '../../coverage/apps/eshop',
15+
};

apps/eshop/project.json

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"root": "apps/eshop",
3+
"sourceRoot": "apps/eshop/src",
4+
"projectType": "application",
5+
"targets": {
6+
"build": {
7+
"executor": "@nrwl/node:build",
8+
"outputs": ["{options.outputPath}"],
9+
"options": {
10+
"outputPath": "dist/apps/eshop",
11+
"main": "apps/eshop/src/main.ts",
12+
"tsConfig": "apps/eshop/tsconfig.app.json",
13+
"assets": ["apps/eshop/src/assets"]
14+
},
15+
"configurations": {
16+
"production": {
17+
"optimization": true,
18+
"extractLicenses": true,
19+
"inspect": false,
20+
"fileReplacements": [
21+
{
22+
"replace": "apps/eshop/src/environments/environment.ts",
23+
"with": "apps/eshop/src/environments/environment.prod.ts"
24+
}
25+
]
26+
}
27+
}
28+
},
29+
"serve": {
30+
"executor": "@nrwl/node:execute",
31+
"options": {
32+
"buildTarget": "eshop:build"
33+
}
34+
},
35+
"lint": {
36+
"executor": "@nrwl/linter:eslint",
37+
"outputs": ["{options.outputFile}"],
38+
"options": {
39+
"lintFilePatterns": ["apps/eshop/**/*.ts"]
40+
}
41+
},
42+
"test": {
43+
"executor": "@nrwl/jest:jest",
44+
"outputs": ["coverage/apps/eshop"],
45+
"options": {
46+
"jestConfig": "apps/eshop/jest.config.js",
47+
"passWithNoTests": true
48+
}
49+
}
50+
},
51+
"tags": []
52+
}

apps/eshop/src/app/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)