Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
78a54d6
cria base para migração da estrutura
edvaldoszy May 27, 2026
349447f
melhora estrutura e nomenclatura das classes
edvaldoszy May 27, 2026
a9ede73
cria classe única para a aplicação, cria classe Kernel que inicia a a…
edvaldoszy Jun 4, 2026
5d0a789
cria testes de integração
edvaldoszy Jun 8, 2026
1cac140
refatora estrutura para reuso nos testes de integração
edvaldoszy Jun 15, 2026
854688d
organize testes uniário e de integração
edvaldoszy Jun 15, 2026
c811486
executa testes de integração no pull request
edvaldoszy Jun 16, 2026
41b8c0f
corrige pre-push
edvaldoszy Jun 16, 2026
bdb51ae
corrige testes unitário
edvaldoszy Jun 16, 2026
80c3482
remove execução dos testes de integração do pull request por agora
edvaldoszy Jun 16, 2026
66bc536
corrige erros de lint
edvaldoszy Jun 16, 2026
75893f8
melhora execução dos testes e2e limpando a base de dados no início
edvaldoszy Jun 22, 2026
796f581
carrega arquivo .env usando node diretamente
edvaldoszy Jul 8, 2026
cb04db5
corrige rotas antigas e carregamento do arquivo .env
edvaldoszy Jul 8, 2026
a702d89
continue mesmo se os testes de integração falharem (por enquanto)
edvaldoszy Jul 8, 2026
dc13e23
renomeia e2e para integration
edvaldoszy Jul 8, 2026
11ee6ba
update yarn.lock
edvaldoszy Aug 6, 2026
2e9c781
ignore notes file
edvaldoszy Aug 7, 2026
2ea5ad1
corrige script de start
edvaldoszy Aug 8, 2026
7d7b190
corrige build, package a atualiza arquivo lock
edvaldoszy Aug 8, 2026
3ee1840
corrige entrypoint do docker
edvaldoszy Aug 8, 2026
988fe34
adiciona rota para checagem da api
edvaldoszy Aug 8, 2026
866646a
habilitar rota de assets
edvaldoszy Aug 8, 2026
2913905
corrige políticas de seguranças
edvaldoszy Aug 8, 2026
ce7e91d
atualiza README de testes, ignora logs da rota /health
edvaldoszy Aug 8, 2026
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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ TZ=UTC
PORT=3000
NODE_ENV=development

# Optional: CORS (used by Application). Comma-separated origins, or * for all.
CORS_ORIGINS=*
CORS_METHODS=HEAD,GET,POST,PUT,PATCH,DELETE
CORS_ALLOWED_HEADERS=Content-Type,Authorization

STORAGE_PATH=./uploads

MYSQL_DATABASE=herbario_dev
Expand Down
47 changes: 44 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Run checks
run: yarn lint

test:
unit-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -29,8 +29,8 @@ jobs:
node-version: 'lts/jod'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run tests with coverage
run: yarn test --silent --coverage
- name: Run unit tests with coverage
run: yarn test:coverage
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
Expand All @@ -39,6 +39,47 @@ jobs:
retention-days: 7
overwrite: true

integration-test:
runs-on: ubuntu-latest
continue-on-error: true
env:
PG_HOST: localhost
PG_PORT: 5432
PG_DATABASE: herbario_test
PG_USERNAME: postgres
PG_PASSWORD: testpassword
PG_MIGRATION_USERNAME: postgres
PG_MIGRATION_PASSWORD: testpassword
services:
postgres:
image: postgis/postgis:18-3.6
env:
POSTGRES_DB: herbario_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: testpassword
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup environment
uses: actions/setup-node@v4
with:
node-version: 'lts/jod'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Apply base schema
run: psql -h $PG_HOST -p $PG_PORT -U $PG_MIGRATION_USERNAME -d $PG_DATABASE -f test/integration/setup/schema.sql
env:
PGPASSWORD: ${{ env.PG_MIGRATION_PASSWORD }}
- name: Run integration tests
run: yarn test:integration

build:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ reports/data/settings

*.log
npm-debug.log

NOTES.md
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm run test --silent
npm run test:unit -- --silent
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,9 @@ USER hcf_api

EXPOSE $PORT

CMD node dist/index.js
HEALTHCHECK \
--interval=30s --timeout=5s \
--start-period=40s --retries=3 \
CMD wget -qO- http://127.0.0.1:$PORT/health || exit 1

CMD node dist/application/index.js
32 changes: 16 additions & 16 deletions build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ rmSync('dist', { recursive: true, force: true })
const assets = globSync('src/**/*.{ejs,html,ttf,css}')

await build({
entryPoints: [
...assets,
'src/index.js',
],
outdir: 'dist',
bundle: true,
minify: true,
platform: 'node',
target: 'node20',
packages: 'external',
loader: {
'.ejs': 'copy',
'.html': 'copy',
'.ttf': 'copy',
'.css': 'copy',
}
entryPoints: [
...assets,
'src/application/index.js',
],
outdir: 'dist',
bundle: true,
minify: true,
platform: 'node',
target: 'node20',
packages: 'external',
loader: {
'.ejs': 'copy',
'.html': 'copy',
'.ttf': 'copy',
'.css': 'copy',
}
})
14 changes: 14 additions & 0 deletions compose.integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
postgres:
image: postgis/postgis:18-3.6
container_name: herbario_postgresql_e2e
environment:
POSTGRES_DB: herbario_e2e
POSTGRES_USER: postgres
POSTGRES_PASSWORD: testpassword
ports:
- "5433:5432"
volumes:
- ./test/integration/setup/schema.sql:/docker-entrypoint-initdb.d/schema.sql:ro
tmpfs:
- /var/lib/postgresql
16 changes: 16 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,22 @@ export default defineConfig([
'@stylistic/object-property-newline': [
'error',
{ allowAllPropertiesOnSameLine: true }
],
'@stylistic/operator-linebreak': [
'warn',
'before',
{ overrides: { '=': 'after' } }
],
'@stylistic/quote-props': [
'error',
'as-needed'
],
'no-restricted-syntax': [
'warn',
{
message: 'Use EnumOf pattern instead of TypeScript enums.',
selector: 'TSEnumDeclaration'
}
]
}
},
Expand Down
18 changes: 13 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "hcf-api",
"version": "0.1.1",
"description": "Projeto para construção da API para o sistema do Herbário da UTFPR",
"main": "dist/app/index.js",
"main": "dist/application/index.js",
"author": "Elaine Sangali <e.nani@gmail.com>",
"license": "MIT",
"private": true,
Expand All @@ -15,10 +15,14 @@
"tsc:check": "tsc --noEmit",
"lint:eslint": "eslint --cache",
"lint": "run-p tsc:check lint:eslint",
"start": "tsx --watch --env-file=.env src/index.js",
"start": "tsx --watch --env-file=.env src/application/index.js",
"build": "node build.mjs",
"test": "vitest --run",
"test:coverage": "vitest --run --coverage",
"test:unit": "vitest --run --project unit",
"test:unit:watch": "vitest --project unit",
"test:integration": "vitest --run --project integration",
"test:integration:watch": "vitest --project integration",
"test:coverage": "vitest --run --project unit --coverage",
"prepare": "husky",
"audit": "npm audit --audit-level=moderate",
"audit:fix": "npm audit fix"
Expand Down Expand Up @@ -62,10 +66,14 @@
"devDependencies": {
"@eslint/js": "9.39.1",
"@stylistic/eslint-plugin": "5.5.0",
"@types/cors": "2.8.19",
"@types/express": "5.0.5",
"@types/morgan": "1.9.10",
"@types/pg": "^8.16.0",
"@types/react": "19.2.2",
"@types/react-dom": "19.2.2",
"@types/supertest": "7.2.0",
"@types/swagger-ui-express": "^4.1.8",
"@vitest/coverage-v8": "4.0.7",
"chai": "6.2.0",
"chai-http": "^5.1.2",
Expand All @@ -77,9 +85,9 @@
"husky": "9.1.7",
"npm-run-all": "4.1.5",
"tsx": "4.21.0",
"supertest": "7.2.2",
"typescript": "5.9.3",
"typescript-eslint": "8.46.3",
"vitest": "4.0.7"
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
}
102 changes: 0 additions & 102 deletions src/app.js

This file was deleted.

Loading
Loading