Skip to content

Commit 2afac09

Browse files
committed
perf: Substitui textos fixos por constantes
1 parent 4f62e81 commit 2afac09

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/app/app.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import morganBody from 'morgan-body';
66
import Youch from 'youch';
77
import routes from './routes';
88
import authServices from './services/auth.services';
9+
import constantUtil from './utils/constant.util';
910

1011
const apiLimiter = rateLimit({
1112
windowMs: 1 * 60 * 1000, // 1 minutes
1213
max: 120,
1314
statusCode: 429,
14-
message: 'Limite de requisições ultrapassado, por favor, aguarde.',
15+
message: constantUtil.MsgStatus429,
1516
});
1617

1718
class App {
@@ -29,9 +30,7 @@ class App {
2930
process.env.NU_PORT
3031
);
3132
this.server.listen(this.port, () => {
32-
console.log(
33-
`API listening on ${process.env.NU_PORT}\nSwagger link: ${process.env.SWAGGER_URL}`
34-
);
33+
console.log(constantUtil.MsgStartAPI);
3534
});
3635
}
3736

src/app/controllers/product.controller.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import constantUtil from '../utils/constant.util';
2+
13
const jsonProducts = {
24
products: [
35
{
@@ -33,7 +35,7 @@ function findProductById(id_product) {
3335
if (!id_product || Number.isNaN(id_product)) {
3436
returnDTO.status = 400;
3537
returnDTO.jsonBody = {
36-
messages: ['id não informado ou inválido!'],
38+
messages: [constantUtil.MsgInvalidID],
3739
};
3840
return returnDTO;
3941
}
@@ -47,7 +49,7 @@ function findProductById(id_product) {
4749
if (!product) {
4850
returnDTO.status = 404;
4951
returnDTO.jsonBody = {
50-
messages: ['Item não encontrado!'],
52+
messages: [constantUtil.MsgStatus404],
5153
};
5254
return returnDTO;
5355
}

0 commit comments

Comments
 (0)