Skip to content

Commit 8b21677

Browse files
committed
feat: auth roles
1 parent 8f834ee commit 8b21677

File tree

299 files changed

+66963
-337
lines changed

Some content is hidden

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

299 files changed

+66963
-337
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ Thumbs.db
4343
.env
4444

4545
.angular
46+
assets/server/**/*
47+
assets/client/**/*

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/.nx/cache
55
/.nx/workspace-data
66
.angular
7+
/diagrams

README.md

+20-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
```
2-
_
2+
_
33
__| | _____ ___ __ ___ __ __
44
/ _` |/ _ \ \ / / '_ ` _ \\ \/ /
5-
| (_| | __/\ V /| | | | | |> <
5+
| (_| | __/\ V /| | | | | |> <
66
\__,_|\___| \_/ |_| |_| |_/_/\_\
77
```
8-
# dev member experience
98

9+
# dev member experience
1010

1111
## Para executar em dev
1212

1313
### Requisitos
14+
1415
1. [pnpm](https://pnpm.io/installation) instalado
1516
1. [docker](https://docs.docker.com/engine/install) instalado
1617

@@ -48,26 +49,29 @@ pnpm dev
4849

4950
## Para commits
5051

52+
Os commits podem ser feitos em português, mas use inglês para termos técnicos, não tente traduzi-los quando eles são conhecidos e usados em inglês.
53+
5154
```sh
5255
pnpm cmt
5356
```
5457

5558
Responda as perguntas para fazer o commit.
5659

57-
5860
## Responsabilidades e relacionamentos
5961

60-
Trata-se de responsabilidade e relacionamentos, ou seja, qual a responsabilidade de cada camada e quais camadas podem depender diretamente uma das outras. Na tabela a seguir vemos que camadas do tipo `util` podem depender apenas de camadas que também sejam do tipo `util`, camadas do tipo `domain` podem depender apenas de camadas do tipo `util` e `api`, camadas do tipo `data-source` podem depender apenas dos tipos `util`, `domain` e `api`, e assim por diante...
62+
Trata-se de responsabilidade e relacionamentos, ou seja, qual a responsabilidade de cada camada e quais camadas podem depender diretamente uma das outras. Esta é uma convenção chamada [enforce module boundaries](https://nx.dev/features/enforce-module-boundaries#enforce-module-boundaries) e quem permite que as regras sejam aplicadas é o [nx](https://nx.dev).
63+
64+
A tabela a seguir representa a configuração no arquivo [`.eslintrc.json`](.eslintrc.json).
6165

62-
Caso tenha interesse em aprofundar neste assunto e descobrir os motivos, recomendo que leia um conteúdo que escrevi ano passado, você pode fazer download através do link a seguir. [Arquitetura em camadas, uma abordagem sobre responsabilidades e relacionamentos](https://conteudode.dev/pdf/nx)
66+
| | api | util | domain | data | ui | feature | resource | app |
67+
| ---------: | :-: | :--: | :----: | :--: | :-: | :-----: | :------: | :-: |
68+
| `api` || 𝗫 | 𝗫 | 𝗫 | 𝗫 | 𝗫 | 𝗫 | 𝗫 |
69+
| `util` ||| 𝗫 | 𝗫 | 𝗫 | 𝗫 | 𝗫 | 𝗫 |
70+
| `domain` |||| 𝗫 | 𝗫 | 𝗫 | 𝗫 | 𝗫 |
71+
| `data` ||||| 𝗫 | 𝗫 | 𝗫 | 𝗫 |
72+
| `ui` ||| 𝗫 | 𝗫 || 𝗫 | 𝗫 | 𝗫 |
73+
| `feature` ||| 𝗫 |||| 𝗫 | 𝗫 |
74+
| `resource` ||| 𝗫 || 𝗫 | 𝗫 || 𝗫 |
75+
| `app` ||| 𝗫 ||||| 𝗫 |
6376

64-
| | util | domain | data-source | data-access | resource | feature | app | api |
65-
| ------------: | :--: | :----: | :---------: | :---------: | :------: | :-----: | :-: | :-: |
66-
| `util` |||||||||
67-
| `domain` | 𝗫 | 𝗫 ||| 𝗫 | 𝗫 | 𝗫 ||
68-
| `data-source` | 𝗫 | 𝗫 | 𝗫 | 𝗫 || 𝗫 |||
69-
| `data-access` | 𝗫 | 𝗫 | 𝗫 | 𝗫 | 𝗫 ||||
70-
| `resource` | 𝗫 | 𝗫 | 𝗫 | 𝗫 || 𝗫 |||
71-
| `feature` | 𝗫 | 𝗫 | 𝗫 | 𝗫 | 𝗫 ||||
72-
| `app` | 𝗫 | 𝗫 | 𝗫 | 𝗫 | 𝗫 | 𝗫 | 𝗫 | 𝗫 |
73-
| `api` | 𝗫 ||||||||
77+
Caso tenha interesse em aprofundar neste assunto e descobrir os motivos, recomendo que leia um conteúdo que escrevi ano passado, você pode fazer download através do link [Arquitetura em camadas, uma abordagem sobre responsabilidades e relacionamentos](https://conteudode.dev/pdf/nx).

apps/devmx/public/figures/roles.png

17.7 KB
Loading

apps/devmx/public/figures/roles.svg

+846
Loading

apps/devmx/src/app/handlers/auth-error.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import { HttpErrorResponse } from '@angular/common/http';
2+
import { MessageService } from '@devmx/shared-ui-global';
23
import { ErrorHandler, inject } from '@angular/core';
34
import { Router } from '@angular/router';
45

56
export class AuthErrorHandler implements ErrorHandler {
67
router;
78

9+
messageService;
10+
811
constructor() {
912
this.router = inject(Router);
13+
14+
this.messageService = inject(MessageService);
15+
1016
onstorage = this.#onTokenChanged;
1117
}
1218

@@ -18,10 +24,19 @@ export class AuthErrorHandler implements ErrorHandler {
1824

1925
handleError(error: Error): void {
2026
if (error instanceof HttpErrorResponse) {
27+
const { message } = error.error;
28+
29+
this.showMessage(error.status, message);
30+
2131
if (error.status === 401) {
32+
this.router.navigateByUrl('/account/auth');
2233
localStorage.removeItem('accessToken');
23-
// this.router.navigateByUrl('/account/auth');
2434
}
2535
}
2636
}
37+
38+
showMessage(status: number, message: string) {
39+
const type = status >= 400 && status < 500 ? 'error' : 'warn';
40+
this.messageService.open({ message, type });
41+
}
2742
}

apps/devmx/src/scss/_m3-theme.scss

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
// This file was generated by running 'ng generate @angular/material:m3-theme'.
2+
// Proceed with caution if making changes to this file.
3+
4+
@use 'sass:map';
5+
@use '@angular/material' as mat;
6+
7+
// Note: Color palettes are generated from primary: #39B44D, secondary: #FCC500, tertiary: #6C11F3, neutral: #262626
8+
$_palettes: (
9+
primary: (
10+
0: #000000,
11+
10: #002105,
12+
20: #00390e,
13+
25: #004613,
14+
30: #005318,
15+
35: #00601d,
16+
40: #006e22,
17+
50: #008a2e,
18+
60: #27a641,
19+
70: #49c259,
20+
80: #66df72,
21+
90: #83fc8b,
22+
95: #c7ffc2,
23+
98: #ebffe5,
24+
99: #f6fff0,
25+
100: #ffffff,
26+
),
27+
secondary: (
28+
0: #000000,
29+
10: #241a00,
30+
20: #3e2e00,
31+
25: #4b3900,
32+
30: #594400,
33+
35: #674f00,
34+
40: #765b00,
35+
50: #947200,
36+
60: #b38b00,
37+
70: #d3a500,
38+
80: #f5bf00,
39+
90: #ffdf93,
40+
95: #ffefd0,
41+
98: #fff8f1,
42+
99: #fffbff,
43+
100: #ffffff,
44+
),
45+
tertiary: (
46+
0: #000000,
47+
10: #23005c,
48+
20: #3c0091,
49+
25: #4900ad,
50+
30: #5600c9,
51+
35: #6400e7,
52+
40: #711ff8,
53+
50: #8951ff,
54+
60: #a078ff,
55+
70: #b89bff,
56+
80: #d0bcff,
57+
90: #e9ddff,
58+
95: #f6edff,
59+
98: #fef7ff,
60+
99: #fffbff,
61+
100: #ffffff,
62+
),
63+
neutral: (
64+
0: #000000,
65+
4: #0b0b0b,
66+
6: #101111,
67+
10: #1b1c1c,
68+
12: #1f2020,
69+
17: #2a2a2a,
70+
20: #303030,
71+
22: #353434,
72+
24: #3a3939,
73+
25: #3c3b3b,
74+
30: #474746,
75+
35: #535252,
76+
40: #5f5e5e,
77+
50: #787776,
78+
60: #929090,
79+
70: #adabaa,
80+
80: #c8c6c5,
81+
87: #dcdad9,
82+
90: #e4e2e1,
83+
92: #eae8e7,
84+
94: #f0edec,
85+
95: #f3f0ef,
86+
96: #f6f3f2,
87+
98: #fcf9f8,
88+
99: #fffbfb,
89+
100: #ffffff,
90+
),
91+
neutral-variant: (
92+
0: #000000,
93+
10: #131e13,
94+
20: #283327,
95+
25: #333e31,
96+
30: #3e4a3c,
97+
35: #4a5647,
98+
40: #556253,
99+
50: #6e7b6b,
100+
60: #879484,
101+
70: #a2af9e,
102+
80: #bdcab8,
103+
90: #d9e6d4,
104+
95: #e7f5e1,
105+
98: #f0fdea,
106+
99: #f6fff0,
107+
100: #ffffff,
108+
),
109+
error: (
110+
0: #000000,
111+
10: #410002,
112+
20: #690005,
113+
25: #7e0007,
114+
30: #93000a,
115+
35: #a80710,
116+
40: #ba1a1a,
117+
50: #de3730,
118+
60: #ff5449,
119+
70: #ff897d,
120+
80: #ffb4ab,
121+
90: #ffdad6,
122+
95: #ffedea,
123+
98: #fff8f7,
124+
99: #fffbff,
125+
100: #ffffff,
126+
),
127+
);
128+
129+
$_rest: (
130+
secondary: map.get($_palettes, secondary),
131+
neutral: map.get($_palettes, neutral),
132+
neutral-variant: map.get($_palettes, neutral-variant),
133+
error: map.get($_palettes, error),
134+
);
135+
$_primary: map.merge(map.get($_palettes, primary), $_rest);
136+
$_secondary: map.merge(map.get($_palettes, secondary), $_rest);
137+
$_tertiary: map.merge(map.get($_palettes, tertiary), $_rest);
138+
139+
$green-palettte: $_primary;
140+
$yellow-palettte: $_secondary;
141+
$purple-palettte: $_tertiary;
142+
143+
// $light: mat.define-theme((
144+
// color: (
145+
// theme-type: light,
146+
// primary: $_primary,
147+
// tertiary: $_tertiary,
148+
// use-system-variables: true,
149+
// ),
150+
// // typography: (
151+
// // use-system-variables: true,
152+
// // ),
153+
// ));

apps/devmx/src/scss/_theme.scss

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// For more information: https://material.angular.io/guide/theming
22
@use '@angular/material' as mat;
3+
@use './m3-theme' as custom;
34
// Plus imports for other components in your app.
45

56
body {
@@ -16,8 +17,10 @@ $light: mat.define-theme(
1617
(
1718
color: (
1819
theme-type: light,
19-
primary: mat.$green-palette,
20-
tertiary: mat.$spring-green-palette,
20+
primary: custom.$green-palettte,
21+
tertiary: custom.$purple-palettte,
22+
// primary: mat.$green-palette,
23+
// tertiary: mat.$spring-green-palette,
2124
),
2225
density: (
2326
scale: 0,

apps/devmx/src/styles.scss

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
@use '@angular/cdk/overlay-prebuilt.css';
22
@use '@angular/material' as mat;
3+
// @use '/node_modules/@angular/material/core/theming/color-api-backwards-compatibility' as mat;
34
@use './scss/theme' as theme;
45
@use './scss/utils';
56

6-
77
// Include theme styles for core and each component used in your app.
88
// Alternatively, you can import and @include the theme mixins for each component
99
// that you are using.
@@ -13,10 +13,10 @@
1313

1414
// Comment out the line below if you want to use the pre-defined typography utility classes.
1515
// For more information: https://material.angular.io/guide/typography#using-typography-styles-in-your-application.
16-
// @include mat.typography-hierarchy($devmx-theme);
16+
// @include mat.typography-hierarchy(theme.$light);
1717

1818
// Comment out the line below if you want to use the deprecated `color` inputs.
19-
// @include mat.color-variants-backwards-compatibility($devmx-theme);
19+
// @include mat.color-variants-backwards-compatibility(theme.$light);
2020
/* You can add global styles to this file, and also import other style files */
2121

2222
html,
@@ -28,13 +28,17 @@ body {
2828
font-family: Roboto, 'Helvetica Neue', sans-serif;
2929
}
3030

31-
a:link,
32-
a:visited,
33-
a:active {
34-
color: rgb(7, 80, 224);
35-
text-decoration: none;
31+
body {
32+
a[href] {
33+
color: unset;
34+
text-decoration: none;
35+
}
3636

37-
&:hover {
38-
text-decoration: underline;
37+
.error-message {
38+
color: mat.get-theme-color(theme.$light, error, 50);
3939
}
4040
}
41+
42+
43+
@include mat.color-variants-backwards-compatibility(theme.$light);
44+
@include mat.typography-hierarchy(theme.$light);

apps/server/project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"defaultConfiguration": "development",
1111
"dependsOn": ["build"],
1212
"options": {
13-
"buildTarget": "server:build",
13+
"buildTarget": "server:build:development",
1414
"runBuildTargetDependencies": false
1515
},
1616
"configurations": {

apps/server/src/app.module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { SharedDatabaseModule, SharedResourceModule } from '@devmx/shared-resource';
22
import { PresentationResourceModule } from '@devmx/presentation-resource';
33
import { AccountResourceModule } from '@devmx/account-resource';
4+
import { ServeStaticModule } from '@nestjs/serve-static';
45
import { Module } from '@nestjs/common';
56
import { env } from './envs/env';
67

78
@Module({
89
imports: [
10+
ServeStaticModule.forRoot(env.static),
911
SharedResourceModule.forRoot(env),
1012
SharedDatabaseModule,
1113
AccountResourceModule,

apps/server/src/envs/env.dev.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { join } from 'node:path';
2+
3+
export const env = {
4+
production: false,
5+
db: {
6+
name: process.env.DB_NAME,
7+
host: process.env.DB_HOST,
8+
port: process.env.DB_PORT,
9+
user: process.env.DB_USER,
10+
pass: process.env.DB_PASS,
11+
},
12+
jwt: {
13+
secret: process.env.JWT_SECRET,
14+
},
15+
multer: {
16+
photos: {
17+
dest: 'assets/server/photos',
18+
},
19+
},
20+
static: {
21+
rootPath: join(__dirname, '..', '..', '..', 'assets', 'server'),
22+
}
23+
};

0 commit comments

Comments
 (0)