silgi 0.20.11 → 0.20.13

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.
@@ -1,4 +1,4 @@
1
- const version = "0.20.11";
1
+ const version = "0.20.13";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -2,7 +2,7 @@ import { SilgiCLI, ModuleOptionsCustom, ModuleDefinition, SilgiModule, ServicePa
2
2
  import { Buffer } from 'node:buffer';
3
3
  import * as consola from 'consola';
4
4
  import { ConsolaOptions } from 'consola';
5
- import { IncomingMessage } from 'node:http';
5
+ import { IncomingMessage, ServerResponse } from 'node:http';
6
6
 
7
7
  declare function hasError(type: SilgiCLI['errors'][0]['type'], silgi?: SilgiCLI): boolean;
8
8
 
@@ -121,7 +121,10 @@ declare function addTemplate<T>(_template: SilgiTemplate<T> | string): ResolvedS
121
121
  */
122
122
  declare function normalizeTemplate<T>(template: SilgiTemplate<T> | string, buildDir?: string): ResolvedSilgiTemplate<T>;
123
123
 
124
- declare function useRequest(event: SilgiEvents): IncomingMessage;
124
+ declare function useRequest<T extends IncomingMessage>(event: SilgiEvents): T | (IncomingMessage & {
125
+ originalUrl?: string;
126
+ });
127
+ declare function useResponse<T extends ServerResponse>(event: SilgiEvents): ServerResponse<IncomingMessage>;
125
128
  declare function getIpAddress(event: SilgiEvents): string | false;
126
129
  /**
127
130
  * Extract the client's IP address from request headers with high accuracy
@@ -150,4 +153,4 @@ declare const MODE_RE: RegExp;
150
153
  declare function hasSilgiModule(moduleKey: string, silgi?: SilgiCLI): boolean;
151
154
  declare function hasInstalledModule(moduleKey: string, silgi?: SilgiCLI): boolean;
152
155
 
153
- export { MODE_RE, addTemplate, applyEnv, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useSilgiRuntimeConfig, writeFile };
156
+ export { MODE_RE, addTemplate, applyEnv, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, useSilgiRuntimeConfig, writeFile };
@@ -2,7 +2,7 @@ import { SilgiCLI, ModuleOptionsCustom, ModuleDefinition, SilgiModule, ServicePa
2
2
  import { Buffer } from 'node:buffer';
3
3
  import * as consola from 'consola';
4
4
  import { ConsolaOptions } from 'consola';
5
- import { IncomingMessage } from 'node:http';
5
+ import { IncomingMessage, ServerResponse } from 'node:http';
6
6
 
7
7
  declare function hasError(type: SilgiCLI['errors'][0]['type'], silgi?: SilgiCLI): boolean;
8
8
 
@@ -121,7 +121,10 @@ declare function addTemplate<T>(_template: SilgiTemplate<T> | string): ResolvedS
121
121
  */
122
122
  declare function normalizeTemplate<T>(template: SilgiTemplate<T> | string, buildDir?: string): ResolvedSilgiTemplate<T>;
123
123
 
124
- declare function useRequest(event: SilgiEvents): IncomingMessage;
124
+ declare function useRequest<T extends IncomingMessage>(event: SilgiEvents): T | (IncomingMessage & {
125
+ originalUrl?: string;
126
+ });
127
+ declare function useResponse<T extends ServerResponse>(event: SilgiEvents): ServerResponse<IncomingMessage>;
125
128
  declare function getIpAddress(event: SilgiEvents): string | false;
126
129
  /**
127
130
  * Extract the client's IP address from request headers with high accuracy
@@ -150,4 +153,4 @@ declare const MODE_RE: RegExp;
150
153
  declare function hasSilgiModule(moduleKey: string, silgi?: SilgiCLI): boolean;
151
154
  declare function hasInstalledModule(moduleKey: string, silgi?: SilgiCLI): boolean;
152
155
 
153
- export { MODE_RE, addTemplate, applyEnv, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useSilgiRuntimeConfig, writeFile };
156
+ export { MODE_RE, addTemplate, applyEnv, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, useSilgiRuntimeConfig, writeFile };
@@ -478,6 +478,13 @@ function useRequest(event) {
478
478
  }
479
479
  return event;
480
480
  }
481
+ function useResponse(event) {
482
+ const silgi = useSilgi();
483
+ if (silgi.options.present === "nuxt" || silgi.options.present === "nitro" || silgi.options.present === "h3") {
484
+ return event.node.res;
485
+ }
486
+ return event;
487
+ }
481
488
  function getIpAddress(event) {
482
489
  const silgi = useSilgi();
483
490
  if (silgi.options.present === "nuxt" || silgi.options.present === "nitro" || silgi.options.present === "h3") {
@@ -552,4 +559,4 @@ function isValidIp(ip) {
552
559
  return false;
553
560
  }
554
561
 
555
- export { MODE_RE, addTemplate, applyEnv, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, getIpAddress, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useSilgiRuntimeConfig, writeFile };
562
+ export { MODE_RE, addTemplate, applyEnv, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, getIpAddress, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, useSilgiRuntimeConfig, writeFile };
@@ -1,4 +1,4 @@
1
- const version = "0.20.11";
1
+ const version = "0.20.13";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -1,4 +1,4 @@
1
- const version = "0.20.11";
1
+ const version = "0.20.13";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.20.11",
4
+ "version": "0.20.13",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {