@bool-ts/core 1.7.7 → 1.7.8

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.
@@ -21,6 +21,9 @@ export type TBoolFactoryOptions = Required<{
21
21
  methods: Array<"GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS">;
22
22
  }>;
23
23
  queryParser: Parameters<typeof Qs.parse>[1];
24
+ static: Required<{
25
+ path: string;
26
+ }> & Partial<{}>;
24
27
  }>;
25
28
  export declare const responseConverter: (response: Response) => Response;
26
29
  export declare const controllerCreator: (controllerConstructor: new (...args: any[]) => unknown, group: RouterGroup, injector: Injector, prefix?: string) => RouterGroup;
@@ -568,8 +568,9 @@ const fetcher = async (bun, bool) => {
568
568
  export const BoolFactory = async (modules, options) => {
569
569
  try {
570
570
  const modulesConverted = !Array.isArray(modules) ? [modules] : modules;
571
- const { allowLogsMethods } = Object.freeze({
572
- allowLogsMethods: options?.log?.methods
571
+ const { allowLogsMethods, staticOption } = Object.freeze({
572
+ allowLogsMethods: options?.log?.methods,
573
+ staticOption: options.static
573
574
  });
574
575
  const moduleResolutions = await Promise.all(modulesConverted.map((moduleConverted) => moduleResolution(moduleConverted, options)));
575
576
  const availableModuleResolutions = moduleResolutions.filter((moduleResolution) => typeof moduleResolution !== "undefined");
@@ -586,6 +587,19 @@ export const BoolFactory = async (modules, options) => {
586
587
  const url = new URL(request.url);
587
588
  const query = Qs.parse(url.searchParams.toString(), options.queryParser);
588
589
  try {
590
+ if (staticOption) {
591
+ const file = Bun.file(`${staticOption.path}/${url.pathname}`);
592
+ const isFileExists = await file.exists();
593
+ if (isFileExists) {
594
+ return new Response(await file.arrayBuffer(), {
595
+ status: 200,
596
+ statusText: "SUCCESS",
597
+ headers: {
598
+ "Content-Type": file.type
599
+ }
600
+ });
601
+ }
602
+ }
589
603
  let collection;
590
604
  for (let i = 0; i < availableModuleResolutions.length; i++) {
591
605
  const routeResult = availableModuleResolutions[i].routerGroup.find(url.pathname, request.method);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bool-ts/core",
3
- "version": "1.7.7",
3
+ "version": "1.7.8",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {