Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.0.1 #94

Merged
merged 59 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
86768c9
feat(shelter-supply): add quantity property
jotahdavid May 10, 2024
b2550ee
feat(shelter-supply): show quantity property at query results
jotahdavid May 10, 2024
6a2694c
fix: removed unintended filter
MatheusDubin May 10, 2024
c117ab0
feat: improve readme file
filipepacheco May 10, 2024
7185fc8
feat: improve readme file
filipepacheco May 10, 2024
79f27fd
Bug fix: added verified field to the query
gustavocs May 10, 2024
4268e47
fix: verified was required on create shelter controller
kelvinsb May 10, 2024
dff6aad
feat: improve readme file
filipepacheco May 10, 2024
f61f86a
Fix linter issues
coelhotatiane May 10, 2024
3f787a5
feat(shelter-supply): set quantity to null if priority is UnderControl
jotahdavid May 10, 2024
e8bb18e
Implement some quality of life updates reg Docker
coelhotatiane May 10, 2024
d005c61
created lint:ci script
sombraSoft May 10, 2024
945296c
created CI job
sombraSoft May 10, 2024
317102a
fix linting in files
sombraSoft May 10, 2024
c887732
fixed ci job
sombraSoft May 10, 2024
18d631a
simplify ci job
sombraSoft May 10, 2024
cbf8971
fixed comment
sombraSoft May 10, 2024
36c7618
fixed lint script
sombraSoft May 10, 2024
8ac3e12
Merge branch 'develop' into feat/improve-readme-file
filipepacheco May 10, 2024
890b826
Merge pull request #29 from jotahdavid/feat/supply-quantity
AlbuquerqueRafael May 10, 2024
a88ed0a
Merge pull request #39 from SOS-RS/feat/improve-readme-file
filipepacheco May 10, 2024
8d050ac
Merge pull request #41 from coelhotatiane/quality-of-life-linter
AlbuquerqueRafael May 10, 2024
847252c
wip: search
fagundesjg May 10, 2024
520cdc5
refact: index search
fagundesjg May 10, 2024
ed08016
fix: fixed shelter OR and AND conditions
fagundesjg May 10, 2024
d9e6ed9
wip: donation tags
fagundesjg May 10, 2024
38c41ac
wip
fagundesjg May 10, 2024
0501b61
fix: parse tag response in shelter index
fagundesjg May 10, 2024
d0532d7
fix: qtd of shelter supplies tagged
fagundesjg May 10, 2024
794c7b8
fix: migration issue
fagundesjg May 10, 2024
2ccf427
wip
fagundesjg May 11, 2024
0248869
feat: update many supplies
fagundesjg May 11, 2024
caf62ea
wip
fagundesjg May 11, 2024
f2f112f
feat: created admin user role
fagundesjg May 11, 2024
cd27183
Fix/develop bugs (#54)
fagundesjg May 11, 2024
15a99b2
README.md 2.0 (#52)
4rthuurr May 11, 2024
057dde0
Add license (#50)
giggio May 11, 2024
0879745
Merge branch 'fix/develop-bugs' into develop
fagundesjg May 11, 2024
e4e9de2
Merge branch 'main' into develop
fagundesjg May 11, 2024
3732db7
docs: add templeate for PR
LeoFC97 May 11, 2024
dc37d79
Merge branch 'develop' into tooling/ci-improvement
sombraSoft May 11, 2024
18afdf7
rebase
sombraSoft May 11, 2024
cf2e38e
Merge pull request #42 from coelhotatiane/quality-of-life-docker
filipepacheco May 11, 2024
7abcf8e
Merge pull request #48 from sombraSoft/tooling/ci-improvement
filipepacheco May 11, 2024
b12e063
hotfix: Correção da Atualização Inconsistente de Prioridade em Shelte…
fagundesjg May 11, 2024
9f5fabc
feat: only show contact on shelter public routes on authorized roles
kelvinsb May 11, 2024
13d65ba
fix: remove unused and unauthorized contact field on list route
kelvinsb May 11, 2024
5d216b0
docs: improve readme file with discord link
RogerioPiatek May 12, 2024
8db01be
feat: return contact when user logged, instead of some Roles
kelvinsb May 12, 2024
ecdf8f4
fix: suggestions about separation
kelvinsb May 13, 2024
c9d0ec1
docs: updated to the link 'discord.gg/sosrs'
RogerioPiatek May 13, 2024
8ee010e
docs: changed discord link position
filipepacheco May 13, 2024
7a35052
Merge pull request #83 from RogerioPiatek/docs/improve-readme-file
filipepacheco May 13, 2024
873554c
Merge pull request #59 from LeoFC97/docs/add-pr-template
filipepacheco May 13, 2024
43561bf
Merge pull request #77 from kelvinsb/feat/hide-contact-for-unauthorized
filipepacheco May 13, 2024
9362f4c
Criação do endpoint para busca de cidades dos abrigos (#82)
AndersonCRocha May 13, 2024
b24a7b7
feat: add shelter filter by geolocation radius (#93)
AndersonCRocha May 14, 2024
5b2c052
Fixing discord link on Readme (#95)
filipepacheco May 14, 2024
94c5f57
Merge remote-tracking branch 'refs/remotes/origin/main' into release/…
filipepacheco May 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
pull_request:
branches:
- master
- develop

jobs:
build:
runs-on: ubuntu-latest

steps:
# Check out the source
- name: Checkout Source
uses: actions/checkout@v4
# Setup node.js and cache
- name: "Setup node.js"
uses: actions/setup-node@v4
with:
node-version: "18.x"
cache: 'npm'
cache-dependency-path: ./package-lock.json
# Install dependencies
- name: Install dependencies
run: npm ci
# Lint App
- name: Lint App
run: npm run lint:ci
# Build App
- name: Build App
run: npm run build
24 changes: 24 additions & 0 deletions .github/workflows/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
### 🔨 Tenho uma nova PR para vocês revisarem

- 🤔 O que foi feito?
> Digite aqui...


### 📗 Checklist do desenvolvedor

- [ ] Foi testado localmente?
- [ ] Foi adicionado documentação necessária (swagger, testes e etc)?

### 👀 Checklist do revisor

#### Revisor 1️⃣

- [ ] Você entendeu o propósito desse PR?
- [ ] Você entendeu o fluxo de negócio?
- [ ] Você entendeu o que e como foi desenvolvido tecnicamente a solução?
- [ ] Você analisou se os testes estão cobrindo a maioria dos casos?


### 🔗 Referênia

[Issue XX](https://github.com/SOS-RS/backend/issues/XX)
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM node:18.18 as node
FROM node:18.18-alpine as node

WORKDIR /usr/app

COPY package.json package-lock.json ./

RUN npm install
COPY . .
COPY . .
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# 🌊 Backend para App de Ajuda em Enchentes 🌊

Este repositório contém o backend de um aplicativo projetado para ajudar na organização e distribuição de suprimentos, bem como na coordenação de voluntários durante enchentes no Rio Grande do Sul. Ele fornece APIs essenciais para a autenticação de usuários, gerenciamento de abrigos e suprimentos, e muito mais.
Este repositório contém o backend de um aplicativo projetado para ajudar na organização e distribuição de suprimentos,
bem como na coordenação de voluntários durante enchentes no Rio Grande do Sul. Ele fornece APIs essenciais para a
autenticação de usuários, gerenciamento de abrigos e suprimentos, e muito mais.

Se você quiser discutir ideias, problemas ou contribuições, sinta-se à vontade para se juntar ao nosso servidor do
Discord [aqui](https://discord.gg/vjZS6BQXvM).

## 🛠 Tecnologias Utilizadas

Expand All @@ -12,7 +17,8 @@ Este repositório contém o backend de um aplicativo projetado para ajudar na or

## 🗂 Dump do Banco de Dados

Para iniciar com dados de exemplo, utilize o dump do banco disponível em `prisma/migration/dev_dump.sql`. Este arquivo pode ser executado após as migrations estarem aplicadas.
Para iniciar com dados de exemplo, utilize o dump do banco disponível em `prisma/migration/dev_dump.sql`. Este arquivo
pode ser executado após as migrations estarem aplicadas.

Se estiver usando Docker, os comandos para carregar o dump são:

Expand Down Expand Up @@ -96,6 +102,7 @@ ports:

## 🤝 Contribuição

Contribuições são muito bem-vindas! Se deseja ajudar, faça um fork do repositório, crie uma branch com suas modificações, e envie um pull request.
Contribuições são muito bem-vindas! Se deseja ajudar, faça um fork do repositório, crie uma branch com suas
modificações, e envie um pull request.

Sua ajuda é crucial para apoiar a comunidade afetada pelas enchentes no Rio Grande do Sul!
23 changes: 13 additions & 10 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,34 @@ version: '3.8'
services:
api:
container_name: sos-rs-api
image: node:18.18
image: node:18.18-alpine
restart: always
tty: true
depends_on:
- db
ports:
- '4000:4000'
- '${PORT}:${PORT}'
volumes:
- .:/usr/app
- /usr/app/node_modules
working_dir: '/usr/app'
environment:
- DB_HOST=sos-rs-db
- DB_PORT=5432
- DB_DATABASE_NAME=sos_rs
- DB_USER=root
- DB_PASSWORD=root
- DB_HOST=${DB_HOST}
- DB_PORT=${DB_PORT}
- DB_DATABASE_NAME=${DB_DATABASE_NAME}
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}
- PORT=${PORT}
command: >
sh -c "npm install &&
npx prisma generate &&
npx prisma migrate dev &&
npm run start:dev"
npm run start:dev -- --preserveWatchOutput"
db:
container_name: sos-rs-db
image: postgres
ports:
- '${DB_PORT}:${DB_PORT}'
environment:
- POSTGRES_PASSWORD=root
- POSTGRES_USER=root
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_USER=${DB_USER}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"lint:ci": "eslint \"{src,apps,libs,test}/**/*.ts\" --format=stylish",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
Expand Down
6 changes: 6 additions & 0 deletions prisma/migrations/20240512005246_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- AlterTable
ALTER TABLE "shelters" ADD COLUMN "city" TEXT,
ADD COLUMN "neighbourhood" TEXT,
ADD COLUMN "street" TEXT,
ADD COLUMN "street_number" TEXT,
ADD COLUMN "zip_code" TEXT;
5 changes: 5 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ model Shelter {
name String @unique
pix String? @unique
address String
street String?
neighbourhood String?
city String?
streetNumber String? @map("street_number")
zipCode String? @map("zip_code")
petFriendly Boolean? @map("pet_friendly")
shelteredPeople Int? @map("sheltered_people")
capacity Int?
Expand Down
8 changes: 8 additions & 0 deletions src/decorators/UserDecorator/user.decorator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createParamDecorator, ExecutionContext } from '@nestjs/common';

export const UserDecorator = createParamDecorator(
(data: unknown, ctx: ExecutionContext) => {
const request = ctx.switchToHttp().getRequest();
return request?.user;
},
);
10 changes: 10 additions & 0 deletions src/guards/apply-user.guard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Injectable } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';

@Injectable()
export class ApplyUser extends AuthGuard('jwt') {
handleRequest(err: any, user: any) {
if (user) return user;
return null;
}
}
38 changes: 25 additions & 13 deletions src/guards/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,34 @@ async function canActivate(context: ExecutionContext, allowed: AccessLevel[]) {
if (request.user) {
const { userId, sessionId } = request.user;

const session = await service.session.findUnique({
where: { id: sessionId, active: true, user: { id: userId } },
include: {
user: true,
},
});

if (
session &&
allowed.some((permission) => permission === session.user.accessLevel)
) {
return true;
}
return isRightSessionRole(allowed, sessionId, userId);
}

return false;
}

async function isRightSessionRole(
allowed: AccessLevel[],
sessionId?: string,
userId?: string,
) {
if (!sessionId) return false;
if (!userId) return false;

const session = await service.session.findUnique({
where: { id: sessionId, active: true, user: { id: userId } },
include: {
user: true,
},
});

if (
session &&
allowed.some((permission) => permission === session.user.accessLevel)
) {
return true;
}
return false;
}

export { canActivate };
Loading