Merge remote-tracking branch 'refs/remotes/origin/producao'
This commit is contained in:
commit
0b9c1daf23
3 changed files with 26 additions and 3 deletions
|
|
@ -10,6 +10,7 @@ import { gerar } from "./listar_arquivos";
|
||||||
import React, {} from "react";
|
import React, {} from "react";
|
||||||
|
|
||||||
import fastifyStatc from "@fastify/static";
|
import fastifyStatc from "@fastify/static";
|
||||||
|
import dayjs from "dayjs";
|
||||||
import Fastify, {} from "fastify";
|
import Fastify, {} from "fastify";
|
||||||
|
|
||||||
const { PORTA, PREFIXO } = ambiente;
|
const { PORTA, PREFIXO } = ambiente;
|
||||||
|
|
@ -57,10 +58,23 @@ const criarHtml = (entrada: {
|
||||||
|
|
||||||
gerar.then(() => {
|
gerar.then(() => {
|
||||||
const fastify = Fastify({
|
const fastify = Fastify({
|
||||||
logger: true,
|
logger: false,
|
||||||
|
|
||||||
ignoreTrailingSlash: true,
|
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
|
//cors
|
||||||
fastify.register(cors, {
|
fastify.register(cors, {
|
||||||
origin: "*",
|
origin: "*",
|
||||||
|
|
@ -118,7 +132,7 @@ gerar.then(() => {
|
||||||
// 404
|
// 404
|
||||||
fastify.setNotFoundHandler((request, reply) => {
|
fastify.setNotFoundHandler((request, reply) => {
|
||||||
const html404 = fs.readFileSync(
|
const html404 = fs.readFileSync(
|
||||||
estaticos("node_modules").html["404.html"],
|
path.join(process.cwd(), estaticos("relativo").html["404.html"]),
|
||||||
"utf8",
|
"utf8",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "p-estaticos",
|
"name": "p-estaticos",
|
||||||
"version": "0.39.0",
|
"version": "0.41.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/cors": "^9.0.1",
|
"@fastify/cors": "^9.0.1",
|
||||||
"@fastify/static": "^7.0.4",
|
"@fastify/static": "^7.0.4",
|
||||||
|
"dayjs": "^1.11.11",
|
||||||
"fastify": "^4.27.0",
|
"fastify": "^4.27.0",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
|
|
|
||||||
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
|
|
@ -14,6 +14,9 @@ importers:
|
||||||
'@fastify/static':
|
'@fastify/static':
|
||||||
specifier: ^7.0.4
|
specifier: ^7.0.4
|
||||||
version: 7.0.4
|
version: 7.0.4
|
||||||
|
dayjs:
|
||||||
|
specifier: ^1.11.11
|
||||||
|
version: 1.11.11
|
||||||
fastify:
|
fastify:
|
||||||
specifier: ^4.27.0
|
specifier: ^4.27.0
|
||||||
version: 4.27.0
|
version: 4.27.0
|
||||||
|
|
@ -248,6 +251,9 @@ packages:
|
||||||
csstype@3.1.3:
|
csstype@3.1.3:
|
||||||
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
|
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
|
||||||
|
|
||||||
|
dayjs@1.11.11:
|
||||||
|
resolution: {integrity: sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg==}
|
||||||
|
|
||||||
depd@2.0.0:
|
depd@2.0.0:
|
||||||
resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==}
|
resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==}
|
||||||
engines: {node: '>= 0.8'}
|
engines: {node: '>= 0.8'}
|
||||||
|
|
@ -831,6 +837,8 @@ snapshots:
|
||||||
|
|
||||||
csstype@3.1.3: {}
|
csstype@3.1.3: {}
|
||||||
|
|
||||||
|
dayjs@1.11.11: {}
|
||||||
|
|
||||||
depd@2.0.0: {}
|
depd@2.0.0: {}
|
||||||
|
|
||||||
dotenv-cli@7.4.1:
|
dotenv-cli@7.4.1:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue