@bool-ts/core 1.7.6 → 1.7.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bool-ts/core",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -52,6 +52,10 @@ export type TBoolFactoryOptions = Required<{
52
52
  methods: Array<"GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS">;
53
53
  }>;
54
54
  queryParser: Parameters<typeof Qs.parse>[1];
55
+ static: Required<{
56
+ path: string;
57
+ }> &
58
+ Partial<{}>;
55
59
  }>;
56
60
 
57
61
  export const responseConverter = (response: Response) => {
@@ -916,8 +920,9 @@ export const BoolFactory = async (
916
920
  ) => {
917
921
  try {
918
922
  const modulesConverted = !Array.isArray(modules) ? [modules] : modules;
919
- const { allowLogsMethods } = Object.freeze({
920
- allowLogsMethods: options?.log?.methods
923
+ const { allowLogsMethods, staticOption } = Object.freeze({
924
+ allowLogsMethods: options?.log?.methods,
925
+ staticOption: options.static
921
926
  });
922
927
 
923
928
  const moduleResolutions = await Promise.all(
@@ -944,6 +949,21 @@ export const BoolFactory = async (
944
949
  const query = Qs.parse(url.searchParams.toString(), options.queryParser);
945
950
 
946
951
  try {
952
+ if (staticOption) {
953
+ const file = Bun.file(`${staticOption.path}/${url.pathname}`);
954
+ const isFileExists = await file.exists();
955
+
956
+ if (isFileExists) {
957
+ return new Response(await file.arrayBuffer(), {
958
+ status: 200,
959
+ statusText: "SUCCESS",
960
+ headers: {
961
+ "Content-Type": file.type
962
+ }
963
+ });
964
+ }
965
+ }
966
+
947
967
  let collection:
948
968
  | undefined
949
969
  | Required<{