32 lines
731 B
TypeScript
32 lines
731 B
TypeScript
|
|
import express, { Application } from "express";
|
||
|
|
import responseTime from "response-time";
|
||
|
|
import helmet from "helmet";
|
||
|
|
import dotenv from "dotenv";
|
||
|
|
|
||
|
|
dotenv.config();
|
||
|
|
|
||
|
|
export function createApp(): Application {
|
||
|
|
const app = express();
|
||
|
|
|
||
|
|
// secure apps by setting various HTTP headers
|
||
|
|
app.use(helmet());
|
||
|
|
app.disable("x-powered-by");
|
||
|
|
|
||
|
|
// Middlewares
|
||
|
|
app.use(express.json());
|
||
|
|
app.use(express.text());
|
||
|
|
app.use(express.urlencoded({ extended: true }));
|
||
|
|
|
||
|
|
// set up the response-time middleware
|
||
|
|
app.use(responseTime());
|
||
|
|
|
||
|
|
app.set("port", process.env.PORT ?? 3002);
|
||
|
|
|
||
|
|
// Rutas (placeholder para bounded contexts)
|
||
|
|
app.get("/", (req, res) => {
|
||
|
|
res.json({ message: "¡Servidor funcionando!" });
|
||
|
|
});
|
||
|
|
|
||
|
|
return app;
|
||
|
|
}
|