hightjs 0.5.1 → 0.5.3

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.
Files changed (48) hide show
  1. package/package.json +1 -1
  2. package/src/builder.js +8 -8
  3. package/src/hotReload.ts +4 -7
  4. package/src/router.ts +15 -13
  5. package/dist/adapters/express.d.ts +0 -7
  6. package/dist/adapters/express.js +0 -63
  7. package/dist/adapters/factory.d.ts +0 -23
  8. package/dist/adapters/factory.js +0 -122
  9. package/dist/adapters/fastify.d.ts +0 -25
  10. package/dist/adapters/fastify.js +0 -61
  11. package/dist/adapters/native.d.ts +0 -8
  12. package/dist/adapters/native.js +0 -198
  13. package/dist/api/console.d.ts +0 -94
  14. package/dist/api/console.js +0 -294
  15. package/dist/api/http.d.ts +0 -180
  16. package/dist/api/http.js +0 -469
  17. package/dist/bin/hightjs.d.ts +0 -2
  18. package/dist/bin/hightjs.js +0 -214
  19. package/dist/builder.d.ts +0 -32
  20. package/dist/builder.js +0 -581
  21. package/dist/client/DefaultNotFound.d.ts +0 -1
  22. package/dist/client/DefaultNotFound.js +0 -79
  23. package/dist/client/client.d.ts +0 -3
  24. package/dist/client/client.js +0 -24
  25. package/dist/client/clientRouter.d.ts +0 -58
  26. package/dist/client/clientRouter.js +0 -132
  27. package/dist/client/entry.client.d.ts +0 -1
  28. package/dist/client/entry.client.js +0 -455
  29. package/dist/components/Link.d.ts +0 -7
  30. package/dist/components/Link.js +0 -13
  31. package/dist/global/global.d.ts +0 -117
  32. package/dist/global/global.js +0 -17
  33. package/dist/helpers.d.ts +0 -20
  34. package/dist/helpers.js +0 -583
  35. package/dist/hotReload.d.ts +0 -32
  36. package/dist/hotReload.js +0 -548
  37. package/dist/index.d.ts +0 -18
  38. package/dist/index.js +0 -494
  39. package/dist/loaders.d.ts +0 -1
  40. package/dist/loaders.js +0 -46
  41. package/dist/renderer.d.ts +0 -14
  42. package/dist/renderer.js +0 -380
  43. package/dist/router.d.ts +0 -101
  44. package/dist/router.js +0 -653
  45. package/dist/types/framework.d.ts +0 -37
  46. package/dist/types/framework.js +0 -2
  47. package/dist/types.d.ts +0 -192
  48. package/dist/types.js +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hightjs",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
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/builder.js CHANGED
@@ -409,7 +409,7 @@ async function buildWithChunks(entryPoint, outdir, isProduction = false) {
409
409
  sourcemap: !isProduction,
410
410
  platform: 'browser',
411
411
  outdir: outdir,
412
- loader: { '.js': 'jsx', '.ts': 'tsx' },
412
+ loader: { '.js': 'js', '.ts': 'tsx' },
413
413
  external: nodeBuiltIns,
414
414
  plugins: [postcssPlugin, npmDependenciesPlugin, reactResolvePlugin, markdownPlugin, assetsPlugin],
415
415
  format: 'esm', // ESM suporta melhor o code splitting
@@ -419,7 +419,7 @@ async function buildWithChunks(entryPoint, outdir, isProduction = false) {
419
419
  },
420
420
  conditions: ['development'],
421
421
  mainFields: ['browser', 'module', 'main'],
422
- resolveExtensions: ['.tsx', '.ts', '.jsx', '.js'],
422
+ resolveExtensions: ['.tsx', '.ts', '.js'],
423
423
  splitting: true,
424
424
  chunkNames: 'chunks/[name]-[hash]',
425
425
  // Força o nome do entry para main(.js) ou main-[hash].js em prod
@@ -471,7 +471,7 @@ async function watchWithChunks(entryPoint, outdir, hotReloadManager = null) {
471
471
  sourcemap: true,
472
472
  platform: 'browser',
473
473
  outdir: outdir,
474
- loader: { '.js': 'jsx', '.ts': 'tsx' },
474
+ loader: { '.js': 'js', '.ts': 'tsx' },
475
475
  external: nodeBuiltIns,
476
476
  plugins: [postcssPlugin, npmDependenciesPlugin, reactResolvePlugin, hmrPlugin, buildCompletePlugin, markdownPlugin, assetsPlugin],
477
477
  format: 'esm',
@@ -481,7 +481,7 @@ async function watchWithChunks(entryPoint, outdir, hotReloadManager = null) {
481
481
  },
482
482
  conditions: ['development'],
483
483
  mainFields: ['browser', 'module', 'main'],
484
- resolveExtensions: ['.tsx', '.ts', '.jsx', '.js'],
484
+ resolveExtensions: ['.tsx', '.ts', '.js'],
485
485
  splitting: true,
486
486
  chunkNames: 'chunks/[name]-[hash]',
487
487
  entryNames: 'main',
@@ -517,7 +517,7 @@ async function build(entryPoint, outfile, isProduction = false) {
517
517
  sourcemap: !isProduction, // Só gera sourcemap em dev
518
518
  platform: 'browser',
519
519
  outfile: outfile,
520
- loader: { '.js': 'jsx', '.ts': 'tsx' },
520
+ loader: { '.js': 'js', '.ts': 'tsx' },
521
521
  external: nodeBuiltIns,
522
522
  plugins: [postcssPlugin, npmDependenciesPlugin, reactResolvePlugin, markdownPlugin, assetsPlugin],
523
523
  format: 'iife',
@@ -529,7 +529,7 @@ async function build(entryPoint, outfile, isProduction = false) {
529
529
  // Configurações específicas para React 19
530
530
  conditions: ['development'],
531
531
  mainFields: ['browser', 'module', 'main'],
532
- resolveExtensions: ['.tsx', '.ts', '.jsx', '.js'],
532
+ resolveExtensions: ['.tsx', '.ts', '.js'],
533
533
  // Garante que não há duplicação de dependências
534
534
  splitting: false,
535
535
  // Preserva nomes de funções e comportamento
@@ -580,7 +580,7 @@ async function watch(entryPoint, outfile, hotReloadManager = null) {
580
580
  sourcemap: true,
581
581
  platform: 'browser',
582
582
  outfile: outfile,
583
- loader: { '.js': 'jsx', '.ts': 'tsx' },
583
+ loader: { '.js': 'js', '.ts': 'tsx' },
584
584
  external: nodeBuiltIns,
585
585
  format: 'iife',
586
586
  globalName: 'HwebApp',
@@ -591,7 +591,7 @@ async function watch(entryPoint, outfile, hotReloadManager = null) {
591
591
  // Configurações específicas para React 19 (mesmo que no build)
592
592
  conditions: ['development'],
593
593
  mainFields: ['browser', 'module', 'main'],
594
- resolveExtensions: ['.tsx', '.ts', '.jsx', '.js'],
594
+ resolveExtensions: ['.tsx', '.ts', '.js'],
595
595
  // Garante que não há duplicação de dependências
596
596
  splitting: false,
597
597
  // Preserva nomes de funções e comportamento
package/src/hotReload.ts CHANGED
@@ -192,8 +192,7 @@ export class HotReloadManager {
192
192
  filePath.includes(path.join('src', 'web', 'components')) ||
193
193
  filePath.includes('layout.tsx') ||
194
194
  filePath.includes('not-found.tsx') ||
195
- filePath.endsWith('.tsx') ||
196
- filePath.endsWith('.jsx');
195
+ filePath.endsWith('.tsx');
197
196
 
198
197
  const isBackendFile = filePath.includes(path.join('src', 'backend')) && !isFrontendFile;
199
198
 
@@ -393,9 +392,7 @@ export class HotReloadManager {
393
392
  // Mudanças que exigem reload completo
394
393
  const needsFullReload =
395
394
  file.includes('layout.tsx') ||
396
- file.includes('layout.jsx') ||
397
395
  file.includes('not-found.tsx') ||
398
- file.includes('not-found.jsx') ||
399
396
  file.endsWith('.css');
400
397
 
401
398
  if (needsFullReload) {
@@ -405,15 +402,15 @@ export class HotReloadManager {
405
402
  }
406
403
 
407
404
  // Mudanças em rotas: tenta HMR
408
- if (file.includes('/routes/') || file.includes('\\\\routes\\\\')) {
405
+ if (file.includes('/routes/') || file.includes('routes')) {
409
406
  console.log('⚡ Route component changed, hot reloading...');
410
-
407
+
411
408
  // Dispara evento para forçar re-render
412
409
  const event = new CustomEvent('hmr:component-update', {
413
410
  detail: { file: data.file, timestamp: Date.now() }
414
411
  });
415
412
  window.dispatchEvent(event);
416
-
413
+
417
414
  // Aguarda 500ms para ver se o HMR foi bem-sucedido
418
415
  setTimeout(() => {
419
416
  const hmrSuccess = window.__HMR_SUCCESS__;
package/src/router.ts CHANGED
@@ -51,7 +51,7 @@ function clearRequireCache(filePath: string) {
51
51
  delete require.cache[resolvedPath];
52
52
 
53
53
  // Também limpa arquivos temporários relacionados (apenas se existir no cache)
54
- const tempFile = filePath.replace(/\.(tsx|ts)$/, '.temp.$1');
54
+ const tempFile = filePath.replace(/\.(tsx|ts|jsx|js)$/, '.temp.$1');
55
55
  const tempResolvedPath = require.cache[require.resolve(tempFile)];
56
56
  if (tempResolvedPath) {
57
57
  delete require.cache[require.resolve(tempFile)];
@@ -61,6 +61,8 @@ function clearRequireCache(filePath: string) {
61
61
  }
62
62
  }
63
63
 
64
+ // Nota: Suporte apenas para TypeScript (.ts, .tsx). Não tratamos .jsx aqui.
65
+
64
66
  /**
65
67
  * Limpa todo o cache de rotas carregadas
66
68
  */
@@ -107,10 +109,9 @@ export function clearFileCache(changedFilePath: string) {
107
109
  */
108
110
  export function loadLayout(webDir: string): { componentPath: string; metadata?: any } | null {
109
111
  const layoutPath = path.join(webDir, 'layout.tsx');
110
- const layoutPathJs = path.join(webDir, 'layout.ts');
111
-
112
+ const layoutPathTs = path.join(webDir, 'layout.ts');
112
113
  const layoutFile = fs.existsSync(layoutPath) ? layoutPath :
113
- fs.existsSync(layoutPathJs) ? layoutPathJs : null;
114
+ fs.existsSync(layoutPathTs) ? layoutPathTs : null;
114
115
 
115
116
  if (layoutFile) {
116
117
  const absolutePath = path.resolve(layoutFile);
@@ -124,8 +125,10 @@ export function loadLayout(webDir: string): { componentPath: string; metadata?:
124
125
  .replace(/import\s+['"][^'"]*\.scss['"];?/g, '// SCSS import removido para servidor')
125
126
  .replace(/import\s+['"][^'"]*\.sass['"];?/g, '// SASS import removido para servidor');
126
127
 
127
- const tempFile = layoutFile.replace(/\.(tsx|ts)$/, '.temp.$1');
128
- fs.writeFileSync(tempFile, tempContent);
128
+ // Escreve um arquivo temporário .temp.tsx ou .temp.ts sem imports de CSS
129
+ const ext = path.extname(layoutFile).toLowerCase();
130
+ const tempFile = layoutFile.replace(/\.(tsx|ts)$/i, '.temp.$1');
131
+ fs.writeFileSync(tempFile, tempContent, 'utf8');
129
132
 
130
133
  // Otimização: limpa cache apenas se existir
131
134
  try {
@@ -138,7 +141,7 @@ export function loadLayout(webDir: string): { componentPath: string; metadata?:
138
141
  const layoutModule = require(tempFile);
139
142
 
140
143
  // Remove o arquivo temporário
141
- fs.unlinkSync(tempFile);
144
+ try { fs.unlinkSync(tempFile); } catch {}
142
145
 
143
146
  const metadata = layoutModule.metadata || null;
144
147
 
@@ -283,7 +286,7 @@ let loadedMiddlewares: Map<string, HightMiddleware[]> = new Map();
283
286
  function loadMiddlewareFromDirectory(dir: string): HightMiddleware[] {
284
287
  const middlewares: HightMiddleware[] = [];
285
288
 
286
- // Procura por middleware.ts ou middleware.tsx
289
+ // Procura por middleware.ts, middleware.tsx
287
290
  const middlewarePath = path.join(dir, 'middleware.ts');
288
291
  const middlewarePathTsx = path.join(dir, 'middleware.tsx');
289
292
 
@@ -365,8 +368,8 @@ export function loadBackendRoutes(backendRoutesDir: string) {
365
368
  if (entry.isDirectory()) {
366
369
  scanDirectory(path.join(dir, entry.name), relativePath);
367
370
  } else if (entry.isFile()) {
368
- const isTypeScript = entry.name.endsWith('.ts') || entry.name.endsWith('.tsx');
369
- if (!isTypeScript) continue;
371
+ const isSupported = entry.name.endsWith('.ts') || entry.name.endsWith('.tsx');
372
+ if (!isSupported) continue;
370
373
 
371
374
  // Identifica middlewares durante o scan
372
375
  if (entry.name.startsWith('middleware')) {
@@ -487,10 +490,9 @@ export function findMatchingBackendRoute(pathname: string, method: string) {
487
490
  */
488
491
  export function loadNotFound(webDir: string): { componentPath: string } | null {
489
492
  const notFoundPath = path.join(webDir, 'notFound.tsx');
490
- const notFoundPathJs = path.join(webDir, 'notFound.ts');
491
-
493
+ const notFoundPathTs = path.join(webDir, 'notFound.ts');
492
494
  const notFoundFile = fs.existsSync(notFoundPath) ? notFoundPath :
493
- fs.existsSync(notFoundPathJs) ? notFoundPathJs : null;
495
+ fs.existsSync(notFoundPathTs) ? notFoundPathTs : null;
494
496
 
495
497
  if (notFoundFile) {
496
498
  const absolutePath = path.resolve(notFoundFile);
@@ -1,7 +0,0 @@
1
- import type { Request as ExpressRequest, Response as ExpressResponse } from 'express';
2
- import { GenericRequest, GenericResponse, FrameworkAdapter } from '../types/framework';
3
- export declare class ExpressAdapter implements FrameworkAdapter {
4
- type: "express";
5
- parseRequest(req: ExpressRequest): GenericRequest;
6
- createResponse(res: ExpressResponse): GenericResponse;
7
- }
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExpressAdapter = void 0;
4
- class ExpressAdapter {
5
- constructor() {
6
- this.type = 'express';
7
- }
8
- parseRequest(req) {
9
- return {
10
- method: req.method,
11
- url: req.url,
12
- headers: req.headers,
13
- body: req.body,
14
- query: req.query,
15
- params: req.params,
16
- cookies: req.cookies || {},
17
- raw: req,
18
- };
19
- }
20
- createResponse(res) {
21
- return new ExpressResponseWrapper(res);
22
- }
23
- }
24
- exports.ExpressAdapter = ExpressAdapter;
25
- class ExpressResponseWrapper {
26
- constructor(res) {
27
- this.res = res;
28
- }
29
- get raw() {
30
- return this.res;
31
- }
32
- status(code) {
33
- this.res.status(code);
34
- return this;
35
- }
36
- header(name, value) {
37
- this.res.setHeader(name, value);
38
- return this;
39
- }
40
- cookie(name, value, options) {
41
- this.res.cookie(name, value, options || {});
42
- return this;
43
- }
44
- clearCookie(name, options) {
45
- // Filter out the deprecated 'expires' option to avoid Express deprecation warning
46
- const { expires, ...filteredOptions } = options || {};
47
- this.res.clearCookie(name, filteredOptions);
48
- return this;
49
- }
50
- json(data) {
51
- this.res.json(data);
52
- }
53
- text(data) {
54
- this.res.setHeader('Content-Type', 'text/plain; charset=utf-8');
55
- this.res.send(data);
56
- }
57
- send(data) {
58
- this.res.send(data);
59
- }
60
- redirect(url) {
61
- this.res.redirect(url);
62
- }
63
- }
@@ -1,23 +0,0 @@
1
- import { FrameworkAdapter } from '../types/framework';
2
- /**
3
- * Factory para criar o adapter correto baseado no framework detectado
4
- */
5
- export declare class FrameworkAdapterFactory {
6
- private static adapter;
7
- /**
8
- * Detecta automaticamente o framework baseado na requisição/resposta
9
- */
10
- static detectFramework(req: any, res: any): FrameworkAdapter;
11
- /**
12
- * Força o uso de um framework específico
13
- */
14
- static setFramework(framework: 'express' | 'fastify' | 'native'): void;
15
- /**
16
- * Reset do adapter (útil para testes)
17
- */
18
- static reset(): void;
19
- /**
20
- * Retorna o adapter atual (se já foi detectado)
21
- */
22
- static getCurrentAdapter(): FrameworkAdapter | null;
23
- }
@@ -1,122 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.FrameworkAdapterFactory = void 0;
37
- const express_1 = require("./express");
38
- const fastify_1 = require("./fastify");
39
- const native_1 = require("./native");
40
- const console_1 = __importStar(require("../api/console"));
41
- /**
42
- * Factory para criar o adapter correto baseado no framework detectado
43
- */
44
- class FrameworkAdapterFactory {
45
- /**
46
- * Detecta automaticamente o framework baseado na requisição/resposta
47
- */
48
- static detectFramework(req, res) {
49
- // Se já detectamos antes, retorna o mesmo adapter
50
- if (this.adapter) {
51
- return this.adapter;
52
- }
53
- const msg = console_1.default.dynamicLine(` ${console_1.Colors.FgYellow}● ${console_1.Colors.Reset}Detecting web framework...`);
54
- // Detecta Express
55
- if (req.app && req.route && res.locals !== undefined) {
56
- msg.end(` ${console_1.Colors.FgGreen}● ${console_1.Colors.Reset}Framework detected: Express`);
57
- this.adapter = new express_1.ExpressAdapter();
58
- return this.adapter;
59
- }
60
- // Detecta Fastify
61
- if (req.server && req.routerPath !== undefined && res.request) {
62
- msg.end(` ${console_1.Colors.FgGreen}● ${console_1.Colors.Reset}Framework detected: Fastify`);
63
- this.adapter = new fastify_1.FastifyAdapter();
64
- return this.adapter;
65
- }
66
- // Detecta HTTP nativo do Node.js
67
- if (req.method !== undefined && req.url !== undefined && req.headers !== undefined &&
68
- res.statusCode !== undefined && res.setHeader !== undefined && res.end !== undefined) {
69
- msg.end(` ${console_1.Colors.FgGreen}● ${console_1.Colors.Reset}Framework detected: HightJS Native (HTTP)`);
70
- this.adapter = new native_1.NativeAdapter();
71
- return this.adapter;
72
- }
73
- // Fallback mais específico para Express
74
- if (res.status && res.send && res.json && res.cookie) {
75
- msg.end(` ${console_1.Colors.FgGreen}● ${console_1.Colors.Reset}Framework detected: Express (fallback)`);
76
- this.adapter = new express_1.ExpressAdapter();
77
- return this.adapter;
78
- }
79
- // Fallback mais específico para Fastify
80
- if (res.code && res.send && res.type && res.setCookie) {
81
- msg.end(` ${console_1.Colors.FgGreen}● ${console_1.Colors.Reset}Framework detected: Fastify (fallback)`);
82
- this.adapter = new fastify_1.FastifyAdapter();
83
- return this.adapter;
84
- }
85
- // Default para HightJS Native se não conseguir detectar
86
- msg.end(` ${console_1.Colors.FgYellow}● ${console_1.Colors.Reset}Unable to detect framework. Using HightJS Native as default.`);
87
- this.adapter = new native_1.NativeAdapter();
88
- return this.adapter;
89
- }
90
- /**
91
- * Força o uso de um framework específico
92
- */
93
- static setFramework(framework) {
94
- switch (framework) {
95
- case 'express':
96
- this.adapter = new express_1.ExpressAdapter();
97
- break;
98
- case 'fastify':
99
- this.adapter = new fastify_1.FastifyAdapter();
100
- break;
101
- case 'native':
102
- this.adapter = new native_1.NativeAdapter();
103
- break;
104
- default:
105
- throw new Error(`Unsupported framework: ${framework}`);
106
- }
107
- }
108
- /**
109
- * Reset do adapter (útil para testes)
110
- */
111
- static reset() {
112
- this.adapter = null;
113
- }
114
- /**
115
- * Retorna o adapter atual (se já foi detectado)
116
- */
117
- static getCurrentAdapter() {
118
- return this.adapter;
119
- }
120
- }
121
- exports.FrameworkAdapterFactory = FrameworkAdapterFactory;
122
- FrameworkAdapterFactory.adapter = null;
@@ -1,25 +0,0 @@
1
- interface FastifyRequest {
2
- method: string;
3
- url: string;
4
- headers: Record<string, string | string[]>;
5
- body?: any;
6
- query?: Record<string, any>;
7
- params?: Record<string, string>;
8
- cookies?: Record<string, string>;
9
- }
10
- interface FastifyReply {
11
- status(code: number): FastifyReply;
12
- header(name: string, value: string): FastifyReply;
13
- setCookie(name: string, value: string, options?: any): FastifyReply;
14
- clearCookie(name: string, options?: any): FastifyReply;
15
- type(contentType: string): FastifyReply;
16
- send(data: any): void;
17
- redirect(url: string): void;
18
- }
19
- import { GenericRequest, GenericResponse, FrameworkAdapter } from '../types/framework';
20
- export declare class FastifyAdapter implements FrameworkAdapter {
21
- type: "fastify";
22
- parseRequest(req: FastifyRequest): GenericRequest;
23
- createResponse(reply: FastifyReply): GenericResponse;
24
- }
25
- export {};
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FastifyAdapter = void 0;
4
- class FastifyAdapter {
5
- constructor() {
6
- this.type = 'fastify';
7
- }
8
- parseRequest(req) {
9
- return {
10
- method: req.method,
11
- url: req.url,
12
- headers: req.headers,
13
- body: req.body,
14
- query: req.query,
15
- params: req.params,
16
- cookies: req.cookies || {},
17
- raw: req
18
- };
19
- }
20
- createResponse(reply) {
21
- return new FastifyResponseWrapper(reply);
22
- }
23
- }
24
- exports.FastifyAdapter = FastifyAdapter;
25
- class FastifyResponseWrapper {
26
- constructor(reply) {
27
- this.reply = reply;
28
- }
29
- get raw() {
30
- return this.reply;
31
- }
32
- status(code) {
33
- this.reply.status(code);
34
- return this;
35
- }
36
- header(name, value) {
37
- this.reply.header(name, value);
38
- return this;
39
- }
40
- cookie(name, value, options) {
41
- this.reply.setCookie(name, value, options);
42
- return this;
43
- }
44
- clearCookie(name, options) {
45
- this.reply.clearCookie(name, options);
46
- return this;
47
- }
48
- json(data) {
49
- this.reply.send(data);
50
- }
51
- text(data) {
52
- this.reply.type('text/plain; charset=utf-8');
53
- this.reply.send(data);
54
- }
55
- send(data) {
56
- this.reply.send(data);
57
- }
58
- redirect(url) {
59
- this.reply.redirect(url);
60
- }
61
- }
@@ -1,8 +0,0 @@
1
- import type { IncomingMessage, ServerResponse } from 'http';
2
- import { GenericRequest, GenericResponse, FrameworkAdapter } from '../types/framework';
3
- export declare class NativeAdapter implements FrameworkAdapter {
4
- type: "native";
5
- parseRequest(req: IncomingMessage): GenericRequest;
6
- createResponse(res: ServerResponse): GenericResponse;
7
- private parseCookies;
8
- }