Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
52 changes: 44 additions & 8 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,55 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout code
uses: actions/checkout@v4
- name: Setup environment
uses: actions/setup-node@v4
with:
node-version: 'lts/jod'
- run: yarn install
- run: yarn lint
- name: Install dependencies
run: yarn install
- name: Run checks
run: yarn lint

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout code
uses: actions/checkout@v4
- name: Setup environment
uses: actions/setup-node@v4
with:
node-version: 'lts/jod'
- run: yarn install
- run: yarn test --silent test/**/*.test.ts
- name: Install dependencies
run: yarn install
- name: Run tests with coverage
run: yarn test --silent --coverage
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/
retention-days: 7
overwrite: true

security:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run scanner
uses: aquasecurity/trivy-action@0.28.0
with:
scan-type: filesystem
scan-ref: .
# trivy-config: trivy.yaml
hide-progress: true
exit-code: 0
- name: Archive scan results
uses: actions/upload-artifact@v4
with:
name: trivy-report
path: trivy-report.json
retention-days: 7
overwrite: true
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# generated
dist/
coverage/
node_modules/

uploads/
mysql/data/
node_modules/
reports/data/fs.journal
reports/data/fs.version
reports/data/profiles
Expand Down
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run test --silent
2 changes: 2 additions & 0 deletions eslint.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default defineConfig([
'dist/',
'mysql/',
'public/',
'coverage/',
'node_modules/'
]
},
Expand Down Expand Up @@ -159,6 +160,7 @@ export default defineConfig([
{
files: ['**/*.test.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off'
}
Expand Down
91 changes: 45 additions & 46 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,74 +19,73 @@
"build:app": "babel -d ./dist -x '.js,.ts,.tsx' --copy-files --no-copy-ignored ./src",
"start": "nodemon --ext 'js,ts,tsx' --exec babel-node --extensions '.js,.ts,.tsx' ./src/index.js",
"build": "run-s clean build:app",
"test": "jest",
"test": "vitest --run",
"test:coverage": "vitest --run --coverage",
"prepare": "husky",
"audit": "npm audit --audit-level=moderate",
"audit:fix": "npm audit fix"
},
"dependencies": {
"axios": "^1.10.0",
"bcrypt": "5.1.1",
"axios": "1.13.2",
"bcrypt": "6.0.0",
"body-parser": "2.2.0",
"commander": "13.1.0",
"commander": "14.0.2",
"cors": "2.8.5",
"date-fns": "4.1.0",
"dotenv": "16.3.1",
"dotenv": "17.2.3",
"ejs": "^2.6.1",
"express": "5.1.0",
"express-rate-limit": "^7.4.1",
"express-validator": "7.2.1",
"fast-csv": "^5.0.5",
"handlebars": "^4.7.8",
"helmet": "^8.0.0",
"express-rate-limit": "8.2.1",
"express-validator": "7.3.0",
"fast-csv": "5.0.5",
"helmet": "8.1.0",
"jsonwebtoken": "9.0.2",
"knex": "2.5.1",
"knex": "3.1.0",
"moment": "^2.24.0",
"moment-timezone": "^0.5.21",
"morgan": "1.10.0",
"multer": "1.4.5-lts.2",
"mysql2": "3.14.0",
"node-wkhtmltopdf": "^2.0.0",
"nodemailer": "^7.0.10",
"puppeteer": "24.6.0",
"q": "^1.5.1",
"react": "19.1.0",
"react-dom": "19.1.0",
"request": "^2.88.0",
"morgan": "1.10.1",
"multer": "2.0.2",
"mysql2": "3.15.3",
"nodemailer": "7.0.10",
"puppeteer": "24.28.0",
"q": "1.5.1",
"react": "19.2.0",
"react-dom": "19.2.0",
"request": "2.88.2",
"sequelize": "^4.38.0",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1",
"throttled-queue": "^1.0.5",
"tsx": "4.19.3",
"uuid": "11.1.0",
"wkhtmltopdf": "^0.4.0"
"swagger-jsdoc": "6.2.8",
"swagger-ui-express": "5.0.1",
"throttled-queue": "3.0.0",
"tsx": "4.20.6",
"uuid": "13.0.0"
},
"devDependencies": {
"@babel/cli": "7.27.0",
"@babel/core": "7.26.10",
"@babel/node": "7.26.0",
"@babel/cli": "7.28.3",
"@babel/core": "7.28.5",
"@babel/node": "7.28.0",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/preset-env": "7.22.10",
"@babel/preset-react": "7.26.3",
"@babel/preset-typescript": "7.22.15",
"@eslint/js": "9.38.0",
"@babel/preset-env": "7.28.5",
"@babel/preset-react": "7.28.5",
"@babel/preset-typescript": "7.28.5",
"@eslint/js": "9.39.1",
"@stylistic/eslint-plugin": "5.5.0",
"@types/express": "5.0.1",
"@types/jest": "30.0.0",
"@types/react": "19.1.0",
"@types/react-dom": "19.1.1",
"babel-plugin-module-resolver": "5.0.0",
"chai": "4.1.2",
"chai-http": "^4.0.0",
"eslint": "9.38.0",
"@types/express": "5.0.5",
"@types/react": "19.2.2",
"@types/react-dom": "19.2.2",
"@vitest/coverage-v8": "4.0.7",
"babel-plugin-module-resolver": "5.0.2",
"chai": "6.2.0",
"chai-http": "^5.1.2",
"eslint": "9.39.1",
"eslint-plugin-import-helpers": "2.0.1",
"globals": "16.4.0",
"globals": "16.5.0",
"husky": "9.1.7",
"jest": "29.7.0",
"jiti": "2.6.1",
"nodemon": "3.1.9",
"nodemon": "3.1.10",
"npm-run-all": "4.1.5",
"rimraf": "6.1.2",
"typescript": "5.9.3",
"typescript-eslint": "8.46.2"
"typescript-eslint": "8.46.3",
"vitest": "4.0.7"
}
}
18 changes: 9 additions & 9 deletions public/js/ficha-tombo.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
window.addEventListener('load', () => {
const svg = document.querySelector('[id^="code128_"]');
if (!svg) return;

if (typeof JsBarcode !== 'function') {
console.error('JsBarcode não carregado. Verifique o caminho do script e a CSP.');
return;
if (svg) {
if (typeof JsBarcode !== 'function') {
console.error('JsBarcode não carregado. Verifique o caminho do script e a CSP.');
return;
}
const attr = svg.getAttribute('data-codigo-barras');
const id = svg.id;
const cbarra = attr || '';
JsBarcode('#'.concat(id), cbarra, { margin: 0, width: 1.4, height: 40, fontSize: 10 });
}
const attr = svg.getAttribute('data-codigo-barras');
const id = svg.id;
const cbarra = attr || '';
JsBarcode('#'.concat(id), cbarra, { margin: 0, width: 1.4, height: 40, fontSize: 10 });


if (!/standalone/.test(window.location.href)) {
Expand Down
46 changes: 45 additions & 1 deletion src/controllers/cidades-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,49 @@ export const atualizarCidade = async (req, res, next) => {
}
};

export const listarCidadesEstados = async (req, res, next) => {
try {
const { nome, estado_id: estadoId } = req.query;

const where = {};

if (nome) {
where.nome = { [Op.like]: `%${nome}%` };
}

if (estadoId) {
where.estado_id = estadoId;
}

const cidades = await Cidade.findAll({
attributes: ['id', 'nome'],
where,
include: [
{
model: models.Estado,
as: 'estado',
attributes: ['id', 'nome', 'sigla'],
include: [
{
model: models.Pais,
as: 'pais',
attributes: ['id', 'nome', 'sigla'],
},
],
},
],
order: [
[sequelize.literal('LOWER(Cidade.nome)'), 'ASC'],
[sequelize.literal('LOWER(estado.nome)'), 'ASC'],
],
});

return res.status(200).json(cidades);
} catch (error) {
return next(error);
}
};

export const desativarCidade = async (req, res, next) => {
try {
const { cidadeId } = req.params;
Expand Down Expand Up @@ -139,9 +182,10 @@ export const listaTodosCidades = where =>
{
model: models.Estado,
as: 'estado',
attributes: ['id', 'nome', 'sigla', 'codigo_telefone', 'pais_id'],
attributes: ['id', 'nome', 'sigla', 'pais_id'],
},
],
order: [[sequelize.literal('LOWER(`cidades`.`nome`)'), 'ASC']],
});

export const listagem = (request, response, next) => {
Expand Down
33 changes: 15 additions & 18 deletions src/controllers/darwincore-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,24 @@ const obterModeloDarwinCoreLotes = async (limit, offset, request, response) => {
model: TomboFoto,
},
{
model: LocalColeta,
model: Cidade,
attributes: {
exclude: ['updated_at', 'created_at'],
},
include: [
{
model: Cidade,
attributes: {
exclude: ['updated_at', 'created_at'],
},
model: Estado,
include: [
{
model: Estado,
include: [
{
model: Pais,
},
],
model: Pais,
},
],
},
],
},
{
model: LocalColeta,
include: [
{
model: FaseSucessional,
attributes: {
Expand Down Expand Up @@ -206,13 +206,10 @@ const obterModeloDarwinCoreLotes = async (limit, offset, request, response) => {
let dataIdentificacao = '';
let identificationQualifier = '';
let nomeIdentificador = '';
const paisNome
= tombo.locais_coletum && tombo.locais_coletum.cidade ? tombo.locais_coletum.cidade.estado.paise.nome : '';
const paisCodigo
= tombo.locais_coletum && tombo.locais_coletum.cidade ? tombo.locais_coletum.cidade.estado.paise.sigla : '';
const paranaNome
= tombo.locais_coletum && tombo.locais_coletum.cidade ? tombo.locais_coletum.cidade.estado.nome : '';
const cidadeNome = tombo.locais_coletum && tombo.locais_coletum.cidade ? tombo.locais_coletum.cidade.nome : '';
const paisNome = tombo?.cidade?.estado?.paise?.nome ?? '';
const paisCodigo = tombo?.cidade?.estado?.paise?.sigla ?? '';
const paranaNome = tombo?.cidade?.estado?.nome ?? '';
const cidadeNome = tombo?.cidade?.nome ?? '';
const vegetacao
= tombo.locais_coletum && tombo.locais_coletum.vegetacao ? tombo.locais_coletum.vegetacao.nome : '';
const familiaNome = tombo.familia ? tombo.familia.nome : '';
Expand Down
Loading
Loading