Skip to content

Commit 1387d1c

Browse files
authored
Merge pull request #90 from RyanCNP/fix/some-fixes
feat: refatorar configuração do banco de dados, ajustar tipos de dados e remover serviço não utilizado
2 parents e94675d + 0ba3b6f commit 1387d1c

8 files changed

Lines changed: 20 additions & 42 deletions

app.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
2-
31
import express from "express";
42
import cors from "cors";
53
import path from "path";
6-
7-
84
import categoriaRoutes from "./src/routes/categoria.routes";
95
import denunciaRoutes from "./src/routes/denuncia.routes";
106
import userRoutes from "./src/routes/user.routes";
@@ -21,11 +17,9 @@ import http from 'http'
2117
import { initSockets } from "./src/sockets";
2218
import bodyParser from "body-parser";
2319
import stripeRoutes from "./src/routes/stripe.routes";
24-
export const app = express();
2520
import RegistroRoutes from './src/routes/registro.routes';
2621
import VisitasRoutes from './src/routes/visita.routes';
27-
import { setupSwagger } from "./src/swagger/swagger";
28-
import { errorHandler } from "./src/middlewares/errorHandler.middleware";
22+
2923
const app = express();
3024

3125
app.use(cors());
@@ -55,7 +49,10 @@ app.use("/public", express.static(path.join(__dirname, "public")));
5549

5650
app.use(errorHandler);
5751

52+
const server = http.createServer(app);
53+
initSockets(server);
54+
5855
const PORT = process.env.PORT || 3000;
59-
app.listen(PORT, () => {
56+
server.listen(PORT, () => {
6057
console.log(`Backend do SaneaSP está rodando na porta ${PORT}`);
6158
});

migrations/20251028230755-create-table-registro.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
},
1919
tipo: {
2020
allowNull: false,
21-
type: DataTypes.INTEGER
21+
type: DataTypes.STRING(50)
2222
},
2323
statusAnterior: {
2424
allowNull: false,

migrations/20251106002405-create-table-funcionarios.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ module.exports = {
1919
onDelete: "CASCADE",
2020
},
2121
nivel: {
22-
allowNull: true,
23-
type: DataTypes.STRING(30),
22+
allowNull: false,
23+
type: DataTypes.STRING(30)
2424
},
2525
});
2626
},

migrations/20251120145923-alter-table-denuncia-status-endereco.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
async up (queryInterface, Sequelize) {
66
// Alterar status para string e default 'aberto'
77
await queryInterface.changeColumn('denuncia', 'status', {
8-
type: Sequelize.STRING(20),
8+
type: Sequelize.STRING(50),
99
allowNull: false,
1010
defaultValue: 'aberto'
1111
});

package-lock.json

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/models/denuncia.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ DenunciaModel.init(
4747
},
4848
status: {
4949
allowNull: false,
50-
type: DataTypes.INTEGER,
50+
type: DataTypes.STRING(50),
5151
field: "status"
5252
},
5353
cep: {

src/services/cidadao.service.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/services/denuncia.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ApiError } from "../errors/ApiError.error"
55
import { HttpCode } from "../enums/HttpCode.enum"
66
import ExcelJS from "exceljs";
77
import { Buffer } from "buffer";
8+
import { StatusDenuncia } from "../enums/statusDenuncia.enum"
89

910
const denunciaFindIncludes = [
1011
{
@@ -75,6 +76,7 @@ export const findUserComplaint = async (fkUsuario: number, filter ?: IFilterList
7576
const query: any = {
7677
where: {idUsuario: fkUsuario},
7778
include: denunciaFindIncludes,
79+
order : [['dataPublicacao', "DESC"]]
7880
}
7981
if (filter && filter.status) {
8082
query.where.status = { [Op.like]: `%${filter.status}%` }
@@ -121,7 +123,7 @@ export const createNewDenuncia = async (body: ICreateDenuncia): Promise<IDenunci
121123
const { pontuacao, ...denunciaBodyWithoutPontuacao } = denunciaBody
122124

123125
const newDenuncia = {
124-
status: 0,
126+
status: StatusDenuncia.Aberto,
125127
dataPublicacao: new Date(),
126128
pontuacao: body.pontuacao,
127129
...denunciaBodyWithoutPontuacao,

0 commit comments

Comments
 (0)