Skip to content

Commit 8f5050f

Browse files
committed
cap07-12-boas-praticas-na-correcao-das-vulnerabilidades
1 parent da795b5 commit 8f5050f

40 files changed

Lines changed: 19373 additions & 0 deletions

src/scout/Dockerfile

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
FROM node:24.8.0-slim AS ci
2+
3+
# baseado no quanto as instruções podem mudar
4+
# instruções que não mudam ou pouco mudam devem ficar no topo
5+
# ENV, ARG, RUN apt update, apt install
6+
7+
RUN apt update && apt install -y \
8+
git \
9+
curl && \
10+
rm -rf /var/lib/apt/lists/*
11+
12+
# deterministicas e não deterministicas
13+
14+
#RUN echo "hello world" > test.txt
15+
16+
# ARG BUILD_TIMESTAMP
17+
# RUN echo "$BUILD_TIMESTAMP" > /build_time.txt
18+
19+
# add vs copy
20+
21+
#ADD --checksum=sha256:278888 http://ftp.de.debian.org/debian/pool/main/c/curl/curl_7.88.1-10+deb12u12_amd64.deb /tmp/curl.deb
22+
# RUN script.sh
23+
# gzip, bzip2 or xz
24+
ADD curl-8.15.0.tar.gz /tmp/test
25+
26+
27+
USER node
28+
29+
RUN mkdir /home/node/app
30+
31+
WORKDIR /home/node/app
32+
33+
RUN --mount=type=bind,source=package.json,target=package.json \
34+
--mount=type=bind,source=package-lock.json,target=package-lock.json \
35+
--mount=type=cache,target=/home/node/.npm,uid=1000,gid=1000,id=npm-cache \
36+
npm ci
37+
38+
COPY --chown=node:node . .
39+
40+
CMD [ "tail", "-f", "/dev/null" ]
41+
42+
FROM node:24.8.0-slim AS builder
43+
44+
ENV NODE_ENV=production
45+
46+
USER node
47+
48+
RUN mkdir /home/node/app
49+
50+
WORKDIR /home/node/app
51+
52+
COPY --from=ci --chown=node:node /home/node/app .
53+
RUN npm run build
54+
55+
RUN --mount=type=cache,target=/home/node/.npm,uid=1000,gid=1000,id=npm-cache \
56+
npm ci --only=production
57+
58+
FROM node:24.8.0-slim AS production
59+
60+
ENV NODE_ENV=production
61+
62+
USER node
63+
64+
RUN mkdir /home/node/app
65+
66+
WORKDIR /home/node/app
67+
68+
COPY --chown=node:node --from=builder /home/node/app/dist ./dist
69+
COPY --chown=node:node --from=builder /home/node/app/node_modules ./node_modules
70+
COPY --chown=node:node --from=builder /home/node/app/package.json ./
71+
72+
EXPOSE 3000
73+
74+
CMD [ "node", "dist/main.js" ]

src/scout/docker-bake.hcl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
group "default" {
2+
targets = [ "nestjs-prod" ]
3+
}
4+
5+
target "nestjs-prod" {
6+
context = "./nestjs-project-insecure"
7+
dockerfile = "../Dockerfile"
8+
tags = ["nestjs:latest"]
9+
}
10+
11+
target "nestjs-ci" {
12+
context = "./nestjs-project-insecure"
13+
dockerfile = "../Dockerfile"
14+
tags = ["nestjs:ci"]
15+
target = "ci"
16+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
project: 'tsconfig.json',
5+
tsconfigRootDir : __dirname,
6+
sourceType: 'module',
7+
},
8+
plugins: ['@typescript-eslint/eslint-plugin'],
9+
extends: [
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:prettier/recommended',
12+
],
13+
root: true,
14+
env: {
15+
node: true,
16+
jest: true,
17+
},
18+
ignorePatterns: ['.eslintrc.js'],
19+
rules: {
20+
'@typescript-eslint/interface-name-prefix': 'off',
21+
'@typescript-eslint/explicit-function-return-type': 'off',
22+
'@typescript-eslint/explicit-module-boundary-types': 'off',
23+
'@typescript-eslint/no-explicit-any': 'off',
24+
},
25+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# compiled output
2+
/dist
3+
/node_modules
4+
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
pnpm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
lerna-debug.log*
13+
14+
# OS
15+
.DS_Store
16+
17+
# Tests
18+
/coverage
19+
/.nyc_output
20+
21+
# IDEs and editors
22+
/.idea
23+
.project
24+
.classpath
25+
.c9/
26+
*.launch
27+
.settings/
28+
*.sublime-workspace
29+
30+
# IDE - VSCode
31+
.vscode/*
32+
!.vscode/settings.json
33+
!.vscode/tasks.json
34+
!.vscode/launch.json
35+
!.vscode/extensions.json
36+
37+
.history/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}
249 KB
Loading
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
![Imersão Full Stack && Full Cycle](https://events-fullcycle.s3.amazonaws.com/events-fullcycle/static/site/img/grupo_4417.png)
2+
3+
Participe gratuitamente: https://imersao.fullcycle.com.br/
4+
5+
## Sobre o repositório
6+
Esse repositório contém o código-fonte ministrado na aula Nest.js com Domain Driven Design (DDD): [https://www.youtube.com/watch?v=XTmvAj5OSQI](https://www.youtube.com/watch?v=XTmvAj5OSQI)
7+
8+
## Rodar a aplicação
9+
10+
Execute os comandos:
11+
12+
```bash
13+
npm install
14+
npm run start:dev
15+
```
16+
17+
Acesse http://localhost:3000/bank-accounts ou use o arquivo `api.http` para testar a API usando a extensão Rest Client do VSCode ou outra ferramenta para brincar com o HTTP.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
GET http://localhost:3000/bank-accounts
2+
3+
###
4+
GET http://localhost:3000/bank-accounts/ce669d21-4fa4-47bb-8918-e657b809910a
5+
6+
###
7+
POST http://localhost:3000/bank-accounts
8+
Content-Type: application/json
9+
10+
{
11+
"account_number": "5555-55"
12+
}
13+
14+
###
15+
PATCH http://localhost:3000/bank-accounts/123
16+
Content-Type: application/json
17+
18+
{
19+
"account_number": 1234
20+
}
21+
22+
###
23+
DELETE http://localhost:3000/bank-accounts/123
24+
25+
###
26+
POST http://localhost:3000/bank-accounts/transfer
27+
Content-Type: application/json
28+
29+
{
30+
"from": "4444-44",
31+
"to": "5555-55",
32+
"amount": 100
33+
}

src/scout/nestjs-project-insecure/bank-accounts.sqlite

Whitespace-only changes.

0 commit comments

Comments
 (0)