hightjs 0.4.0 → 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 +139 -4
- 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 +39 -29
- 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 +2 -2
- package/dist/index.js +16 -16
- 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 +36 -31
- 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/backend/auth.ts +0 -42
- package/example/src/backend/routes/auth.ts +0 -3
- package/example/src/backend/routes/version.ts +0 -13
- package/example/src/web/components/Home.tsx +0 -140
- package/example/src/web/components/LoginPage.tsx +0 -149
- package/example/src/web/globals.css +0 -5
- package/example/src/web/layout.tsx +0 -100
- package/example/src/web/routes/index.tsx +0 -13
- package/example/src/web/routes/login.tsx +0 -30
- 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 -472
- package/src/client/DefaultNotFound.tsx +0 -84
- package/src/client/clientRouter.ts +0 -153
- package/src/client/entry.client.tsx +0 -511
- package/src/client.ts +0 -24
- package/src/components/Link.tsx +0 -38
- package/src/helpers.ts +0 -542
- package/src/hotReload.ts +0 -569
- package/src/index.ts +0 -555
- 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/integracoes.md
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
# 🔌 Integrações
|
|
2
|
-
|
|
3
|
-
O HightJS pode ser usado de três formas diferentes: **Native** (servidor próprio), **Express** ou **Fastify**.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 🚀 Native (Recomendado)
|
|
8
|
-
|
|
9
|
-
O modo nativo não requer dependências extras e oferece todos os recursos do HightJS, incluindo **SSL integrado**.
|
|
10
|
-
|
|
11
|
-
### Via CLI (Recomendado)
|
|
12
|
-
|
|
13
|
-
A forma recomendada de iniciar o servidor Native é usando a CLI:
|
|
14
|
-
|
|
15
|
-
**Desenvolvimento:**
|
|
16
|
-
```bash
|
|
17
|
-
npx hight dev
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
**Produção:**
|
|
21
|
-
```bash
|
|
22
|
-
npx hight start
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
**Com SSL:**
|
|
26
|
-
```bash
|
|
27
|
-
npx hight start --ssl -p 443
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
**Opções disponíveis:**
|
|
31
|
-
- `--port` ou `-p`: Define a porta (padrão: 3000)
|
|
32
|
-
- `--hostname` ou `-h`: Define o host (padrão: 0.0.0.0)
|
|
33
|
-
- `--ssl`: Ativa HTTPS (requer certificados em `./certs/`)
|
|
34
|
-
|
|
35
|
-
### Via Código (Alternativa)
|
|
36
|
-
|
|
37
|
-
Se precisar de mais controle programático, você pode inicializar manualmente:
|
|
38
|
-
|
|
39
|
-
**Básico:**
|
|
40
|
-
```typescript
|
|
41
|
-
import { app } from "hightjs";
|
|
42
|
-
|
|
43
|
-
const hightApp = app({
|
|
44
|
-
port: 3000,
|
|
45
|
-
dev: true
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
hightApp.init();
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
**Com SSL:**
|
|
52
|
-
```typescript
|
|
53
|
-
import { app } from "hightjs";
|
|
54
|
-
|
|
55
|
-
const hightApp = app({
|
|
56
|
-
port: 443,
|
|
57
|
-
dev: false,
|
|
58
|
-
ssl: {
|
|
59
|
-
redirectPort: 80,
|
|
60
|
-
key: "./certs/key.pem",
|
|
61
|
-
cert: "./certs/cert.pem"
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
hightApp.init();
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
**Estrutura de pastas para SSL:**
|
|
69
|
-
```
|
|
70
|
-
projeto/
|
|
71
|
-
certs/
|
|
72
|
-
cert.pem
|
|
73
|
-
key.pem
|
|
74
|
-
src/
|
|
75
|
-
...
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
**Opções SSL:**
|
|
79
|
-
- `key`: Caminho para o arquivo de chave privada
|
|
80
|
-
- `cert`: Caminho para o arquivo de certificado
|
|
81
|
-
- `redirectPort`: Porta HTTP que redirecionará para HTTPS (opcional)
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
## 📦 Express
|
|
86
|
-
|
|
87
|
-
Se você já tem um projeto Express ou prefere usar Express, pode integrar o HightJS facilmente.
|
|
88
|
-
|
|
89
|
-
### Instalação
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
npm install express
|
|
93
|
-
npm install --save-dev @types/express
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Uso
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
import express from 'express';
|
|
100
|
-
import { app } from "hightjs";
|
|
101
|
-
|
|
102
|
-
const port = 3000;
|
|
103
|
-
const dev = true;
|
|
104
|
-
|
|
105
|
-
const expressApp = express();
|
|
106
|
-
const hightApp = app({
|
|
107
|
-
framework: 'express',
|
|
108
|
-
port: port,
|
|
109
|
-
dev: dev
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
hightApp.integrate(expressApp);
|
|
113
|
-
|
|
114
|
-
expressApp.listen(port, () => {
|
|
115
|
-
console.log(`Servidor rodando em http://localhost:${port}`);
|
|
116
|
-
});
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Com middlewares Express
|
|
120
|
-
|
|
121
|
-
Você pode adicionar middlewares Express normalmente antes da integração:
|
|
122
|
-
|
|
123
|
-
```typescript
|
|
124
|
-
import express from 'express';
|
|
125
|
-
import { app } from "hightjs";
|
|
126
|
-
import cors from 'cors';
|
|
127
|
-
|
|
128
|
-
const expressApp = express();
|
|
129
|
-
|
|
130
|
-
// Middlewares Express
|
|
131
|
-
expressApp.use(cors());
|
|
132
|
-
expressApp.use(express.json());
|
|
133
|
-
|
|
134
|
-
const hightApp = app({
|
|
135
|
-
framework: 'express',
|
|
136
|
-
port: 3000,
|
|
137
|
-
dev: true
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
hightApp.integrate(expressApp);
|
|
141
|
-
|
|
142
|
-
expressApp.listen(3000);
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
---
|
|
146
|
-
|
|
147
|
-
## ⚡ Fastify
|
|
148
|
-
|
|
149
|
-
Para máxima performance, você pode usar Fastify como base.
|
|
150
|
-
|
|
151
|
-
### Instalação
|
|
152
|
-
|
|
153
|
-
```bash
|
|
154
|
-
npm install fastify
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### Uso
|
|
158
|
-
|
|
159
|
-
```typescript
|
|
160
|
-
import Fastify from 'fastify';
|
|
161
|
-
import { app } from 'hightjs';
|
|
162
|
-
|
|
163
|
-
const port = 3000;
|
|
164
|
-
const dev = true;
|
|
165
|
-
|
|
166
|
-
// Cria o servidor Fastify
|
|
167
|
-
const fastifyApp = Fastify({
|
|
168
|
-
logger: dev // Ativa logs se estiver em modo dev
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// Cria a instância do HightJS usando Fastify
|
|
172
|
-
const hightApp = app({
|
|
173
|
-
framework: 'fastify',
|
|
174
|
-
port: port,
|
|
175
|
-
dev: dev
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
// Integra o Fastify ao HightJS
|
|
179
|
-
hightApp.integrate(fastifyApp);
|
|
180
|
-
|
|
181
|
-
// Inicia o servidor Fastify
|
|
182
|
-
fastifyApp.listen({ port }, (err, address) => {
|
|
183
|
-
if (err) {
|
|
184
|
-
fastifyApp.log.error(err);
|
|
185
|
-
process.exit(1);
|
|
186
|
-
}
|
|
187
|
-
console.log(`Servidor rodando em ${address}`);
|
|
188
|
-
});
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Com plugins Fastify
|
|
192
|
-
|
|
193
|
-
Você pode registrar plugins Fastify antes da integração:
|
|
194
|
-
|
|
195
|
-
```typescript
|
|
196
|
-
import Fastify from 'fastify';
|
|
197
|
-
import { app } from 'hightjs';
|
|
198
|
-
import fastifyCors from '@fastify/cors';
|
|
199
|
-
|
|
200
|
-
const fastifyApp = Fastify({ logger: true });
|
|
201
|
-
|
|
202
|
-
// Registra plugins Fastify
|
|
203
|
-
await fastifyApp.register(fastifyCors, {
|
|
204
|
-
origin: true
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
const hightApp = app({
|
|
208
|
-
framework: 'fastify',
|
|
209
|
-
port: 3000,
|
|
210
|
-
dev: true
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
hightApp.integrate(fastifyApp);
|
|
214
|
-
|
|
215
|
-
fastifyApp.listen({ port: 3000 });
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
---
|
|
219
|
-
|
|
220
|
-
## 🤔 Qual escolher?
|
|
221
|
-
|
|
222
|
-
| Framework | Vantagens | Use quando |
|
|
223
|
-
|-----------|-----------|------------|
|
|
224
|
-
| **Native** | SSL integrado, zero config, sem dependências extras | Projetos novos, quer simplicidade |
|
|
225
|
-
| **Express** | Ecossistema gigante, muitos middlewares | Já usa Express, precisa de middlewares específicos |
|
|
226
|
-
| **Fastify** | Máxima performance, validação schema | Precisa de alta performance, validação avançada |
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
## ⚠️ Notas importantes
|
|
231
|
-
|
|
232
|
-
1. **SSL só está disponível no modo Native**
|
|
233
|
-
2. Ao usar Express/Fastify, você gerencia o servidor manualmente
|
|
234
|
-
3. O HightJS se integra perfeitamente com qualquer framework escolhido
|
|
235
|
-
4. Todos os recursos do HightJS funcionam em qualquer modo (rotas, WebSocket, auth, etc.)
|
|
236
|
-
|
|
237
|
-
---
|
|
238
|
-
|
|
239
|
-
Voltar para a [documentação principal](./README.md)
|
|
240
|
-
|
package/docs/middlewares.md
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# 🧩 Middlewares
|
|
2
|
-
|
|
3
|
-
Adicione middlewares:
|
|
4
|
-
|
|
5
|
-
- Direto na rota: `middleware: [...]`
|
|
6
|
-
- Arquivo `middleware.ts` na pasta (auto-carregado)
|
|
7
|
-
|
|
8
|
-
## Interface
|
|
9
|
-
|
|
10
|
-
```ts
|
|
11
|
-
export type HightMiddleware = (
|
|
12
|
-
request: HightJSRequest,
|
|
13
|
-
params: { [key: string]: string },
|
|
14
|
-
next: () => Promise<HightJSResponse>
|
|
15
|
-
) => Promise<HightJSResponse> | HightJSResponse;
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Exemplo por Pasta
|
|
19
|
-
|
|
20
|
-
`src/backend/routes/middleware.ts`:
|
|
21
|
-
|
|
22
|
-
```ts
|
|
23
|
-
import {HightJSRequest, HightJSResponse} from 'hightjs';
|
|
24
|
-
|
|
25
|
-
export async function log(
|
|
26
|
-
request: HightJSRequest,
|
|
27
|
-
params: { [key: string]: string },
|
|
28
|
-
next: () => Promise<HightJSResponse>
|
|
29
|
-
): Promise<HightJSResponse> {
|
|
30
|
-
|
|
31
|
-
console.log('[API]', request.method, request.url);
|
|
32
|
-
return next();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export async function blockLegacy(
|
|
37
|
-
request: HightJSRequest,
|
|
38
|
-
params: { [key: string]: string },
|
|
39
|
-
next: () => Promise<HightJSResponse>
|
|
40
|
-
): Promise<HightJSResponse> {
|
|
41
|
-
if (request.header('user-agent')?.includes('IE 8')) {
|
|
42
|
-
return HightJSResponse.json({ error: 'Navegador não suportado' }, {status: 400});
|
|
43
|
-
}
|
|
44
|
-
return next();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default [log, blockLegacy];
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Exemplo por Rota
|
|
51
|
-
|
|
52
|
-
```ts
|
|
53
|
-
import {BackendRouteConfig, HightJSRequest, HightJSResponse} from 'hightjs';
|
|
54
|
-
|
|
55
|
-
async function authCheck(
|
|
56
|
-
request: HightJSRequest,
|
|
57
|
-
params: { [key: string]: string },
|
|
58
|
-
next: () => Promise<HightJSResponse>
|
|
59
|
-
): Promise<HightJSResponse> {
|
|
60
|
-
if(!request.header("authorization")) {
|
|
61
|
-
return HightJSResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
62
|
-
}
|
|
63
|
-
return next();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const route: BackendRouteConfig = {
|
|
67
|
-
pattern: '/secure/data',
|
|
68
|
-
middleware: [authCheck],
|
|
69
|
-
GET: async () => HightJSResponse.json({ secret: true })
|
|
70
|
-
};
|
|
71
|
-
export default route;
|
|
72
|
-
```
|
|
73
|
-
|
package/docs/rotas-backend.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# 🌐 Rotas Backend
|
|
2
|
-
|
|
3
|
-
Qualquer arquivo em `src/backend/routes` vira endpoint backend.
|
|
4
|
-
O _pattern_ pode ser qualquer caminho, não só `/api/...`!
|
|
5
|
-
|
|
6
|
-
## Exemplo Simples
|
|
7
|
-
|
|
8
|
-
`src/backend/routes/version.ts`:
|
|
9
|
-
|
|
10
|
-
```ts
|
|
11
|
-
import { HightJSRequest, HightJSResponse, BackendRouteConfig } from 'hightjs';
|
|
12
|
-
|
|
13
|
-
const route: BackendRouteConfig = {
|
|
14
|
-
pattern: '/version',
|
|
15
|
-
GET: async (_req: HightJSRequest) => {
|
|
16
|
-
return HightJSResponse.json({
|
|
17
|
-
version: '1.0.0',
|
|
18
|
-
name: 'HightJS',
|
|
19
|
-
description: 'Framework web full-stack moderno para Node.js'
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
export default route;
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Suporte a Métodos
|
|
27
|
-
|
|
28
|
-
Defina `GET`, `POST`, `PUT`, `DELETE` (ou só os necessários).
|
|
29
|
-
|
|
30
|
-
## Rotas Dinâmicas Backend
|
|
31
|
-
|
|
32
|
-
`src/backend/routes/users/[id].ts` → `/users/123`
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
import { BackendRouteConfig, HightJSResponse } from "hightjs";
|
|
36
|
-
|
|
37
|
-
const route: BackendRouteConfig = {
|
|
38
|
-
pattern: '/users/[id]',
|
|
39
|
-
GET: async (req, params) => {
|
|
40
|
-
return HightJSResponse.json({ userId: params.id });
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
export default route;
|
|
44
|
-
```
|
|
45
|
-
|
package/docs/rotas-frontend.md
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
# 🖥️ Rotas Frontend
|
|
2
|
-
|
|
3
|
-
Cada arquivo em `src/web/routes` é uma página.
|
|
4
|
-
|
|
5
|
-
```tsx
|
|
6
|
-
import { RouteConfig } from 'hightjs/client';
|
|
7
|
-
import React from 'react';
|
|
8
|
-
|
|
9
|
-
function Component() {
|
|
10
|
-
return <h1>HELLO WORLD</h1>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const config: RouteConfig = {
|
|
14
|
-
pattern: '/thanks2',
|
|
15
|
-
component: Component,
|
|
16
|
-
generateMetadata: () => ({ title: 'HightJS | Thanks' })
|
|
17
|
-
};
|
|
18
|
-
export default config;
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Rotas Dinâmicas com Parâmetros
|
|
22
|
-
|
|
23
|
-
```tsx
|
|
24
|
-
import {RouteConfig} from "hightjs/client";
|
|
25
|
-
import React from "react";
|
|
26
|
-
|
|
27
|
-
function PostPage({ params }: { params: { id: string } }) {
|
|
28
|
-
const id = params.id
|
|
29
|
-
return (
|
|
30
|
-
<div>
|
|
31
|
-
<h1>Post ID: {id}</h1>
|
|
32
|
-
<p>This is the content of post {id}.</p>
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const config: RouteConfig = {
|
|
38
|
-
pattern: '/post/[id]',
|
|
39
|
-
component: PostPage,
|
|
40
|
-
generateMetadata: async (params) => ({ title: `Post ${params.id}` })
|
|
41
|
-
};
|
|
42
|
-
export default config
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Layout Global
|
|
47
|
-
|
|
48
|
-
`src/web/layout.tsx`:
|
|
49
|
-
|
|
50
|
-
```tsx
|
|
51
|
-
export const metadata = { title: 'Meu App', description: 'Descrição global' };
|
|
52
|
-
export default function Layout({ children }: { children: React.ReactNode }) {
|
|
53
|
-
return <div>{children}</div>;
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Página 404
|
|
58
|
-
|
|
59
|
-
`src/web/notFound.tsx`:
|
|
60
|
-
|
|
61
|
-
```tsx
|
|
62
|
-
export default function NotFound() {
|
|
63
|
-
return <h1>Página não encontrada</h1>;
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
package/docs/seguranca.md
DELETED
package/docs/websocket.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# 🛜 WebSocket
|
|
2
|
-
|
|
3
|
-
O HightJS possui suporte nativo a WebSockets nas rotas do backend.
|
|
4
|
-
|
|
5
|
-
## Exemplo Prático
|
|
6
|
-
|
|
7
|
-
`src/backend/routes/chat.ts`:
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
import {BackendRouteConfig, HightJSResponse} from 'hightjs';
|
|
11
|
-
|
|
12
|
-
const route: BackendRouteConfig = {
|
|
13
|
-
pattern: '/api/chat',
|
|
14
|
-
GET: async () => {
|
|
15
|
-
return HightJSResponse.json({ message: 'Chat HTTP endpoint' });
|
|
16
|
-
},
|
|
17
|
-
WS: (ctx) => {
|
|
18
|
-
console.log('Nova conexão WebSocket no chat');
|
|
19
|
-
|
|
20
|
-
ctx.send({
|
|
21
|
-
type: 'welcome',
|
|
22
|
-
message: 'Bem-vindo ao chat!'
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
ctx.ws.on('message', (data) => {
|
|
26
|
-
const message = JSON.parse(data.toString());
|
|
27
|
-
console.log(message)
|
|
28
|
-
// Broadcast para todos exceto o remetente
|
|
29
|
-
ctx.broadcast({
|
|
30
|
-
type: 'message',
|
|
31
|
-
user: message.user,
|
|
32
|
-
text: message.text,
|
|
33
|
-
timestamp: new Date().toISOString()
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
ctx.ws.on('close', () => {
|
|
38
|
-
console.log('Cliente desconectado');
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export default route;
|
|
44
|
-
```
|
|
45
|
-
|
package/example/certs/cert.pem
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
|
2
|
-
MIIDSTCCAjGgAwIBAgIUEDNwk+twrH227ELWWT9Qn92kOzswDQYJKoZIhvcNAQEL
|
|
3
|
-
BQAwNDELMAkGA1UEBhMCQlIxFTATBgNVBAgMDFPDg8KjbyBQYXVsbzEOMAwGA1UE
|
|
4
|
-
CgwFSGlnaHQwHhcNMjUxMDI2MTY0NDM2WhcNMjYxMDI2MTY0NDM2WjA0MQswCQYD
|
|
5
|
-
VQQGEwJCUjEVMBMGA1UECAwMU8ODwqNvIFBhdWxvMQ4wDAYDVQQKDAVIaWdodDCC
|
|
6
|
-
ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL+jVQJ2GbyDOWs+KZ0Mlx1f
|
|
7
|
-
E983vQQVoQpbh/Tzqo4NNGZHGEQF+AcuYiBJUqQAqKBP+aQIqr2u/PL4XUjLLUCo
|
|
8
|
-
ZituhZhvWAMTgFjyc8crOSp3V4zveIQdOTWnJBUp49lgzS1ho4iwxxxfLNsEWo/d
|
|
9
|
-
te98I0ac0kX9dNbtW8xlPwyfaH6ZPKlMlMUdxVkEnEZLnkAx+WoVfc2XH3naLN1F
|
|
10
|
-
bZDCZyxOV/mfdqlZHXqidFMfRK3A3XK7iRNfowUZnj6Cgl9aP7jKQJpUVq1SUVGX
|
|
11
|
-
ZWSMvBrFdizekgXfKnpS5Ha+Sk9bMOSQNo5k70+yLXPhzspYIY3MH8cMZM7EnTMC
|
|
12
|
-
AwEAAaNTMFEwHQYDVR0OBBYEFIyUOMXBKUb/mFU7vYBSgNMGUJWeMB8GA1UdIwQY
|
|
13
|
-
MBaAFIyUOMXBKUb/mFU7vYBSgNMGUJWeMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZI
|
|
14
|
-
hvcNAQELBQADggEBAIHEMxHzdmaqAT2FaEB/KmNAqWIC31huZrVIdRyXS51Dbtnv
|
|
15
|
-
a77YuwXgNmnKmk5/M9feE7mVu+bOAwusNdO9yHuFeuwLuFD4dK/Dx6jNAjeOC+jM
|
|
16
|
-
EIXUK8cNdlnAhhmhs/ni1uxol0RSWz+5+1Vo7M5JgOs182oLSZu5uFKbCbfgijy2
|
|
17
|
-
77nrNbTK79lq3nLnf1b103yRFkbTKphVdLY+QZGuBtGmoFoCDif3dwcTcPhCO6Sw
|
|
18
|
-
HFxLKlqXtwrhY7r/VK4+Q83gQIZUkCY59RWRtG9TI8swauRfP0mGSoDlKVd+HiOY
|
|
19
|
-
bNAA5cGXYqNgpYHaCiPkTBzwU4UroWtRasyDwXs=
|
|
20
|
-
-----END CERTIFICATE-----
|
package/example/certs/key.pem
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
-----BEGIN RSA PRIVATE KEY-----
|
|
2
|
-
MIIEpAIBAAKCAQEAv6NVAnYZvIM5az4pnQyXHV8T3ze9BBWhCluH9POqjg00ZkcY
|
|
3
|
-
RAX4By5iIElSpACooE/5pAiqva788vhdSMstQKhmK26FmG9YAxOAWPJzxys5KndX
|
|
4
|
-
jO94hB05NackFSnj2WDNLWGjiLDHHF8s2wRaj92173wjRpzSRf101u1bzGU/DJ9o
|
|
5
|
-
fpk8qUyUxR3FWQScRkueQDH5ahV9zZcfedos3UVtkMJnLE5X+Z92qVkdeqJ0Ux9E
|
|
6
|
-
rcDdcruJE1+jBRmePoKCX1o/uMpAmlRWrVJRUZdlZIy8GsV2LN6SBd8qelLkdr5K
|
|
7
|
-
T1sw5JA2jmTvT7Itc+HOylghjcwfxwxkzsSdMwIDAQABAoIBAQCZDSRWq+XQFemk
|
|
8
|
-
yefIQwbpcUbYrpZqDbApKoMB0h10B/3CdaNeqHm3mobKDGVRECmcp2LUbAuZJIlm
|
|
9
|
-
r48pFQPWMOgwZbuSy9I52rhV0YVAGzgzv06QA613rjNDs3Jw6JzNvq7/QIywHadX
|
|
10
|
-
9HdJkEeXwNWOJ9GwkoypU0yeXsFDEnEGSDdeHCBDoxzxyqZJ2DHHj9f6oZrIq6sg
|
|
11
|
-
8f9QBziu4y6IDDfhqynScN7nD3JEiyyd8k6Poh0EMo6zdLXeNbDKKP3FA4BuJVkg
|
|
12
|
-
aSUQFkh2YqJnaxB/cwHdQfZT2Znku4MbKPZ9c6BwVgoU4TI9eUjJ8g5UZXu42mW8
|
|
13
|
-
sgd1XmKJAoGBAPonc7/eI/c4vkwAd83lUsq3stoU9fB+oUcTA/cgIuq+jWHOLSW6
|
|
14
|
-
3etWICBXMyN+OoAsEP3y815JItlvypYsN2CJgoR8VbYmeMRaDOpTGQYCnjEArjPB
|
|
15
|
-
QACD12/IamWj+ifAx/lyD8v60rhALW+5usj/P1SiNwCN5wLZUQGxs5p/AoGBAMQd
|
|
16
|
-
zqNvkzKNQR21TqWqw9L/BK8CEag7qMiETvxNTMSTwuRi6o4ZscBIGcnbRBL6oiQl
|
|
17
|
-
uw2qqfwgR/mqDQ8kN5bMIW6PkOvzb2W77VfkaZrVOyQr2a5f7lN5ypmOl+R3PTTc
|
|
18
|
-
IZfa9f9wiK7kpeSDZcazN0AX6+oJqWaXcjAKLFtNAoGBAMpK+Tnh5GfaRVmkzz18
|
|
19
|
-
A9XXdBUT+kc/wCB/6icAn/wBmMfNOYlXcnsLrPM6USqUu65G9H7I57IJptr7onKK
|
|
20
|
-
00WILjoBajbhKaxvvh4IkSXhHBg4mqdT0fQYqjHFevUzA+r95Tl92fR0o89IZvYA
|
|
21
|
-
1mIQuCAzBhO2rWgKYY3jLID1AoGAW5JzbxrlB2Cve/ixnWdsAnRzMmhr6DrbJ62n
|
|
22
|
-
1+UcKFm6UbviO7HBrr+70uYgFiCTXv+DJPGAZ6qHEQuXB2/oyO/N2HsOty224TDr
|
|
23
|
-
tPOBX/uantwey24dsTqYIDVVtSb8HFeBFA/4d2qLV+aJk3bLKgl6jeHdlS0nvTCP
|
|
24
|
-
7+CAL60CgYBBjyUkX3Ok1k25caoiPWwALnzqEyj5yje2qFyV+2HODDFmkJtJ2nZW
|
|
25
|
-
omUzfuugp5jPFt51EBj0nQsRV6y/3LUjmFx0ER3f9juyyVq33OlRRkzFZv6Tq3YE
|
|
26
|
-
cmEZlNonQBPP/sGQGNas28NZLUzt3/8VDVcTRgpn5Q4O8vbaOJJpRg==
|
|
27
|
-
-----END RSA PRIVATE KEY-----
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { HightConfig, HightConfigFunction } from 'hightjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* HightJS Configuration File
|
|
5
|
-
*
|
|
6
|
-
* This file allows you to customize server settings for your HightJS application.
|
|
7
|
-
* You can export either a static configuration object or a function that returns the configuration.
|
|
8
|
-
*
|
|
9
|
-
* In a real project, you would import from 'hightjs' instead:
|
|
10
|
-
* import type { HightConfig, HightConfigFunction } from 'hightjs';
|
|
11
|
-
*/
|
|
12
|
-
const hightConfig: HightConfigFunction = (phase, { defaultConfig }) => {
|
|
13
|
-
const config: HightConfig = {
|
|
14
|
-
/**
|
|
15
|
-
* Maximum number of HTTP headers allowed per request
|
|
16
|
-
* Default: 100
|
|
17
|
-
* Increase this if you need to support requests with many headers
|
|
18
|
-
*/
|
|
19
|
-
maxHeadersCount: 100,
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Timeout in milliseconds for receiving HTTP headers
|
|
23
|
-
* Default: 60000 (60 seconds)
|
|
24
|
-
*/
|
|
25
|
-
headersTimeout: 60000,
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Timeout in milliseconds for a complete request
|
|
29
|
-
* Default: 30000 (30 seconds)
|
|
30
|
-
*/
|
|
31
|
-
requestTimeout: 30000,
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* General server timeout in milliseconds
|
|
35
|
-
* Default: 35000 (35 seconds)
|
|
36
|
-
*/
|
|
37
|
-
serverTimeout: 35000,
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Timeout per individual request in milliseconds
|
|
41
|
-
* Default: 30000 (30 seconds)
|
|
42
|
-
*/
|
|
43
|
-
individualRequestTimeout: 30000,
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Maximum URL length in characters
|
|
47
|
-
* Default: 2048
|
|
48
|
-
*/
|
|
49
|
-
maxUrlLength: 2048,
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Enable HTTP access logging (e.g., GET /api/users 200 15ms)
|
|
53
|
-
* Default: false
|
|
54
|
-
*/
|
|
55
|
-
accessLogging: true,
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// You can customize settings based on the phase
|
|
59
|
-
if (phase === 'development') {
|
|
60
|
-
// In development, you might want longer timeouts for debugging
|
|
61
|
-
config.requestTimeout = 60000;
|
|
62
|
-
config.individualRequestTimeout = 60000;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (phase === 'production') {
|
|
66
|
-
// In production, you might want stricter limits
|
|
67
|
-
config.maxHeadersCount = 50;
|
|
68
|
-
config.maxUrlLength = 1024;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return config;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export default hightConfig;
|
|
75
|
-
|
|
76
|
-
// You can also export a static object instead of a function:
|
|
77
|
-
// const staticConfig: HightConfig = {
|
|
78
|
-
// maxHeadersCount: 100,
|
|
79
|
-
// headersTimeout: 60000,
|
|
80
|
-
// requestTimeout: 30000,
|
|
81
|
-
// serverTimeout: 35000,
|
|
82
|
-
// individualRequestTimeout: 30000,
|
|
83
|
-
// maxUrlLength: 2048,
|
|
84
|
-
// };
|
|
85
|
-
//
|
|
86
|
-
// export default staticConfig;
|
|
87
|
-
|