Merge remote-tracking branch 'refs/remotes/origin/producao'

This commit is contained in:
andreLMpena 2024-07-01 11:21:21 -03:00
commit 0b9c1daf23
3 changed files with 26 additions and 3 deletions

View file

@ -10,6 +10,7 @@ import { gerar } from "./listar_arquivos";
import React, {} from "react";
import fastifyStatc from "@fastify/static";
import dayjs from "dayjs";
import Fastify, {} from "fastify";
const { PORTA, PREFIXO } = ambiente;
@ -57,10 +58,23 @@ const criarHtml = (entrada: {
gerar.then(() => {
const fastify = Fastify({
logger: true,
logger: false,
ignoreTrailingSlash: true,
});
fastify.addHook("onSend", async (request, reply) => {
console.log(
[
dayjs().format("YYYY-MM-DD HH:mm:ss"),
request.method,
request.url,
reply.statusCode,
request.headers.site || request.headers.referer,
].join(" "),
);
});
//cors
fastify.register(cors, {
origin: "*",
@ -118,7 +132,7 @@ gerar.then(() => {
// 404
fastify.setNotFoundHandler((request, reply) => {
const html404 = fs.readFileSync(
estaticos("node_modules").html["404.html"],
path.join(process.cwd(), estaticos("relativo").html["404.html"]),
"utf8",
);

View file

@ -1,6 +1,6 @@
{
"name": "p-estaticos",
"version": "0.39.0",
"version": "0.41.0",
"description": "",
"main": "dist/index.js",
"scripts": {
@ -21,6 +21,7 @@
"dependencies": {
"@fastify/cors": "^9.0.1",
"@fastify/static": "^7.0.4",
"dayjs": "^1.11.11",
"fastify": "^4.27.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",

8
pnpm-lock.yaml generated
View file

@ -14,6 +14,9 @@ importers:
'@fastify/static':
specifier: ^7.0.4
version: 7.0.4
dayjs:
specifier: ^1.11.11
version: 1.11.11
fastify:
specifier: ^4.27.0
version: 4.27.0
@ -248,6 +251,9 @@ packages:
csstype@3.1.3:
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
dayjs@1.11.11:
resolution: {integrity: sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg==}
depd@2.0.0:
resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==}
engines: {node: '>= 0.8'}
@ -831,6 +837,8 @@ snapshots:
csstype@3.1.3: {}
dayjs@1.11.11: {}
depd@2.0.0: {}
dotenv-cli@7.4.1: