hightjs 0.3.5 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -116
- package/dist/bin/hightjs.js +51 -23
- package/dist/builder.js +198 -8
- package/dist/client/DefaultNotFound.d.ts +1 -1
- package/dist/client/DefaultNotFound.js +72 -46
- package/dist/client/client.d.ts +3 -0
- package/dist/{client.js → client/client.js} +4 -4
- package/dist/client/entry.client.js +77 -9
- package/dist/global/global.d.ts +117 -0
- package/dist/{auth/types.js → global/global.js} +0 -1
- package/dist/helpers.js +80 -2
- package/dist/hotReload.js +84 -4
- package/dist/index.js +72 -61
- package/dist/loaders.d.ts +1 -0
- package/dist/loaders.js +46 -0
- package/dist/renderer.js +158 -4
- package/dist/types.d.ts +44 -0
- package/package.json +37 -30
- package/.idea/HightJS.iml +0 -9
- package/.idea/copilot.data.migration.agent.xml +0 -6
- package/.idea/copilot.data.migration.ask.xml +0 -6
- package/.idea/copilot.data.migration.ask2agent.xml +0 -6
- package/.idea/copilot.data.migration.edit.xml +0 -6
- package/.idea/copilotDiffState.xml +0 -67
- package/.idea/inspectionProfiles/Project_Default.xml +0 -13
- package/.idea/libraries/test_package.xml +0 -9
- package/.idea/libraries/ts_commonjs_default_export.xml +0 -9
- package/.idea/misc.xml +0 -7
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/dist/auth/client.d.ts +0 -24
- package/dist/auth/client.js +0 -146
- package/dist/auth/components.d.ts +0 -29
- package/dist/auth/components.js +0 -100
- package/dist/auth/core.d.ts +0 -55
- package/dist/auth/core.js +0 -189
- package/dist/auth/index.d.ts +0 -7
- package/dist/auth/index.js +0 -45
- package/dist/auth/jwt.d.ts +0 -41
- package/dist/auth/jwt.js +0 -185
- package/dist/auth/providers/credentials.d.ts +0 -60
- package/dist/auth/providers/credentials.js +0 -97
- package/dist/auth/providers/discord.d.ts +0 -63
- package/dist/auth/providers/discord.js +0 -190
- package/dist/auth/providers/google.d.ts +0 -63
- package/dist/auth/providers/google.js +0 -186
- package/dist/auth/providers/index.d.ts +0 -2
- package/dist/auth/providers/index.js +0 -35
- package/dist/auth/providers.d.ts +0 -3
- package/dist/auth/providers.js +0 -26
- package/dist/auth/react/index.d.ts +0 -6
- package/dist/auth/react/index.js +0 -48
- package/dist/auth/react.d.ts +0 -22
- package/dist/auth/react.js +0 -199
- package/dist/auth/routes.d.ts +0 -16
- package/dist/auth/routes.js +0 -152
- package/dist/auth/types.d.ts +0 -76
- package/dist/client.d.ts +0 -3
- package/docs/README.md +0 -58
- package/docs/arquivos-especiais.md +0 -10
- package/docs/autenticacao.md +0 -212
- package/docs/checklist.md +0 -9
- package/docs/cli.md +0 -72
- package/docs/config.md +0 -216
- package/docs/estrutura.md +0 -20
- package/docs/faq.md +0 -10
- package/docs/hot-reload.md +0 -5
- package/docs/integracoes.md +0 -240
- package/docs/middlewares.md +0 -73
- package/docs/rotas-backend.md +0 -45
- package/docs/rotas-frontend.md +0 -66
- package/docs/seguranca.md +0 -8
- package/docs/websocket.md +0 -45
- package/example/certs/cert.pem +0 -20
- package/example/certs/key.pem +0 -27
- package/example/hightjs.config.ts +0 -87
- package/example/package-lock.json +0 -1174
- package/example/package.json +0 -26
- package/example/postcss.config.js +0 -8
- package/example/src/auth.ts +0 -42
- package/example/src/web/backend/routes/auth.ts +0 -3
- package/example/src/web/backend/routes/version.ts +0 -13
- package/example/src/web/globals.css +0 -5
- package/example/src/web/layout.tsx +0 -100
- package/example/src/web/routes/index.tsx +0 -153
- package/example/src/web/routes/login.tsx +0 -175
- package/example/tailwind.config.js +0 -12
- package/example/tsconfig.json +0 -15
- package/src/adapters/express.ts +0 -87
- package/src/adapters/factory.ts +0 -112
- package/src/adapters/fastify.ts +0 -104
- package/src/adapters/native.ts +0 -234
- package/src/api/console.ts +0 -305
- package/src/api/http.ts +0 -535
- package/src/auth/client.ts +0 -171
- package/src/auth/components.tsx +0 -125
- package/src/auth/core.ts +0 -215
- package/src/auth/index.ts +0 -25
- package/src/auth/jwt.ts +0 -210
- package/src/auth/providers/credentials.ts +0 -139
- package/src/auth/providers/discord.ts +0 -239
- package/src/auth/providers/google.ts +0 -234
- package/src/auth/providers/index.ts +0 -20
- package/src/auth/providers.ts +0 -20
- package/src/auth/react/index.ts +0 -25
- package/src/auth/react.tsx +0 -234
- package/src/auth/routes.ts +0 -183
- package/src/auth/types.ts +0 -108
- package/src/bin/hightjs.js +0 -222
- package/src/builder.js +0 -411
- package/src/client/DefaultNotFound.tsx +0 -84
- package/src/client/clientRouter.ts +0 -153
- package/src/client/entry.client.tsx +0 -444
- package/src/client.ts +0 -24
- package/src/components/Link.tsx +0 -38
- package/src/helpers.ts +0 -542
- package/src/hotReload.ts +0 -489
- package/src/index.ts +0 -546
- package/src/renderer.tsx +0 -263
- package/src/router.ts +0 -730
- package/src/types/framework.ts +0 -58
- package/src/types.ts +0 -207
- package/tsconfig.json +0 -17
package/docs/autenticacao.md
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
# 🔐 Autenticação (HightJS/auth)
|
|
2
|
-
|
|
3
|
-
Autenticação JWT embutida, fácil de configurar.
|
|
4
|
-
O jeito recomendado é criar as rotas diretamente no `auth.ts` e importar onde quiser.
|
|
5
|
-
|
|
6
|
-
## Configuração Básica & Rotas
|
|
7
|
-
|
|
8
|
-
`src/auth.ts`:
|
|
9
|
-
|
|
10
|
-
```ts
|
|
11
|
-
import { CredentialsProvider, DiscordProvider, createAuthRoutes } from 'hightjs/auth';
|
|
12
|
-
import type { AuthConfig } from 'hightjs/auth';
|
|
13
|
-
|
|
14
|
-
export const authConfig: AuthConfig = {
|
|
15
|
-
providers: [
|
|
16
|
-
new CredentialsProvider({
|
|
17
|
-
id: 'credentials',
|
|
18
|
-
name: 'Credentials',
|
|
19
|
-
credentials: {
|
|
20
|
-
username: { label: 'Username', type: 'text', placeholder: 'Digite seu usuário' },
|
|
21
|
-
password: { label: 'Password', type: 'password', placeholder: 'Digite sua senha' }
|
|
22
|
-
},
|
|
23
|
-
async authorize(credentials) {
|
|
24
|
-
if (credentials.username === 'admin' && credentials.password === 'admin') {
|
|
25
|
-
return {
|
|
26
|
-
id: '1',
|
|
27
|
-
username: 'admin',
|
|
28
|
-
email: 'admin@test.com',
|
|
29
|
-
name: 'Administrador',
|
|
30
|
-
testeeee: 'sdondsfndsfndsfodsfo'
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}),
|
|
36
|
-
new DiscordProvider({
|
|
37
|
-
clientId: "ID",
|
|
38
|
-
clientSecret: "TOKEN",
|
|
39
|
-
callbackUrl: "http://localhost:3000/api/auth/callback/discord",
|
|
40
|
-
scope: ['identify', 'email', 'guilds'],
|
|
41
|
-
successUrl: "http://localhost:3000/"
|
|
42
|
-
})
|
|
43
|
-
],
|
|
44
|
-
session: {
|
|
45
|
-
strategy: 'jwt',
|
|
46
|
-
maxAge: 24 * 60 * 60, // 24 horas
|
|
47
|
-
},
|
|
48
|
-
pages: {
|
|
49
|
-
signIn: '/login',
|
|
50
|
-
signOut: '/'
|
|
51
|
-
},
|
|
52
|
-
secret: 'hweb-test-secret-key-change-in-production'
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// Cria as rotas de autenticação automaticamente
|
|
56
|
-
export const authRoutes = createAuthRoutes(authConfig);
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Exportando as rotas
|
|
60
|
-
|
|
61
|
-
`src/web/backend/routes/auth.ts`:
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
import { authRoutes } from "../../../auth";
|
|
65
|
-
export default authRoutes;
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Configurando o Frontend
|
|
69
|
-
|
|
70
|
-
Para usar autenticação no frontend, você precisa configurar o `SessionProvider` no layout:
|
|
71
|
-
|
|
72
|
-
`src/web/layout.tsx`:
|
|
73
|
-
|
|
74
|
-
```tsx
|
|
75
|
-
import { SessionProvider } from 'hightjs/auth/react';
|
|
76
|
-
|
|
77
|
-
export const metadata = { title: 'Meu App', descrição: 'Descrição global' };
|
|
78
|
-
|
|
79
|
-
export default function Layout({ children }: { children: React.ReactNode }) {
|
|
80
|
-
return (
|
|
81
|
-
<SessionProvider>
|
|
82
|
-
{children}
|
|
83
|
-
</SessionProvider>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## Fazendo Login no Frontend
|
|
89
|
-
|
|
90
|
-
Exemplo de como implementar login com credenciais e Discord:
|
|
91
|
-
|
|
92
|
-
```tsx
|
|
93
|
-
import { useSession } from 'hightjs/auth/react';
|
|
94
|
-
import React, { useState } from 'react';
|
|
95
|
-
|
|
96
|
-
function LoginPage() {
|
|
97
|
-
const { signIn } = useSession();
|
|
98
|
-
const [username, setUsername] = useState('');
|
|
99
|
-
const [password, setPassword] = useState('');
|
|
100
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
101
|
-
const [error, setError] = useState<string | null>(null);
|
|
102
|
-
|
|
103
|
-
const handleDiscordLogin = async () => {
|
|
104
|
-
await signIn('discord', { redirect: true });
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const handleLogin = async (e: React.FormEvent) => {
|
|
108
|
-
e.preventDefault();
|
|
109
|
-
setIsLoading(true);
|
|
110
|
-
setError(null);
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
const result = await signIn('credentials', {
|
|
114
|
-
username: username,
|
|
115
|
-
password: password,
|
|
116
|
-
callbackUrl: '/'
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
if (!result || result.error) {
|
|
120
|
-
setError('Credenciais inválidas. Verifique seus dados e senha.');
|
|
121
|
-
setIsLoading(false);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
router.push("/")
|
|
125
|
-
} catch (err) {
|
|
126
|
-
setError('Ocorreu um erro inesperado. Tente novamente.');
|
|
127
|
-
setIsLoading(false);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
return (
|
|
132
|
-
<div>
|
|
133
|
-
<form onSubmit={handleLogin}>
|
|
134
|
-
<input
|
|
135
|
-
type="text"
|
|
136
|
-
value={username}
|
|
137
|
-
onChange={(e) => setUsername(e.target.value)}
|
|
138
|
-
placeholder="Username"
|
|
139
|
-
/>
|
|
140
|
-
<input
|
|
141
|
-
type="password"
|
|
142
|
-
value={password}
|
|
143
|
-
onChange={(e) => setPassword(e.target.value)}
|
|
144
|
-
placeholder="Password"
|
|
145
|
-
/>
|
|
146
|
-
<button type="submit" disabled={isLoading}>Login</button>
|
|
147
|
-
</form>
|
|
148
|
-
|
|
149
|
-
<button onClick={handleDiscordLogin}>Login com Discord</button>
|
|
150
|
-
|
|
151
|
-
{error && <p style={{color: 'red'}}>{error}</p>}
|
|
152
|
-
</div>
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## Acessando Dados do Usuário
|
|
158
|
-
|
|
159
|
-
Para acessar informações do usuário autenticado:
|
|
160
|
-
|
|
161
|
-
```tsx
|
|
162
|
-
import { useSession } from 'hightjs/auth/react';
|
|
163
|
-
|
|
164
|
-
function UserProfile() {
|
|
165
|
-
const { data: session, status, signOut } = useSession();
|
|
166
|
-
|
|
167
|
-
if (status === 'loading') return <p>Carregando...</p>;
|
|
168
|
-
|
|
169
|
-
if (!session) return <p>Não autenticado</p>;
|
|
170
|
-
|
|
171
|
-
return (
|
|
172
|
-
<div>
|
|
173
|
-
<h1>Bem-vindo, {session.user?.name}</h1>
|
|
174
|
-
<p>Email: {session.user?.email}</p>
|
|
175
|
-
<button onClick={() => signOut()}>Logout</button>
|
|
176
|
-
</div>
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
## Protegendo rotas backend
|
|
182
|
-
|
|
183
|
-
```ts
|
|
184
|
-
import { HightJSRequest } from "hightjs";
|
|
185
|
-
import { BackendRouteConfig, HightJSResponse } from "hightjs";
|
|
186
|
-
import { authRoutes } from "../../../../auth";
|
|
187
|
-
|
|
188
|
-
const route: BackendRouteConfig = {
|
|
189
|
-
pattern: "/api/version",
|
|
190
|
-
GET: async (req: HightJSRequest, params: any) => {
|
|
191
|
-
const session = await authRoutes.auth.getSession(req)
|
|
192
|
-
if (!session) {
|
|
193
|
-
return HightJSResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
194
|
-
}
|
|
195
|
-
return HightJSResponse.json({
|
|
196
|
-
version: "1.0.0",
|
|
197
|
-
name: "HightJS",
|
|
198
|
-
description: "Um framework web full-stack moderno para Node.js",
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
export default route;
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
## Métodos principais
|
|
206
|
-
|
|
207
|
-
- `signIn()` - Fazer login (credenciais ou provider)
|
|
208
|
-
- `signOut()` - Fazer logout
|
|
209
|
-
- `useSession()` - Hook para acessar sessão no frontend
|
|
210
|
-
- `authRoutes.auth.getSession()` - Verificar sessão no backend
|
|
211
|
-
- `authRoutes.auth.isAuthenticated()` - Verificar se está autenticado
|
|
212
|
-
|
package/docs/checklist.md
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# ✅ Checklist Mental
|
|
2
|
-
|
|
3
|
-
1. Precisa de página? Crie em `src/web/routes/...`
|
|
4
|
-
2. Precisa de endpoint? Crie em `src/web/backend/routes/...`
|
|
5
|
-
3. Precisa proteger? Use autenticação nas rotas
|
|
6
|
-
4. Precisa middleware? `middleware.ts` ou `middleware: []` na rota
|
|
7
|
-
5. Metadata? `generateMetadata` ou `metadata` no layout
|
|
8
|
-
6. Deploy? `npx hight start`
|
|
9
|
-
|
package/docs/cli.md
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# 🛠️ CLI
|
|
2
|
-
|
|
3
|
-
Comandos principais:
|
|
4
|
-
|
|
5
|
-
| Comando | Descrição |
|
|
6
|
-
|-------------------|----------------------|
|
|
7
|
-
| `npx hight dev` | Modo desenvolvimento |
|
|
8
|
-
| `npx hight start` | Modo produção |
|
|
9
|
-
|
|
10
|
-
## Opções
|
|
11
|
-
|
|
12
|
-
- `--port` ou `-p` Porta (default 3000)
|
|
13
|
-
- `--hostname` ou `-h` Host (default 0.0.0.0)
|
|
14
|
-
- `--framework` Framework: native, express, fastify (default: native)
|
|
15
|
-
- `--ssl` Ativa HTTPS (requer certificados em `./certs/`)
|
|
16
|
-
|
|
17
|
-
## Exemplos
|
|
18
|
-
|
|
19
|
-
### Desenvolvimento básico
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npx hight dev
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### Produção com porta customizada
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npx hight start -p 8080
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Com SSL (HTTPS)
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npx hight start --ssl -p 443
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
**Requisitos para SSL:**
|
|
38
|
-
- Modo Native (não funciona com Express/Fastify via CLI)
|
|
39
|
-
- Pasta `./certs/` na raiz do projeto
|
|
40
|
-
- Arquivos `cert.pem` e `key.pem` dentro de `./certs/`
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
projeto/
|
|
44
|
-
certs/
|
|
45
|
-
cert.pem
|
|
46
|
-
key.pem
|
|
47
|
-
src/
|
|
48
|
-
...
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Com framework específico
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
# Usando Express
|
|
55
|
-
npx hight dev --framework express
|
|
56
|
-
|
|
57
|
-
# Usando Fastify
|
|
58
|
-
npx hight dev --framework fastify
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
## 🔐 SSL Integrado
|
|
64
|
-
|
|
65
|
-
O HightJS oferece suporte SSL nativo quando usando o adaptador Native. Para mais detalhes sobre integrações com Express e Fastify, consulte:
|
|
66
|
-
|
|
67
|
-
👉 [**Guia de Integrações**](./integracoes.md)
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
Voltar para a [documentação principal](./README.md)
|
|
72
|
-
|
package/docs/config.md
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
# HightJS Configuration (hightjs.config.ts)
|
|
2
|
-
|
|
3
|
-
O HightJS permite que você personalize as configurações do servidor através de um arquivo `hightjs.config.ts` (ou `.js`) na raiz do seu projeto.
|
|
4
|
-
|
|
5
|
-
## 📝 Estrutura Básica
|
|
6
|
-
|
|
7
|
-
### Opção 1: Função de Configuração (Recomendado)
|
|
8
|
-
|
|
9
|
-
```typescript
|
|
10
|
-
import type { HightConfig, HightConfigFunction } from 'hightjs';
|
|
11
|
-
|
|
12
|
-
const hightConfig: HightConfigFunction = (phase, { defaultConfig }) => {
|
|
13
|
-
const config: HightConfig = {
|
|
14
|
-
maxHeadersCount: 100,
|
|
15
|
-
headersTimeout: 60000,
|
|
16
|
-
requestTimeout: 30000,
|
|
17
|
-
serverTimeout: 35000,
|
|
18
|
-
individualRequestTimeout: 30000,
|
|
19
|
-
maxUrlLength: 2048,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// Personalize baseado no ambiente
|
|
23
|
-
if (phase === 'development') {
|
|
24
|
-
config.requestTimeout = 60000;
|
|
25
|
-
config.individualRequestTimeout = 60000;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (phase === 'production') {
|
|
29
|
-
config.maxHeadersCount = 50;
|
|
30
|
-
config.maxUrlLength = 1024;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return config;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default hightConfig;
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Opção 2: Objeto Estático
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
import type { HightConfig } from 'hightjs';
|
|
43
|
-
|
|
44
|
-
const config: HightConfig = {
|
|
45
|
-
maxHeadersCount: 100,
|
|
46
|
-
headersTimeout: 60000,
|
|
47
|
-
requestTimeout: 30000,
|
|
48
|
-
serverTimeout: 35000,
|
|
49
|
-
individualRequestTimeout: 30000,
|
|
50
|
-
maxUrlLength: 2048,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export default config;
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## ⚙️ Configurações Disponíveis
|
|
57
|
-
|
|
58
|
-
| Propriedade | Tipo | Padrão | Descrição |
|
|
59
|
-
|------------|------|--------|-----------|
|
|
60
|
-
| `maxHeadersCount` | `number` | `100` | Número máximo de headers HTTP permitidos por requisição |
|
|
61
|
-
| `headersTimeout` | `number` | `60000` | Timeout em ms para receber os headers HTTP |
|
|
62
|
-
| `requestTimeout` | `number` | `30000` | Timeout em ms para uma requisição completa |
|
|
63
|
-
| `serverTimeout` | `number` | `35000` | Timeout geral do servidor em ms |
|
|
64
|
-
| `individualRequestTimeout` | `number` | `30000` | Timeout por requisição individual em ms |
|
|
65
|
-
| `maxUrlLength` | `number` | `2048` | Tamanho máximo da URL em caracteres |
|
|
66
|
-
| `accessLogging` | `boolean` | `false` | Habilita logs de acesso HTTP (ex: `GET /api/users 200 15ms`) |
|
|
67
|
-
|
|
68
|
-
## 🎯 Casos de Uso
|
|
69
|
-
|
|
70
|
-
### Habilitar Logs de Acesso
|
|
71
|
-
|
|
72
|
-
```typescript
|
|
73
|
-
const config: HightConfig = {
|
|
74
|
-
accessLogging: true, // Mostra: GET /api/users 200 15ms
|
|
75
|
-
};
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Aumentar Timeouts para Debugging
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
const config: HightConfig = {
|
|
82
|
-
requestTimeout: 120000, // 2 minutos
|
|
83
|
-
individualRequestTimeout: 120000,
|
|
84
|
-
};
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Aumentar Limites para APIs com Muitos Headers
|
|
88
|
-
|
|
89
|
-
```typescript
|
|
90
|
-
const config: HightConfig = {
|
|
91
|
-
maxHeadersCount: 200, // Dobro do padrão
|
|
92
|
-
};
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Configuração Rigorosa para Produção
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
const hightConfig: HightConfigFunction = (phase) => {
|
|
99
|
-
if (phase === 'production') {
|
|
100
|
-
return {
|
|
101
|
-
maxHeadersCount: 50,
|
|
102
|
-
maxUrlLength: 1024,
|
|
103
|
-
requestTimeout: 15000, // Mais restritivo
|
|
104
|
-
individualRequestTimeout: 15000,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Valores padrão para desenvolvimento
|
|
109
|
-
return {};
|
|
110
|
-
};
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### Suporte a URLs Muito Longas
|
|
114
|
-
|
|
115
|
-
```typescript
|
|
116
|
-
const config: HightConfig = {
|
|
117
|
-
maxUrlLength: 4096, // Dobro do padrão
|
|
118
|
-
};
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## 🔄 Hot Reload
|
|
122
|
-
|
|
123
|
-
Em modo de desenvolvimento (`dev: true`), o arquivo de configuração é recarregado automaticamente quando modificado, permitindo ajustes sem reiniciar o servidor.
|
|
124
|
-
|
|
125
|
-
## 📦 TypeScript vs JavaScript
|
|
126
|
-
|
|
127
|
-
### TypeScript (Recomendado)
|
|
128
|
-
- Arquivo: `hightjs.config.ts`
|
|
129
|
-
- Benefícios: Autocomplete, validação de tipos, detecção de erros
|
|
130
|
-
|
|
131
|
-
### JavaScript
|
|
132
|
-
- Arquivo: `hightjs.config.js`
|
|
133
|
-
- Use JSDoc para ter intellisense:
|
|
134
|
-
|
|
135
|
-
```javascript
|
|
136
|
-
/**
|
|
137
|
-
* @type {import('hightjs').HightConfigFunction}
|
|
138
|
-
*/
|
|
139
|
-
const hightConfig = (phase, { defaultConfig }) => {
|
|
140
|
-
/** @type {import('hightjs').HightConfig} */
|
|
141
|
-
const config = {
|
|
142
|
-
maxHeadersCount: 100,
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
return config;
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
module.exports = hightConfig;
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
## 🚀 Exemplo Completo
|
|
152
|
-
|
|
153
|
-
```typescript
|
|
154
|
-
import type { HightConfig, HightConfigFunction } from 'hightjs';
|
|
155
|
-
|
|
156
|
-
const hightConfig: HightConfigFunction = (phase, { defaultConfig }) => {
|
|
157
|
-
// Começa com valores padrão
|
|
158
|
-
const config: HightConfig = { ...defaultConfig };
|
|
159
|
-
|
|
160
|
-
// Configurações comuns
|
|
161
|
-
config.maxHeadersCount = 150;
|
|
162
|
-
|
|
163
|
-
// Ajustes por ambiente
|
|
164
|
-
if (phase === 'development') {
|
|
165
|
-
// Habilita logs de acesso em dev
|
|
166
|
-
config.accessLogging = true;
|
|
167
|
-
|
|
168
|
-
// Timeouts maiores para debugging
|
|
169
|
-
config.requestTimeout = 120000;
|
|
170
|
-
config.individualRequestTimeout = 120000;
|
|
171
|
-
|
|
172
|
-
// URLs longas para testes
|
|
173
|
-
config.maxUrlLength = 4096;
|
|
174
|
-
} else if (phase === 'production') {
|
|
175
|
-
// Logs de acesso também podem ser úteis em produção
|
|
176
|
-
config.accessLogging = true;
|
|
177
|
-
|
|
178
|
-
// Mais restritivo em produção
|
|
179
|
-
config.maxHeadersCount = 50;
|
|
180
|
-
config.maxUrlLength = 1024;
|
|
181
|
-
config.requestTimeout = 20000;
|
|
182
|
-
config.individualRequestTimeout = 20000;
|
|
183
|
-
|
|
184
|
-
// Timeouts mais curtos para headers
|
|
185
|
-
config.headersTimeout = 30000;
|
|
186
|
-
config.serverTimeout = 25000;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return config;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
export default hightConfig;
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## 📍 Localização do Arquivo
|
|
196
|
-
|
|
197
|
-
O arquivo `hightjs.config.ts` (ou `.js`) deve estar na **raiz do seu projeto**, no mesmo nível do `package.json`.
|
|
198
|
-
|
|
199
|
-
```
|
|
200
|
-
seu-projeto/
|
|
201
|
-
├── hightjs.config.ts ← Aqui
|
|
202
|
-
├── package.json
|
|
203
|
-
├── tsconfig.json
|
|
204
|
-
└── src/
|
|
205
|
-
└── web/
|
|
206
|
-
└── ...
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
## ⚠️ Notas Importantes
|
|
210
|
-
|
|
211
|
-
1. **Prioridade**: `.ts` tem prioridade sobre `.js` se ambos existirem
|
|
212
|
-
2. **Fallback**: Se o arquivo não existir, valores padrão serão usados
|
|
213
|
-
3. **Validação**: Valores inválidos serão ignorados e substituídos pelos padrões
|
|
214
|
-
4. **Performance**: Use valores apropriados para evitar timeouts desnecessários ou aberturas de segurança
|
|
215
|
-
5. **Segurança**: Não exponha valores muito altos em produção (ex: `maxUrlLength` muito grande pode facilitar ataques DoS)
|
|
216
|
-
|
package/docs/estrutura.md
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# 📦 Estrutura Recomendada
|
|
2
|
-
|
|
3
|
-
```
|
|
4
|
-
src/
|
|
5
|
-
web/
|
|
6
|
-
layout.tsx // Layout global (opcional)
|
|
7
|
-
notFound.tsx // Página 404 customizada (opcional)
|
|
8
|
-
routes/
|
|
9
|
-
index.tsx // Página inicial "/"
|
|
10
|
-
about.tsx // Página "/about"
|
|
11
|
-
blog.tsx // Rota dinâmica "/blog/123"
|
|
12
|
-
backend/
|
|
13
|
-
routes/
|
|
14
|
-
middleware.ts // Middlewares globais da pasta
|
|
15
|
-
version.ts // Endpoint "/version"
|
|
16
|
-
users/
|
|
17
|
-
middleware.ts // Middlewares só desse grupo
|
|
18
|
-
list.ts // Endpoint "/users/list"
|
|
19
|
-
```
|
|
20
|
-
|
package/docs/faq.md
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# ❓ FAQ Rápido
|
|
2
|
-
|
|
3
|
-
| Pergunta | Resposta |
|
|
4
|
-
|--------------------------------|-----------------------------------------------------|
|
|
5
|
-
| Precisa Next/Vite? | Não, bundler interno via esbuild. |
|
|
6
|
-
| Dá para usar React 19? | Sim (peer dependency). |
|
|
7
|
-
| Tem SSR? | Atualmente só client-side hydration. |
|
|
8
|
-
| Posso usar CSS/SCSS? | Import normal nos componentes. |
|
|
9
|
-
| Rota de API conflita com página?| Não, rotas backend podem ser qualquer path. |
|
|
10
|
-
|