hightjs 0.2.52 → 0.3.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/dist/adapters/express.js +1 -1
- package/dist/api/console.d.ts +6 -4
- package/dist/api/console.js +27 -9
- package/dist/auth/components.js +16 -0
- package/dist/auth/core.js +16 -0
- package/dist/auth/index.js +16 -0
- package/dist/auth/jwt.js +16 -0
- package/dist/auth/providers/index.js +16 -0
- package/dist/auth/providers.js +16 -0
- package/dist/auth/react/index.js +16 -0
- package/dist/auth/react.js +16 -0
- package/dist/auth/routes.js +16 -0
- package/dist/auth/types.js +16 -0
- package/dist/bin/hightjs.js +68 -11
- package/dist/builder.js +16 -0
- package/dist/client/clientRouter.js +16 -0
- package/dist/client/entry.client.js +16 -0
- package/dist/client.js +16 -0
- package/dist/helpers.d.ts +7 -6
- package/dist/helpers.js +284 -198
- package/dist/hotReload.js +23 -7
- package/dist/index.js +49 -25
- package/dist/router.js +16 -0
- package/dist/types.d.ts +6 -0
- package/docs/cli.md +4 -5
- package/package.json +1 -1
- package/src/adapters/express.ts +18 -1
- package/src/adapters/factory.ts +16 -0
- package/src/adapters/fastify.ts +16 -0
- package/src/adapters/native.ts +16 -0
- package/src/api/console.ts +28 -10
- package/src/api/http.ts +16 -0
- package/src/auth/client.ts +16 -0
- package/src/auth/components.tsx +16 -0
- package/src/auth/core.ts +16 -0
- package/src/auth/index.ts +16 -0
- package/src/auth/jwt.ts +16 -0
- package/src/auth/providers/credentials.ts +16 -0
- package/src/auth/providers/discord.ts +16 -0
- package/src/auth/providers/google.ts +16 -0
- package/src/auth/providers/index.ts +16 -0
- package/src/auth/providers.ts +16 -0
- package/src/auth/react/index.ts +16 -0
- package/src/auth/react.tsx +16 -0
- package/src/auth/routes.ts +17 -0
- package/src/auth/types.ts +17 -0
- package/src/bin/hightjs.js +79 -11
- package/src/builder.js +16 -0
- package/src/client/DefaultNotFound.tsx +16 -0
- package/src/client/clientRouter.ts +16 -0
- package/src/client/entry.client.tsx +16 -0
- package/src/client.ts +16 -0
- package/src/components/Link.tsx +16 -0
- package/src/helpers.ts +327 -215
- package/src/hotReload.ts +24 -8
- package/src/index.ts +54 -25
- package/src/renderer.tsx +16 -0
- package/src/router.ts +16 -0
- package/src/types/framework.ts +16 -0
- package/src/types.ts +22 -0
package/dist/index.js
CHANGED
|
@@ -38,6 +38,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.app = exports.FrameworkAdapterFactory = exports.FastifyAdapter = exports.ExpressAdapter = exports.HightJSResponse = exports.HightJSRequest = void 0;
|
|
40
40
|
exports.default = hweb;
|
|
41
|
+
/*
|
|
42
|
+
* This file is part of the HightJS Project.
|
|
43
|
+
* Copyright (c) 2025 itsmuzin
|
|
44
|
+
*
|
|
45
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
46
|
+
* you may not use this file except in compliance with the License.
|
|
47
|
+
* You may obtain a copy of the License at
|
|
48
|
+
*
|
|
49
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
50
|
+
*
|
|
51
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
52
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
53
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
54
|
+
* See the License for the specific language governing permissions and
|
|
55
|
+
* limitations under the License.
|
|
56
|
+
*/
|
|
41
57
|
const path_1 = __importDefault(require("path"));
|
|
42
58
|
const fs_1 = __importDefault(require("fs"));
|
|
43
59
|
const express_1 = require("./adapters/express");
|
|
@@ -163,6 +179,8 @@ import '${relativeEntryPath}';
|
|
|
163
179
|
}
|
|
164
180
|
function hweb(options) {
|
|
165
181
|
const { dev = true, dir = process.cwd(), port = 3000 } = options;
|
|
182
|
+
// @ts-ignore
|
|
183
|
+
process.hight = options;
|
|
166
184
|
const userWebDir = path_1.default.join(dir, 'src', 'web');
|
|
167
185
|
const userWebRoutesDir = path_1.default.join(userWebDir, 'routes');
|
|
168
186
|
const userBackendRoutesDir = path_1.default.join(userWebDir, 'backend', 'routes');
|
|
@@ -175,8 +193,6 @@ function hweb(options) {
|
|
|
175
193
|
* @returns Resposta do middleware ou handler final
|
|
176
194
|
*/
|
|
177
195
|
async function executeMiddlewareChain(middlewares, finalHandler, request, params) {
|
|
178
|
-
// @ts-ignore
|
|
179
|
-
process.hight = options;
|
|
180
196
|
if (!middlewares || middlewares.length === 0) {
|
|
181
197
|
// Não há middlewares, executa diretamente o handler final
|
|
182
198
|
return await finalHandler(request, params);
|
|
@@ -230,6 +246,15 @@ function hweb(options) {
|
|
|
230
246
|
regenerateEntryFile();
|
|
231
247
|
});
|
|
232
248
|
}
|
|
249
|
+
const now = Date.now();
|
|
250
|
+
const timee = console_1.default.dynamicLine(` ${console_1.Colors.BgYellow} router ${console_1.Colors.Reset} Carregando rotas e componentes do frontend e backend`);
|
|
251
|
+
const spinnerFrames1 = ['|', '/', '-', '\\'];
|
|
252
|
+
let frameIndex1 = 0;
|
|
253
|
+
const spinner1 = setInterval(() => {
|
|
254
|
+
console_1.default.info('aaaa');
|
|
255
|
+
timee.update(` ${console_1.Colors.FgYellow}${spinnerFrames1[frameIndex1]}${console_1.Colors.Reset} Carregando rotas e componentes...`);
|
|
256
|
+
frameIndex1 = (frameIndex1 + 1) % spinnerFrames1.length;
|
|
257
|
+
}, 100); // muda a cada 100ms
|
|
233
258
|
// ORDEM IMPORTANTE: Carrega TUDO antes de criar o arquivo de entrada
|
|
234
259
|
frontendRoutes = (0, router_1.loadRoutes)(userWebRoutesDir);
|
|
235
260
|
(0, router_1.loadBackendRoutes)(userBackendRoutesDir);
|
|
@@ -241,31 +266,30 @@ function hweb(options) {
|
|
|
241
266
|
const outDir = path_1.default.join(dir, 'hweb-dist');
|
|
242
267
|
fs_1.default.mkdirSync(outDir, { recursive: true });
|
|
243
268
|
entryPoint = createEntryFile(dir, frontendRoutes);
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
if (
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
269
|
+
clearInterval(spinner1);
|
|
270
|
+
timee.end(` ${console_1.Colors.BgGreen} router ${console_1.Colors.Reset} Rotas e componentes carregados em ${Date.now() - now}ms`);
|
|
271
|
+
if (isProduction) {
|
|
272
|
+
const time = console_1.default.dynamicLine(` ${console_1.Colors.BgYellow} build ${console_1.Colors.Reset} Iniciando build do cliente para produção`);
|
|
273
|
+
// Spinner
|
|
274
|
+
const spinnerFrames = ['|', '/', '-', '\\'];
|
|
275
|
+
let frameIndex = 0;
|
|
276
|
+
const spinner = setInterval(() => {
|
|
277
|
+
time.update(` ${console_1.Colors.FgYellow}${spinnerFrames[frameIndex]}${console_1.Colors.Reset} Buildando para produção...`);
|
|
278
|
+
frameIndex = (frameIndex + 1) % spinnerFrames.length;
|
|
279
|
+
}, 100); // muda a cada 100ms
|
|
280
|
+
const now = Date.now();
|
|
281
|
+
await (0, builder_1.buildWithChunks)(entryPoint, outDir, isProduction);
|
|
282
|
+
const elapsed = Date.now() - now;
|
|
283
|
+
clearInterval(spinner); // para o spinner
|
|
284
|
+
time.update(""); // limpa a linha
|
|
285
|
+
time.end(` ${console_1.Colors.BgGreen} build ${console_1.Colors.Reset} Build do cliente concluído em ${elapsed}ms`);
|
|
258
286
|
}
|
|
259
287
|
else {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
(0, builder_1.watch)(entryPoint, outfile, hotReloadManager).catch(err => {
|
|
266
|
-
console_1.default.error(`Erro ao iniciar o watch`, err);
|
|
267
|
-
});
|
|
268
|
-
}
|
|
288
|
+
const time = console_1.default.dynamicLine(` ${console_1.Colors.BgYellow} watcher ${console_1.Colors.Reset} Iniciando watch do cliente`);
|
|
289
|
+
(0, builder_1.watchWithChunks)(entryPoint, outDir, hotReloadManager).catch(err => {
|
|
290
|
+
console_1.default.error(`Erro ao iniciar o watch`, err);
|
|
291
|
+
});
|
|
292
|
+
time.end(` ${console_1.Colors.BgGreen} watcher ${console_1.Colors.Reset} Watch do cliente iniciado`);
|
|
269
293
|
}
|
|
270
294
|
},
|
|
271
295
|
executeInstrumentation: () => {
|
package/dist/router.js
CHANGED
|
@@ -16,6 +16,22 @@ exports.getNotFound = getNotFound;
|
|
|
16
16
|
exports.processWebSocketRoutes = processWebSocketRoutes;
|
|
17
17
|
exports.findMatchingWebSocketRoute = findMatchingWebSocketRoute;
|
|
18
18
|
exports.setupWebSocketUpgrade = setupWebSocketUpgrade;
|
|
19
|
+
/*
|
|
20
|
+
* This file is part of the HightJS Project.
|
|
21
|
+
* Copyright (c) 2025 itsmuzin
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
24
|
+
* you may not use this file except in compliance with the License.
|
|
25
|
+
* You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
19
35
|
const fs_1 = __importDefault(require("fs"));
|
|
20
36
|
const path_1 = __importDefault(require("path"));
|
|
21
37
|
const ws_1 = require("ws");
|
package/dist/types.d.ts
CHANGED
|
@@ -20,6 +20,12 @@ export interface HightJSOptions {
|
|
|
20
20
|
port?: number;
|
|
21
21
|
dir?: string;
|
|
22
22
|
framework?: 'express' | 'fastify' | 'native';
|
|
23
|
+
ssl?: {
|
|
24
|
+
redirectPort: number;
|
|
25
|
+
key: string;
|
|
26
|
+
cert: string;
|
|
27
|
+
ca?: string;
|
|
28
|
+
};
|
|
23
29
|
}
|
|
24
30
|
export interface Metadata {
|
|
25
31
|
title?: string;
|
package/docs/cli.md
CHANGED
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Comandos principais:
|
|
4
4
|
|
|
5
|
-
| Comando
|
|
6
|
-
|
|
7
|
-
| `npx hight dev`
|
|
8
|
-
| `npx hight start`
|
|
5
|
+
| Comando | Descrição |
|
|
6
|
+
|-------------------|----------------------|
|
|
7
|
+
| `npx hight dev` | Modo desenvolvimento |
|
|
8
|
+
| `npx hight start` | Modo produção |
|
|
9
9
|
|
|
10
10
|
## Opções
|
|
11
11
|
|
|
12
12
|
- `--port` Porta (default 3000)
|
|
13
13
|
- `--hostname` Host (default 0.0.0.0)
|
|
14
|
-
- `--framework` `native` | `express` | `fastify` (default: native)
|
|
15
14
|
|
|
16
15
|
## Produção
|
|
17
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hightjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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",
|
package/src/adapters/express.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
import type { Request as ExpressRequest, Response as ExpressResponse } from 'express';
|
|
2
18
|
import { GenericRequest, GenericResponse, FrameworkAdapter, CookieOptions } from '../types/framework';
|
|
3
19
|
|
|
@@ -5,6 +21,7 @@ export class ExpressAdapter implements FrameworkAdapter {
|
|
|
5
21
|
type = 'express' as const;
|
|
6
22
|
|
|
7
23
|
parseRequest(req: ExpressRequest): GenericRequest {
|
|
24
|
+
|
|
8
25
|
return {
|
|
9
26
|
method: req.method,
|
|
10
27
|
url: req.url,
|
|
@@ -13,7 +30,7 @@ export class ExpressAdapter implements FrameworkAdapter {
|
|
|
13
30
|
query: req.query as Record<string, any>,
|
|
14
31
|
params: req.params,
|
|
15
32
|
cookies: req.cookies || {},
|
|
16
|
-
raw: req
|
|
33
|
+
raw: req,
|
|
17
34
|
};
|
|
18
35
|
}
|
|
19
36
|
|
package/src/adapters/factory.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
import { FrameworkAdapter } from '../types/framework';
|
|
2
18
|
import { ExpressAdapter } from './express';
|
|
3
19
|
import { FastifyAdapter } from './fastify';
|
package/src/adapters/fastify.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
// Tipos para Fastify (sem import direto para evitar dependência obrigatória)
|
|
2
18
|
interface FastifyRequest {
|
|
3
19
|
method: string;
|
package/src/adapters/native.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
import type { IncomingMessage, ServerResponse } from 'http';
|
|
2
18
|
import { GenericRequest, GenericResponse, FrameworkAdapter, CookieOptions } from '../types/framework';
|
|
3
19
|
import { parse as parseUrl } from 'url';
|
package/src/api/console.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
import boxen, { Options as BoxenOptions } from 'boxen';
|
|
2
18
|
import readline from 'node:readline';
|
|
3
19
|
|
|
@@ -32,7 +48,6 @@ export class DynamicLine {
|
|
|
32
48
|
}
|
|
33
49
|
}
|
|
34
50
|
|
|
35
|
-
|
|
36
51
|
export enum Colors {
|
|
37
52
|
Reset = "\x1b[0m",
|
|
38
53
|
Bright = "\x1b[1m",
|
|
@@ -50,6 +65,7 @@ export enum Colors {
|
|
|
50
65
|
FgMagenta = "\x1b[35m",
|
|
51
66
|
FgCyan = "\x1b[36m",
|
|
52
67
|
FgWhite = "\x1b[37m",
|
|
68
|
+
FgGray = "\x1b[90m", // ← adicionado
|
|
53
69
|
|
|
54
70
|
BgBlack = "\x1b[40m",
|
|
55
71
|
BgRed = "\x1b[41m",
|
|
@@ -59,8 +75,10 @@ export enum Colors {
|
|
|
59
75
|
BgMagenta = "\x1b[45m",
|
|
60
76
|
BgCyan = "\x1b[46m",
|
|
61
77
|
BgWhite = "\x1b[47m",
|
|
78
|
+
BgGray = "\x1b[100m", // ← adicionado
|
|
62
79
|
}
|
|
63
80
|
|
|
81
|
+
|
|
64
82
|
export enum Levels {
|
|
65
83
|
ERROR = "ERROR",
|
|
66
84
|
WARN = "WARN",
|
|
@@ -178,27 +196,27 @@ export default class Console {
|
|
|
178
196
|
static success(...args: any[]): void { this.log(Levels.SUCCESS, ...args); }
|
|
179
197
|
static debug(...args: any[]): void { this.log(Levels.DEBUG, ...args); }
|
|
180
198
|
|
|
181
|
-
static logCustomLevel(levelName: string, without: boolean = true, ...args: any[]): void {
|
|
182
|
-
if (without) { this.logWithout(levelName as Levels, ...args); }
|
|
183
|
-
else { this.log(levelName as Levels, ...args); }
|
|
199
|
+
static logCustomLevel(levelName: string, without: boolean = true, color?: Colors, ...args: any[]): void {
|
|
200
|
+
if (without) { this.logWithout(levelName as Levels, color, ...args); }
|
|
201
|
+
else { this.log(levelName as Levels, color, ...args); }
|
|
184
202
|
}
|
|
185
203
|
|
|
186
|
-
static logWithout(level: Levels, ...args: any[]): void {
|
|
187
|
-
const color = level === Levels.ERROR ? Colors.
|
|
204
|
+
static logWithout(level: Levels, colors?:Colors, ...args: any[]): void {
|
|
205
|
+
const color = colors || level === Levels.ERROR ? Colors.BgRed : level === Levels.WARN ? Colors.BgYellow : level === Levels.INFO ? Colors.BgMagenta : level === Levels.SUCCESS ? Colors.BgGreen : Colors.BgCyan;
|
|
188
206
|
let output = "";
|
|
189
207
|
for (const arg of args) {
|
|
190
208
|
let msg = (arg instanceof Error) ? arg.stack : (typeof arg === 'string') ? arg : JSON.stringify(arg, null, 2);
|
|
191
|
-
if (msg) output += ` ${color}${level}
|
|
209
|
+
if (msg) output += ` ${color} ${level} ${Colors.Reset} ${msg}\n`;
|
|
192
210
|
}
|
|
193
211
|
this.writeStatic(output);
|
|
194
212
|
}
|
|
195
213
|
|
|
196
|
-
static log(level: Levels, ...args: any[]): void {
|
|
197
|
-
const color = level === Levels.ERROR ? Colors.
|
|
214
|
+
static log(level: Levels, colors?: Colors, ...args: any[]): void {
|
|
215
|
+
const color = colors || level === Levels.ERROR ? Colors.BgRed : level === Levels.WARN ? Colors.BgYellow : level === Levels.INFO ? Colors.BgMagenta : level === Levels.SUCCESS ? Colors.BgGreen : Colors.BgCyan;
|
|
198
216
|
let output = "\n";
|
|
199
217
|
for (const arg of args) {
|
|
200
218
|
let msg = (arg instanceof Error) ? arg.stack : (typeof arg === 'string') ? arg : JSON.stringify(arg, null, 2);
|
|
201
|
-
if (msg) output += ` ${color}${level}
|
|
219
|
+
if (msg) output += ` ${color} ${level} ${Colors.Reset} ${msg}\n`;
|
|
202
220
|
}
|
|
203
221
|
this.writeStatic(output);
|
|
204
222
|
}
|
package/src/api/http.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
import { GenericRequest, GenericResponse, CookieOptions } from '../types/framework';
|
|
2
18
|
|
|
3
19
|
// Input validation and sanitization utilities
|
package/src/auth/client.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
import type { SignInOptions, SignInResult, Session } from './types';
|
|
2
18
|
// Configuração global do client
|
|
3
19
|
let basePath = '/api/auth';
|
package/src/auth/components.tsx
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
import React, { ReactNode } from 'react';
|
|
2
18
|
import { useAuth } from './react';
|
|
3
19
|
import { router } from '../client/clientRouter';
|
package/src/auth/core.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
import { HightJSRequest, HightJSResponse } from '../api/http';
|
|
2
18
|
import type { AuthConfig, AuthProviderClass, User, Session } from './types';
|
|
3
19
|
import { SessionManager } from './jwt';
|
package/src/auth/index.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
// Exportações principais do sistema de autenticação
|
|
2
18
|
export * from './types';
|
|
3
19
|
export * from './providers';
|
package/src/auth/jwt.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
import crypto from 'crypto';
|
|
2
18
|
import type { User, Session } from './types';
|
|
3
19
|
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
import type { AuthProviderClass, User, AuthRoute } from '../types';
|
|
2
18
|
import { HightJSRequest, HightJSResponse } from '../../api/http';
|
|
3
19
|
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
import type {AuthProviderClass, AuthRoute, User} from '../types';
|
|
2
18
|
import {HightJSRequest, HightJSResponse} from '../../api/http';
|
|
3
19
|
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
import type {AuthProviderClass, AuthRoute, User} from '../types';
|
|
2
18
|
import {HightJSRequest, HightJSResponse} from '../../api/http';
|
|
3
19
|
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
// Exportações dos providers
|
|
2
18
|
export * from './credentials';
|
|
3
19
|
export * from './discord';
|
package/src/auth/providers.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
// Exportações dos providers
|
|
2
18
|
export { CredentialsProvider } from './providers/credentials';
|
|
3
19
|
export { DiscordProvider } from './providers/discord';
|
package/src/auth/react/index.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
// Exportações do frontend
|
|
2
18
|
export * from '../react';
|
|
3
19
|
export * from '../client';
|
package/src/auth/react.tsx
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
import React, { createContext, useContext, useEffect, useState, useCallback, ReactNode } from 'react';
|
|
2
18
|
import type { Session, SessionContextType, SignInOptions, SignInResult, User } from './types';
|
|
3
19
|
import { router } from "../client/clientRouter";
|
package/src/auth/routes.ts
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the HightJS Project.
|
|
3
|
+
* Copyright (c) 2025 itsmuzin
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
1
17
|
import { HightJSRequest, HightJSResponse } from '../api/http';
|
|
2
18
|
import type { AuthConfig } from './types';
|
|
3
19
|
import { HWebAuth } from './core';
|
|
20
|
+
import Console from "../api/console";
|
|
4
21
|
|
|
5
22
|
/**
|
|
6
23
|
* Cria o handler catch-all para /api/auth/[...value]
|