hightjs 0.5.3 → 0.5.4
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/dist/adapters/express.d.ts +7 -0
- package/dist/adapters/express.js +63 -0
- package/dist/adapters/factory.d.ts +23 -0
- package/dist/adapters/factory.js +122 -0
- package/dist/adapters/fastify.d.ts +25 -0
- package/dist/adapters/fastify.js +61 -0
- package/dist/adapters/native.d.ts +8 -0
- package/dist/adapters/native.js +198 -0
- package/dist/api/console.d.ts +94 -0
- package/dist/api/console.js +294 -0
- package/dist/api/http.d.ts +180 -0
- package/dist/api/http.js +469 -0
- package/dist/bin/hightjs.d.ts +2 -0
- package/dist/bin/hightjs.js +214 -0
- package/dist/builder.d.ts +32 -0
- package/dist/builder.js +581 -0
- package/dist/client/DefaultNotFound.d.ts +1 -0
- package/dist/client/DefaultNotFound.js +79 -0
- package/dist/client/client.d.ts +3 -0
- package/dist/client/client.js +24 -0
- package/dist/client/clientRouter.d.ts +58 -0
- package/dist/client/clientRouter.js +132 -0
- package/dist/client/entry.client.d.ts +1 -0
- package/dist/client/entry.client.js +455 -0
- package/dist/components/Link.d.ts +7 -0
- package/dist/components/Link.js +13 -0
- package/dist/global/global.d.ts +117 -0
- package/dist/global/global.js +17 -0
- package/dist/helpers.d.ts +20 -0
- package/dist/helpers.js +583 -0
- package/dist/hotReload.d.ts +32 -0
- package/dist/hotReload.js +545 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +494 -0
- package/dist/loaders.d.ts +1 -0
- package/dist/loaders.js +46 -0
- package/dist/renderer.d.ts +14 -0
- package/dist/renderer.js +380 -0
- package/dist/router.d.ts +101 -0
- package/dist/router.js +659 -0
- package/dist/types/framework.d.ts +37 -0
- package/dist/types/framework.js +2 -0
- package/dist/types.d.ts +192 -0
- package/dist/types.js +2 -0
- package/package.json +1 -1
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { GenericRequest } from './types/framework';
|
|
3
|
+
import { HightJSRequest, HightJSResponse } from "./api/http";
|
|
4
|
+
import { WebSocket } from 'ws';
|
|
5
|
+
import { IncomingMessage } from 'http';
|
|
6
|
+
export interface WebSocketContext {
|
|
7
|
+
ws: WebSocket;
|
|
8
|
+
req: IncomingMessage;
|
|
9
|
+
hightReq: HightJSRequest;
|
|
10
|
+
url: URL;
|
|
11
|
+
params: Record<string, string>;
|
|
12
|
+
query: Record<string, string>;
|
|
13
|
+
send: (data: any) => void;
|
|
14
|
+
close: (code?: number, reason?: string) => void;
|
|
15
|
+
broadcast: (data: any, exclude?: WebSocket[]) => void;
|
|
16
|
+
}
|
|
17
|
+
export interface HightJSOptions {
|
|
18
|
+
dev?: boolean;
|
|
19
|
+
hostname?: string;
|
|
20
|
+
port?: number;
|
|
21
|
+
dir?: string;
|
|
22
|
+
framework?: 'express' | 'fastify' | 'native';
|
|
23
|
+
ssl?: {
|
|
24
|
+
redirectPort: number;
|
|
25
|
+
key: string;
|
|
26
|
+
cert: string;
|
|
27
|
+
ca?: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Interface para as configurações avançadas do servidor HightJS.
|
|
32
|
+
* Essas configurações podem ser definidas no arquivo hightjs.config.js
|
|
33
|
+
*/
|
|
34
|
+
export interface HightConfig {
|
|
35
|
+
/**
|
|
36
|
+
* Limita o número máximo de headers HTTP permitidos por requisição.
|
|
37
|
+
* Padrão: 100
|
|
38
|
+
*/
|
|
39
|
+
maxHeadersCount?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Timeout em milissegundos para receber os headers HTTP.
|
|
42
|
+
* Padrão: 60000 (60 segundos)
|
|
43
|
+
*/
|
|
44
|
+
headersTimeout?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Timeout em milissegundos para uma requisição completa.
|
|
47
|
+
* Padrão: 30000 (30 segundos)
|
|
48
|
+
*/
|
|
49
|
+
requestTimeout?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Timeout geral do servidor em milissegundos.
|
|
52
|
+
* Padrão: 35000 (35 segundos)
|
|
53
|
+
*/
|
|
54
|
+
serverTimeout?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Timeout por requisição individual em milissegundos.
|
|
57
|
+
* Padrão: 30000 (30 segundos)
|
|
58
|
+
*/
|
|
59
|
+
individualRequestTimeout?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Tamanho máximo permitido para a URL em caracteres.
|
|
62
|
+
* Padrão: 2048
|
|
63
|
+
*/
|
|
64
|
+
maxUrlLength?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Habilita o log de acesso HTTP (ex: GET /api/users 200 15ms).
|
|
67
|
+
* Padrão: false
|
|
68
|
+
*/
|
|
69
|
+
accessLogging?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Configurações de CORS (Cross-Origin Resource Sharing).
|
|
72
|
+
* Define quais origens podem acessar seus recursos.
|
|
73
|
+
*/
|
|
74
|
+
cors?: {
|
|
75
|
+
/**
|
|
76
|
+
* Origens permitidas. Pode ser:
|
|
77
|
+
* - Uma string específica: 'https://exemplo.com'
|
|
78
|
+
* - Um array de strings: ['https://exemplo.com', 'https://outro.com']
|
|
79
|
+
* - Um wildcard: '*' (permite todas as origens - não recomendado em produção)
|
|
80
|
+
* - Uma função que retorna boolean: (origin) => origin.endsWith('.exemplo.com')
|
|
81
|
+
*/
|
|
82
|
+
origin?: string | string[] | ((origin: string) => boolean);
|
|
83
|
+
/**
|
|
84
|
+
* Métodos HTTP permitidos.
|
|
85
|
+
* Padrão: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS']
|
|
86
|
+
*/
|
|
87
|
+
methods?: string[];
|
|
88
|
+
/**
|
|
89
|
+
* Headers permitidos nas requisições.
|
|
90
|
+
* Padrão: ['Content-Type', 'Authorization']
|
|
91
|
+
*/
|
|
92
|
+
allowedHeaders?: string[];
|
|
93
|
+
/**
|
|
94
|
+
* Headers que serão expostos ao cliente.
|
|
95
|
+
* Padrão: []
|
|
96
|
+
*/
|
|
97
|
+
exposedHeaders?: string[];
|
|
98
|
+
/**
|
|
99
|
+
* Permite o envio de credenciais (cookies, headers de autenticação).
|
|
100
|
+
* Padrão: false
|
|
101
|
+
*/
|
|
102
|
+
credentials?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Tempo em segundos que o navegador deve cachear a resposta preflight.
|
|
105
|
+
* Padrão: 86400 (24 horas)
|
|
106
|
+
*/
|
|
107
|
+
maxAge?: number;
|
|
108
|
+
/**
|
|
109
|
+
* Habilita ou desabilita completamente o CORS.
|
|
110
|
+
* Padrão: false
|
|
111
|
+
*/
|
|
112
|
+
enabled?: boolean;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Tipo da função de configuração que pode ser exportada no hightjs.config.js
|
|
117
|
+
*/
|
|
118
|
+
export type HightConfigFunction = (phase: string, context: {
|
|
119
|
+
defaultConfig: HightConfig;
|
|
120
|
+
}) => HightConfig | Promise<HightConfig>;
|
|
121
|
+
export interface Metadata {
|
|
122
|
+
title?: string;
|
|
123
|
+
description?: string;
|
|
124
|
+
keywords?: string | string[];
|
|
125
|
+
author?: string;
|
|
126
|
+
favicon?: string;
|
|
127
|
+
viewport?: string;
|
|
128
|
+
themeColor?: string;
|
|
129
|
+
canonical?: string;
|
|
130
|
+
robots?: string;
|
|
131
|
+
openGraph?: {
|
|
132
|
+
title?: string;
|
|
133
|
+
description?: string;
|
|
134
|
+
type?: string;
|
|
135
|
+
url?: string;
|
|
136
|
+
image?: string | {
|
|
137
|
+
url: string;
|
|
138
|
+
width?: number;
|
|
139
|
+
height?: number;
|
|
140
|
+
alt?: string;
|
|
141
|
+
};
|
|
142
|
+
siteName?: string;
|
|
143
|
+
locale?: string;
|
|
144
|
+
};
|
|
145
|
+
twitter?: {
|
|
146
|
+
card?: 'summary' | 'summary_large_image' | 'app' | 'player';
|
|
147
|
+
site?: string;
|
|
148
|
+
creator?: string;
|
|
149
|
+
title?: string;
|
|
150
|
+
description?: string;
|
|
151
|
+
image?: string;
|
|
152
|
+
imageAlt?: string;
|
|
153
|
+
};
|
|
154
|
+
language?: string;
|
|
155
|
+
charset?: string;
|
|
156
|
+
appleTouchIcon?: string;
|
|
157
|
+
manifest?: string;
|
|
158
|
+
other?: Record<string, string>;
|
|
159
|
+
}
|
|
160
|
+
export interface RouteConfig {
|
|
161
|
+
pattern: string;
|
|
162
|
+
component: ComponentType<any>;
|
|
163
|
+
generateMetadata?: (params: any, req: GenericRequest) => Promise<Metadata> | Metadata;
|
|
164
|
+
}
|
|
165
|
+
export type RequestHandler = (req: any, res: any) => Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Define o formato de uma função que manipula uma rota da API.
|
|
168
|
+
*/
|
|
169
|
+
export type BackendHandler = (request: HightJSRequest, // HWebRequest será importado onde necessário
|
|
170
|
+
params: {
|
|
171
|
+
[key: string]: string;
|
|
172
|
+
}) => Promise<HightJSResponse> | HightJSResponse;
|
|
173
|
+
export type HightMiddleware = (request: HightJSRequest, // HWebRequest será importado onde necessário
|
|
174
|
+
params: {
|
|
175
|
+
[key: string]: string;
|
|
176
|
+
}, next: () => Promise<HightJSResponse>) => Promise<HightJSResponse> | HightJSResponse;
|
|
177
|
+
/**
|
|
178
|
+
* Define o formato de uma função que manipula uma rota WebSocket.
|
|
179
|
+
*/
|
|
180
|
+
export type WebSocketHandler = (context: WebSocketContext) => Promise<void> | void;
|
|
181
|
+
/**
|
|
182
|
+
* Define a estrutura de cada rota da API, com suporte para métodos HTTP e WebSocket.
|
|
183
|
+
*/
|
|
184
|
+
export interface BackendRouteConfig {
|
|
185
|
+
pattern: string;
|
|
186
|
+
GET?: BackendHandler;
|
|
187
|
+
POST?: BackendHandler;
|
|
188
|
+
PUT?: BackendHandler;
|
|
189
|
+
DELETE?: BackendHandler;
|
|
190
|
+
WS?: WebSocketHandler;
|
|
191
|
+
middleware?: HightMiddleware[];
|
|
192
|
+
}
|
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hightjs",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "HightJS is a high-level framework for building web applications with ease and speed. It provides a robust set of tools and features to streamline development and enhance productivity.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|