-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.js
33 lines (28 loc) · 907 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import express from "express";
import mustache from "mustache-express";
import { app, router, server } from "./routes/index.js";
import cors from "cors";
import path from "path";
import compression from "compression";
// Constante
const dirname = path.resolve();
// Config
app.use(cors());
app.use(express.json({ limit: "50mb" }));
app.use(express.urlencoded({ limit: "50mb", extended: true }));
app.use(compression());
app.use("/upload", express.static(path.join(dirname, "upload")));
app.use("/upload/enviar", express.static(path.join(dirname, "upload/enviar")));
// Rotas
app.use("/", router);
app.use((req, res) => {
res
.status(404)
.type("txt")
.send("404, rota não encontrada, verifique a solicitação.");
});
// Habilitando mustache para renderizar views
app.engine("mst", mustache());
app.set("view engine", "mst");
app.set("views", dirname + "/views");
export default server;