@merkaly/api 0.1.4 → 0.1.9-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -79
- package/package.json +89 -96
- package/src/account/account.module.d.ts +4 -0
- package/src/account/account.module.ts +15 -0
- package/src/account/auth/auth.controller.d.ts +10 -0
- package/src/account/auth/auth.controller.ts +38 -0
- package/src/account/auth/auth.decorator.d.ts +4 -0
- package/src/account/auth/auth.decorator.ts +10 -0
- package/src/account/auth/auth.guard.d.ts +15 -0
- package/src/account/auth/auth.guard.ts +41 -0
- package/src/account/auth/auth.module.d.ts +4 -0
- package/src/account/auth/auth.module.ts +26 -0
- package/src/account/auth/auth.repository.d.ts +6 -0
- package/src/account/auth/auth.repository.ts +39 -0
- package/src/account/auth/auth.strategy.d.ts +17 -0
- package/src/account/auth/auth.strategy.ts +31 -0
- package/src/account/auth/auth.validator.d.ts +4 -0
- package/src/account/auth/auth.validator.ts +11 -11
- package/src/account/auth/index.d.ts +1 -0
- package/src/account/auth/index.ts +1 -0
- package/src/account/index.d.ts +4 -0
- package/src/account/index.ts +4 -0
- package/src/account/organizations/index.d.ts +3 -0
- package/src/account/organizations/index.ts +3 -0
- package/src/account/organizations/members/index.d.ts +1 -0
- package/src/account/organizations/members/index.ts +1 -0
- package/src/account/organizations/members/member.controller.d.ts +9 -0
- package/src/account/organizations/members/member.controller.ts +33 -0
- package/src/account/organizations/members/member.entity.d.ts +9 -0
- package/src/account/organizations/members/member.entity.ts +11 -11
- package/src/account/organizations/members/member.module.d.ts +4 -0
- package/src/account/organizations/members/member.module.ts +14 -0
- package/src/account/organizations/members/member.repository.d.ts +12 -0
- package/src/account/organizations/members/member.repository.ts +43 -0
- package/src/account/organizations/members/member.validator.d.ts +2 -0
- package/src/account/organizations/members/member.validator.ts +3 -0
- package/src/account/organizations/organization.controller.d.ts +11 -0
- package/src/account/organizations/organization.controller.ts +42 -0
- package/src/account/organizations/organization.entity.d.ts +17 -0
- package/src/account/organizations/organization.entity.ts +24 -21
- package/src/account/organizations/organization.module.d.ts +4 -0
- package/src/account/organizations/organization.module.ts +16 -0
- package/src/account/organizations/organization.repository.d.ts +12 -0
- package/src/account/organizations/organization.repository.ts +74 -0
- package/src/account/organizations/organization.validator.d.ts +13 -0
- package/src/account/organizations/organization.validator.ts +52 -41
- package/src/account/roles/index.d.ts +3 -0
- package/src/account/roles/index.ts +3 -0
- package/src/account/roles/role.controller.d.ts +11 -0
- package/src/account/roles/role.controller.ts +39 -0
- package/src/account/roles/role.entity.d.ts +7 -0
- package/src/account/roles/role.entity.ts +9 -9
- package/src/account/roles/role.module.d.ts +4 -0
- package/src/account/roles/role.module.ts +15 -0
- package/src/account/roles/role.repository.d.ts +12 -0
- package/src/account/roles/role.repository.ts +63 -0
- package/src/account/roles/role.validator.d.ts +9 -0
- package/src/account/roles/role.validator.ts +21 -21
- package/src/account/roles/users/index.d.ts +2 -0
- package/src/account/roles/users/index.ts +2 -0
- package/src/account/roles/users/user.controller.d.ts +8 -0
- package/src/account/roles/users/user.controller.ts +28 -0
- package/src/account/roles/users/user.entity.d.ts +9 -0
- package/src/account/roles/users/user.entity.ts +11 -11
- package/src/account/roles/users/user.module.d.ts +4 -0
- package/src/account/roles/users/user.module.ts +14 -0
- package/src/account/roles/users/user.repository.d.ts +11 -0
- package/src/account/roles/users/user.repository.ts +34 -0
- package/src/account/roles/users/user.validator.d.ts +2 -0
- package/src/account/roles/users/user.validator.ts +3 -10
- package/src/account/users/index.d.ts +3 -0
- package/src/account/users/index.ts +3 -0
- package/src/account/users/roles/index.d.ts +2 -0
- package/src/account/users/roles/index.ts +2 -0
- package/src/account/users/roles/role.controller.d.ts +9 -0
- package/src/account/users/roles/role.controller.ts +34 -0
- package/src/account/users/roles/role.entity.d.ts +9 -0
- package/src/account/users/roles/role.entity.ts +11 -11
- package/src/account/users/roles/role.module.d.ts +4 -0
- package/src/account/users/roles/role.module.ts +14 -0
- package/src/account/users/roles/role.repository.d.ts +12 -0
- package/src/account/users/roles/role.repository.ts +38 -0
- package/src/account/users/roles/role.validator.d.ts +2 -0
- package/src/account/users/roles/role.validator.ts +3 -10
- package/src/account/users/user.controller.d.ts +11 -0
- package/src/account/users/user.controller.ts +39 -0
- package/src/account/users/user.entity.d.ts +32 -0
- package/src/account/users/user.entity.ts +36 -36
- package/src/account/users/user.module.d.ts +4 -0
- package/src/account/users/user.module.ts +15 -0
- package/src/account/users/user.repository.d.ts +12 -0
- package/src/account/users/user.repository.ts +53 -0
- package/src/account/users/user.validator.d.ts +11 -0
- package/src/account/users/user.validator.ts +29 -29
- package/src/app.d.ts +1 -0
- package/src/app.emitter.d.ts +16 -0
- package/src/app.emitter.ts +27 -0
- package/src/app.entity.d.ts +7 -0
- package/src/app.entity.ts +13 -20
- package/src/app.module.d.ts +9 -0
- package/src/app.module.ts +45 -0
- package/src/app.repository.d.ts +5 -0
- package/src/app.repository.ts +12 -0
- package/src/app.routes.d.ts +3 -0
- package/src/app.routes.ts +61 -0
- package/src/index.d.ts +3 -0
- package/src/index.ts +3 -0
- package/src/inventory/brands/brand.controller.d.ts +11 -0
- package/src/inventory/brands/brand.controller.ts +41 -0
- package/src/inventory/brands/brand.entity.d.ts +5 -0
- package/src/inventory/brands/brand.entity.ts +10 -10
- package/src/inventory/brands/brand.module.d.ts +4 -0
- package/src/inventory/brands/brand.module.ts +14 -0
- package/src/inventory/brands/brand.repository.d.ts +13 -0
- package/src/inventory/brands/brand.repository.ts +36 -0
- package/src/inventory/brands/brand.validator.d.ts +6 -0
- package/src/inventory/brands/brand.validator.ts +12 -12
- package/src/inventory/brands/index.d.ts +2 -0
- package/src/inventory/brands/index.ts +2 -0
- package/src/inventory/categories/category.controller.d.ts +11 -0
- package/src/inventory/categories/category.controller.ts +43 -0
- package/src/inventory/categories/category.entity.d.ts +5 -0
- package/src/inventory/categories/category.entity.ts +10 -10
- package/src/inventory/categories/category.module.d.ts +4 -0
- package/src/inventory/categories/category.module.ts +14 -0
- package/src/inventory/categories/category.repository.d.ts +13 -0
- package/src/inventory/categories/category.repository.ts +36 -0
- package/src/inventory/categories/category.validator.d.ts +6 -0
- package/src/inventory/categories/category.validator.ts +11 -11
- package/src/inventory/categories/index.d.ts +2 -0
- package/src/inventory/categories/index.ts +2 -0
- package/src/inventory/index.d.ts +5 -0
- package/src/inventory/index.ts +6 -0
- package/src/inventory/inventory.module.d.ts +4 -0
- package/src/inventory/inventory.module.ts +17 -0
- package/src/inventory/products/index.d.ts +4 -0
- package/src/inventory/products/index.ts +4 -0
- package/src/inventory/products/media/index.d.ts +2 -0
- package/src/inventory/products/media/index.ts +2 -0
- package/src/inventory/products/media/media.controller.d.ts +7 -0
- package/src/inventory/products/media/media.controller.ts +23 -0
- package/src/inventory/products/media/media.entity.d.ts +6 -0
- package/src/inventory/products/media/media.entity.ts +10 -10
- package/src/inventory/products/media/media.module.d.ts +4 -0
- package/src/inventory/products/media/media.module.ts +14 -0
- package/src/inventory/products/media/media.repository.d.ts +10 -0
- package/src/inventory/products/media/media.repository.ts +22 -0
- package/src/inventory/products/media/media.validator.d.ts +4 -0
- package/src/inventory/products/media/media.validator.ts +7 -7
- package/src/inventory/products/product.controller.d.ts +12 -0
- package/src/inventory/products/product.controller.ts +59 -0
- package/src/inventory/products/product.entity.d.ts +31 -0
- package/src/inventory/products/product.entity.ts +63 -63
- package/src/inventory/products/product.module.d.ts +4 -0
- package/src/inventory/products/product.module.ts +16 -0
- package/src/inventory/products/product.repository.d.ts +18 -0
- package/src/inventory/products/product.repository.ts +94 -0
- package/src/inventory/products/product.validator.d.ts +21 -0
- package/src/inventory/products/product.validator.ts +70 -70
- package/src/inventory/products/variants/index.d.ts +2 -0
- package/src/inventory/products/variants/index.ts +2 -0
- package/src/inventory/products/variants/variant.controller.d.ts +7 -0
- package/src/inventory/products/variants/variant.controller.ts +23 -0
- package/src/inventory/products/variants/variant.entity.d.ts +6 -0
- package/src/inventory/products/variants/variant.entity.ts +11 -11
- package/src/inventory/products/variants/variant.module.d.ts +4 -0
- package/src/inventory/products/variants/variant.module.ts +14 -0
- package/src/inventory/products/variants/variant.repository.d.ts +10 -0
- package/src/inventory/products/variants/variant.repository.ts +23 -0
- package/src/inventory/products/variants/variant.validator.d.ts +4 -0
- package/src/inventory/products/variants/variant.validator.ts +7 -7
- package/src/inventory/properties/index.d.ts +2 -0
- package/src/inventory/properties/index.ts +2 -0
- package/src/inventory/properties/property.controller.d.ts +11 -0
- package/src/inventory/properties/property.controller.ts +42 -0
- package/src/inventory/properties/property.entity.d.ts +8 -0
- package/src/inventory/properties/property.entity.ts +19 -19
- package/src/inventory/properties/property.module.d.ts +4 -0
- package/src/inventory/properties/property.module.ts +14 -0
- package/src/inventory/properties/property.repository.d.ts +13 -0
- package/src/inventory/properties/property.repository.ts +38 -0
- package/src/inventory/properties/property.validator.d.ts +8 -0
- package/src/inventory/properties/property.validator.ts +20 -20
- package/src/store/carts/cart.controller.d.ts +11 -0
- package/src/store/carts/cart.controller.ts +44 -0
- package/src/store/carts/cart.entity.d.ts +14 -0
- package/src/store/carts/cart.entity.ts +21 -21
- package/src/store/carts/cart.module.d.ts +4 -0
- package/src/store/carts/cart.module.ts +14 -0
- package/src/store/carts/cart.repository.d.ts +13 -0
- package/src/store/carts/cart.repository.ts +36 -0
- package/src/store/carts/cart.validator.d.ts +4 -0
- package/src/store/carts/cart.validator.ts +7 -7
- package/src/store/carts/index.d.ts +2 -0
- package/src/store/carts/index.ts +2 -0
- package/src/store/index.d.ts +3 -0
- package/src/store/index.ts +4 -0
- package/src/store/orders/index.d.ts +3 -0
- package/src/store/orders/index.ts +3 -0
- package/src/store/orders/items/index.d.ts +2 -0
- package/src/store/orders/items/index.ts +2 -0
- package/src/store/orders/items/item.controller.d.ts +11 -0
- package/src/store/orders/items/item.controller.ts +41 -0
- package/src/store/orders/items/item.entity.d.ts +7 -0
- package/src/store/orders/items/item.entity.ts +14 -14
- package/src/store/orders/items/item.module.d.ts +4 -0
- package/src/store/orders/items/item.module.ts +14 -0
- package/src/store/orders/items/item.repository.d.ts +13 -0
- package/src/store/orders/items/item.repository.ts +35 -0
- package/src/store/orders/items/item.validator.d.ts +4 -0
- package/src/store/orders/items/item.validator.ts +7 -7
- package/src/store/orders/order.controller.d.ts +11 -0
- package/src/store/orders/order.controller.ts +44 -0
- package/src/store/orders/order.entity.d.ts +9 -0
- package/src/store/orders/order.entity.ts +18 -18
- package/src/store/orders/order.module.d.ts +4 -0
- package/src/store/orders/order.module.ts +15 -0
- package/src/store/orders/order.repository.d.ts +13 -0
- package/src/store/orders/order.repository.ts +35 -0
- package/src/store/orders/order.validator.d.ts +4 -0
- package/src/store/orders/order.validator.ts +7 -7
- package/src/store/store.module.d.ts +4 -0
- package/src/store/store.module.ts +14 -0
package/README.md
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
|
|
6
|
-
|
|
7
|
-
[travis-url]: https://travis-ci.org/nestjs/nest
|
|
8
|
-
|
|
9
|
-
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
|
|
10
|
-
|
|
11
|
-
[linux-url]: https://travis-ci.org/nestjs/nest
|
|
12
|
-
|
|
13
|
-
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
|
|
14
|
-
<p align="center">
|
|
15
|
-
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
|
16
|
-
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
|
17
|
-
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
|
|
18
|
-
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
|
|
19
|
-
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
|
20
|
-
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
|
|
21
|
-
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
|
|
22
|
-
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
|
23
|
-
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
|
24
|
-
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-dc3d53.svg"/></a>
|
|
25
|
-
<a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
|
26
|
-
</p>
|
|
27
|
-
<!--[](https://opencollective.com/nest#backer)
|
|
28
|
-
[](https://opencollective.com/nest#sponsor)-->
|
|
29
|
-
|
|
30
|
-
## Description
|
|
31
|
-
|
|
32
|
-
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
|
33
|
-
|
|
34
|
-
## Installation
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
$ npm install
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Running the app
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
# development
|
|
44
|
-
$ npm run start
|
|
45
|
-
|
|
46
|
-
# watch mode
|
|
47
|
-
$ npm run start:dev
|
|
48
|
-
|
|
49
|
-
# production mode
|
|
50
|
-
$ npm run start:prod
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## Test
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
# unit tests
|
|
57
|
-
$ npm run test
|
|
58
|
-
|
|
59
|
-
# e2e tests
|
|
60
|
-
$ npm run test:e2e
|
|
61
|
-
|
|
62
|
-
# test coverage
|
|
63
|
-
$ npm run test:cov
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Support
|
|
67
|
-
|
|
68
|
-
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If
|
|
69
|
-
you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
|
70
|
-
|
|
71
|
-
## Stay in touch
|
|
72
|
-
|
|
73
|
-
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
|
74
|
-
- Website - [https://nestjs.com](https://nestjs.com/)
|
|
75
|
-
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
|
76
|
-
|
|
77
|
-
## License
|
|
78
|
-
|
|
79
|
-
Nest is [MIT licensed](LICENSE).
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
|
|
6
|
+
|
|
7
|
+
[travis-url]: https://travis-ci.org/nestjs/nest
|
|
8
|
+
|
|
9
|
+
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
|
|
10
|
+
|
|
11
|
+
[linux-url]: https://travis-ci.org/nestjs/nest
|
|
12
|
+
|
|
13
|
+
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
|
16
|
+
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
|
17
|
+
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
|
|
18
|
+
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
|
|
19
|
+
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
|
20
|
+
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
|
|
21
|
+
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
|
|
22
|
+
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
|
23
|
+
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
|
24
|
+
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-dc3d53.svg"/></a>
|
|
25
|
+
<a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
|
26
|
+
</p>
|
|
27
|
+
<!--[](https://opencollective.com/nest#backer)
|
|
28
|
+
[](https://opencollective.com/nest#sponsor)-->
|
|
29
|
+
|
|
30
|
+
## Description
|
|
31
|
+
|
|
32
|
+
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
$ npm install
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Running the app
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# development
|
|
44
|
+
$ npm run start
|
|
45
|
+
|
|
46
|
+
# watch mode
|
|
47
|
+
$ npm run start:dev
|
|
48
|
+
|
|
49
|
+
# production mode
|
|
50
|
+
$ npm run start:prod
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Test
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# unit tests
|
|
57
|
+
$ npm run test
|
|
58
|
+
|
|
59
|
+
# e2e tests
|
|
60
|
+
$ npm run test:e2e
|
|
61
|
+
|
|
62
|
+
# test coverage
|
|
63
|
+
$ npm run test:cov
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Support
|
|
67
|
+
|
|
68
|
+
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If
|
|
69
|
+
you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
|
70
|
+
|
|
71
|
+
## Stay in touch
|
|
72
|
+
|
|
73
|
+
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
|
74
|
+
- Website - [https://nestjs.com](https://nestjs.com/)
|
|
75
|
+
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
Nest is [MIT licensed](LICENSE).
|
package/package.json
CHANGED
|
@@ -1,96 +1,89 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@merkaly/api",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "NestJS Backend ApiRest Service",
|
|
5
|
-
"author": "Randy Tellez Galan <kronhyx@gmail.com>",
|
|
6
|
-
"license": "UNLICENSED",
|
|
7
|
-
"main": "src",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@nestjs/
|
|
46
|
-
"@nestjs/
|
|
47
|
-
"@nestjs/
|
|
48
|
-
"@nestjs/
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"@
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
58
|
-
"@
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
},
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
"publishConfig": {
|
|
91
|
-
"access": "public"
|
|
92
|
-
},
|
|
93
|
-
"engines": {
|
|
94
|
-
"node": "^14"
|
|
95
|
-
}
|
|
96
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@merkaly/api",
|
|
3
|
+
"version": "0.1.9-1",
|
|
4
|
+
"description": "NestJS Backend ApiRest Service",
|
|
5
|
+
"author": "Randy Tellez Galan <kronhyx@gmail.com>",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"main": "src",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"prebuild": "yarn run clean",
|
|
10
|
+
"prepack": "yarn build",
|
|
11
|
+
"build": "nest build",
|
|
12
|
+
"clean": "tsc -b --clean",
|
|
13
|
+
"start": "nest start --preserveWatchOutput",
|
|
14
|
+
"dev": "yarn run clean && npm start -- --watch",
|
|
15
|
+
"start:debug": "yarn dev -- --debug ",
|
|
16
|
+
"start:prod": "node dist/index.js",
|
|
17
|
+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" . ",
|
|
18
|
+
"test": "jest",
|
|
19
|
+
"test:watch": "yarn test -- --watch",
|
|
20
|
+
"test:cov": "yarn test -- --coverage",
|
|
21
|
+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
22
|
+
"semantic-release": "yarn run build:package && semantic-release"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@nestjs/axios": "^0.0.5",
|
|
26
|
+
"@nestjs/swagger": "^5.0.9",
|
|
27
|
+
"@types/auth0": "^2.33.4",
|
|
28
|
+
"@types/node": "^17.0.2",
|
|
29
|
+
"auth0": "^2.35.0",
|
|
30
|
+
"class-transformer": "^0.5.1",
|
|
31
|
+
"class-validator": "^0.13.1",
|
|
32
|
+
"fireorm": "^0.23.0",
|
|
33
|
+
"reflect-metadata": "^0.1.13"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@commitlint/config-conventional": "^16.0.0",
|
|
37
|
+
"@elastic/elasticsearch": "^7.13.0",
|
|
38
|
+
"@nestjs/cli": "8.2.0",
|
|
39
|
+
"@nestjs/common": "8.2.6",
|
|
40
|
+
"@nestjs/config": "^1.0.0",
|
|
41
|
+
"@nestjs/core": "8.2.6",
|
|
42
|
+
"@nestjs/elasticsearch": "8.0.0",
|
|
43
|
+
"@nestjs/event-emitter": "^1.0.0",
|
|
44
|
+
"@nestjs/jwt": "8.0.0",
|
|
45
|
+
"@nestjs/passport": "8.1.0",
|
|
46
|
+
"@nestjs/platform-express": "8.2.6",
|
|
47
|
+
"@nestjs/schematics": "8.0.5",
|
|
48
|
+
"@nestjs/testing": "8.2.6",
|
|
49
|
+
"@semantic-release/exec": "^6.0.1",
|
|
50
|
+
"@semantic-release/git": "^10.0.0",
|
|
51
|
+
"@types/express": "^4.17.12",
|
|
52
|
+
"@types/faker": "^5.5.9",
|
|
53
|
+
"@types/jest": "^27.0.0",
|
|
54
|
+
"@types/multer": "^1.4.7",
|
|
55
|
+
"@types/passport-jwt": "^3.0.5",
|
|
56
|
+
"@types/supertest": "^2.0.11",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "4.33.0",
|
|
58
|
+
"@typescript-eslint/parser": "4.33.0",
|
|
59
|
+
"commitlint": "^16.1.0",
|
|
60
|
+
"eslint": "7.32.0",
|
|
61
|
+
"eslint-plugin-import": "^2.23.4",
|
|
62
|
+
"faker": "^5.5.3",
|
|
63
|
+
"firebase": "^9.0.0",
|
|
64
|
+
"firebase-admin": "^10.0.2",
|
|
65
|
+
"husky": "^7.0.0",
|
|
66
|
+
"jest": "27.4.7",
|
|
67
|
+
"passport": "^0.4.1",
|
|
68
|
+
"passport-jwt": "^4.0.0",
|
|
69
|
+
"rimraf": "^3.0.2",
|
|
70
|
+
"rxjs": "^7.2.0",
|
|
71
|
+
"semantic-release": "^18.0.0",
|
|
72
|
+
"supertest": "^6.1.3",
|
|
73
|
+
"swagger-ui-express": "^4.1.5",
|
|
74
|
+
"ts-jest": "27.1.3",
|
|
75
|
+
"ts-loader": "^9.2.3",
|
|
76
|
+
"ts-node": "^10.0.0",
|
|
77
|
+
"tsconfig-paths": "^3.9.0"
|
|
78
|
+
},
|
|
79
|
+
"repository": {
|
|
80
|
+
"type": "git",
|
|
81
|
+
"url": "https://github.com/sk-merkaly/api.git"
|
|
82
|
+
},
|
|
83
|
+
"publishConfig": {
|
|
84
|
+
"access": "public"
|
|
85
|
+
},
|
|
86
|
+
"engines": {
|
|
87
|
+
"node": "^14"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Module, ModuleMetadata } from '@nestjs/common'
|
|
2
|
+
import OrganizationModule from './organizations/organization.module'
|
|
3
|
+
import RoleModule from './roles/role.module'
|
|
4
|
+
import UserModule from './users/user.module'
|
|
5
|
+
|
|
6
|
+
export const metadata: ModuleMetadata = {
|
|
7
|
+
imports: [UserModule, OrganizationModule, RoleModule],
|
|
8
|
+
controllers: [],
|
|
9
|
+
providers: [],
|
|
10
|
+
exports: []
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@Module(metadata)
|
|
14
|
+
export default class AccountModule {
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TokenResponse, User as Auth0User } from 'auth0';
|
|
2
|
+
import UserRepository from '../users/user.repository';
|
|
3
|
+
import AuthRepository from './auth.repository';
|
|
4
|
+
import { LoginValidator } from './auth.validator';
|
|
5
|
+
export default class AuthController {
|
|
6
|
+
protected readonly authRepository: AuthRepository;
|
|
7
|
+
protected readonly userRepository: UserRepository;
|
|
8
|
+
login({ username, password }: LoginValidator): Promise<Partial<TokenResponse>>;
|
|
9
|
+
user(user: string): Promise<Auth0User>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Body, Controller, Get, HttpException, Inject, Post } from '@nestjs/common'
|
|
2
|
+
import { ApiTags } from '@nestjs/swagger'
|
|
3
|
+
import { PasswordGrantOptions, TokenResponse, User as Auth0User } from 'auth0'
|
|
4
|
+
import UserRepository from '../users/user.repository'
|
|
5
|
+
import { Public, User } from './auth.decorator'
|
|
6
|
+
import AuthRepository from './auth.repository'
|
|
7
|
+
import { LoginValidator } from './auth.validator'
|
|
8
|
+
|
|
9
|
+
@Controller()
|
|
10
|
+
@ApiTags(AuthController.name)
|
|
11
|
+
export default class AuthController {
|
|
12
|
+
@Inject() protected readonly authRepository: AuthRepository
|
|
13
|
+
@Inject() protected readonly userRepository: UserRepository
|
|
14
|
+
|
|
15
|
+
@Public()
|
|
16
|
+
@Post('/login')
|
|
17
|
+
async login (@Body() { username, password }: LoginValidator): Promise<Partial<TokenResponse>> {
|
|
18
|
+
const options: PasswordGrantOptions = {
|
|
19
|
+
username,
|
|
20
|
+
password,
|
|
21
|
+
scope: 'openid'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return this.authRepository.client.passwordGrant(options)
|
|
25
|
+
.then(({ access_token, refresh_token, expires_in }) => ({ access_token, refresh_token, expires_in }))
|
|
26
|
+
.catch(({ message, statusCode, originalError }) => {
|
|
27
|
+
const description = originalError.response.res.statusMessage
|
|
28
|
+
|
|
29
|
+
throw new HttpException({ ...JSON.parse(message), message: description }, statusCode)
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Get('/user')
|
|
34
|
+
async user (@User() user: string): Promise<Auth0User> {
|
|
35
|
+
return this.userRepository.read(user)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createParamDecorator, CustomDecorator, ExecutionContext, SetMetadata } from '@nestjs/common'
|
|
2
|
+
|
|
3
|
+
export const IS_PUBLIC_KEY = 'isPublic'
|
|
4
|
+
export const Public: () => CustomDecorator = () => SetMetadata(IS_PUBLIC_KEY, true)
|
|
5
|
+
|
|
6
|
+
export const User = createParamDecorator((data: unknown, ctx: ExecutionContext): string => {
|
|
7
|
+
const request = ctx.switchToHttp().getRequest()
|
|
8
|
+
|
|
9
|
+
return request.user
|
|
10
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import AuthRepository from './auth.repository';
|
|
3
|
+
declare module 'express' {
|
|
4
|
+
interface Request {
|
|
5
|
+
user?: string;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
declare const AuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
9
|
+
export default class AuthGuard extends AuthGuard_base {
|
|
10
|
+
protected readonly authRepository: AuthRepository;
|
|
11
|
+
private reflector;
|
|
12
|
+
canActivate(context: ExecutionContext): Promise<any>;
|
|
13
|
+
handleRequest(err: Record<string, unknown>, user: string): any;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ExecutionContext, Inject, Injectable, UnauthorizedException } from '@nestjs/common'
|
|
2
|
+
import { Reflector } from '@nestjs/core'
|
|
3
|
+
import { AuthGuard as JwtGuard } from '@nestjs/passport'
|
|
4
|
+
import { IS_PUBLIC_KEY } from './auth.decorator'
|
|
5
|
+
import AuthRepository from './auth.repository'
|
|
6
|
+
|
|
7
|
+
declare module 'express' {
|
|
8
|
+
interface Request {
|
|
9
|
+
user?: string
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@Injectable()
|
|
14
|
+
export default class AuthGuard extends JwtGuard('jwt') {
|
|
15
|
+
|
|
16
|
+
@Inject() protected readonly authRepository: AuthRepository
|
|
17
|
+
@Inject() private reflector: Reflector
|
|
18
|
+
|
|
19
|
+
async canActivate (context: ExecutionContext): Promise<any> {
|
|
20
|
+
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
|
|
21
|
+
context.getHandler(),
|
|
22
|
+
context.getClass()
|
|
23
|
+
])
|
|
24
|
+
|
|
25
|
+
if (isPublic) {
|
|
26
|
+
return true
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return super.canActivate(context)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
handleRequest (err: Record<string, unknown>, user: string): any {
|
|
33
|
+
|
|
34
|
+
if (err || !user) {
|
|
35
|
+
throw err || new UnauthorizedException()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return user
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Global, Module, ModuleMetadata } from '@nestjs/common'
|
|
2
|
+
import { ElasticsearchModule } from '@nestjs/elasticsearch'
|
|
3
|
+
import { JwtModule } from '@nestjs/jwt'
|
|
4
|
+
import { PassportModule } from '@nestjs/passport'
|
|
5
|
+
import AppConfig from '../../app.config'
|
|
6
|
+
import UserRepository from '../users/user.repository'
|
|
7
|
+
import AuthController from './auth.controller'
|
|
8
|
+
import AuthGuard from './auth.guard'
|
|
9
|
+
import AuthRepository from './auth.repository'
|
|
10
|
+
import AuthStrategy from './auth.strategy'
|
|
11
|
+
|
|
12
|
+
export const metadata: ModuleMetadata = {
|
|
13
|
+
imports: [
|
|
14
|
+
PassportModule.register({ session: true }),
|
|
15
|
+
JwtModule.register({ signOptions: { expiresIn: '60m' } }),
|
|
16
|
+
ElasticsearchModule.register(AppConfig.elasticsearch)
|
|
17
|
+
],
|
|
18
|
+
controllers: [AuthController],
|
|
19
|
+
providers: [AuthRepository, AuthStrategy, AuthRepository, AuthGuard, UserRepository],
|
|
20
|
+
exports: [AuthRepository, ElasticsearchModule]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Global()
|
|
24
|
+
@Module(metadata)
|
|
25
|
+
export default class AuthModule {
|
|
26
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Inject, Injectable } from '@nestjs/common'
|
|
2
|
+
import { JwtService } from '@nestjs/jwt'
|
|
3
|
+
import { AuthenticationClient, ClientCredentialsGrantOptions, ManagementClient } from 'auth0'
|
|
4
|
+
import axios from 'axios'
|
|
5
|
+
import AppConfig from '../../app.config'
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export default class AuthRepository {
|
|
9
|
+
@Inject() private jwtService: JwtService
|
|
10
|
+
|
|
11
|
+
get client (): AuthenticationClient {
|
|
12
|
+
return new AuthenticationClient({
|
|
13
|
+
domain: AppConfig.auth0.domain,
|
|
14
|
+
clientId: AppConfig.auth0.client,
|
|
15
|
+
clientSecret: AppConfig.auth0.secret
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
$management (): Promise<ManagementClient> {
|
|
20
|
+
const options: ClientCredentialsGrantOptions = {
|
|
21
|
+
audience: AppConfig.auth0.audience
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return this.client.clientCredentialsGrant(options)
|
|
25
|
+
.then(({ access_token }) => {
|
|
26
|
+
axios.defaults.baseURL = AppConfig.auth0.audience.replace(/^\/|\/$/g, '')
|
|
27
|
+
axios.defaults.headers['authorization'] = `Bearer ${access_token}`
|
|
28
|
+
|
|
29
|
+
const options = {
|
|
30
|
+
domain: AppConfig.auth0.domain,
|
|
31
|
+
clientId: AppConfig.auth0.client,
|
|
32
|
+
clientSecret: AppConfig.auth0.secret,
|
|
33
|
+
token: access_token
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return new ManagementClient(options)
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Strategy, StrategyOptions } from 'passport-jwt';
|
|
2
|
+
export declare const strategy: StrategyOptions;
|
|
3
|
+
interface DecodedUser {
|
|
4
|
+
iss: string;
|
|
5
|
+
sub: string;
|
|
6
|
+
aud: string[];
|
|
7
|
+
iat: number;
|
|
8
|
+
exp: number;
|
|
9
|
+
azp: string;
|
|
10
|
+
scope: string;
|
|
11
|
+
}
|
|
12
|
+
declare const AuthStrategy_base: new (...args: any[]) => Strategy;
|
|
13
|
+
export default class AuthStrategy extends AuthStrategy_base {
|
|
14
|
+
constructor();
|
|
15
|
+
validate({ sub }: DecodedUser): string;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common'
|
|
2
|
+
import { PassportStrategy } from '@nestjs/passport'
|
|
3
|
+
import { readFileSync } from 'fs'
|
|
4
|
+
import { ExtractJwt, Strategy, StrategyOptions } from 'passport-jwt'
|
|
5
|
+
|
|
6
|
+
export const strategy: StrategyOptions = {
|
|
7
|
+
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
8
|
+
ignoreExpiration: false,
|
|
9
|
+
secretOrKey: process.env.AUTH_CERTIFICATE || readFileSync('authCertificate.pem')
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface DecodedUser {
|
|
13
|
+
iss: string,
|
|
14
|
+
sub: string,
|
|
15
|
+
aud: string[],
|
|
16
|
+
iat: number,
|
|
17
|
+
exp: number,
|
|
18
|
+
azp: string,
|
|
19
|
+
scope: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Injectable()
|
|
23
|
+
export default class AuthStrategy extends PassportStrategy(Strategy) {
|
|
24
|
+
constructor () {
|
|
25
|
+
super(strategy)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
validate ({ sub }: DecodedUser): string {
|
|
29
|
+
return sub
|
|
30
|
+
}
|
|
31
|
+
}
|