nuxt-file-storage 0.2.1 → 0.2.2

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/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "nuxt-file-storage",
3
3
  "configKey": "fileStorage",
4
- "version": "0.2.1"
4
+ "version": "0.2.2"
5
5
  }
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, addImportsDir, addTemplate } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addImportsDir, addServerScanDir } from '@nuxt/kit';
2
2
  import defu from 'defu';
3
3
 
4
4
  const module = defineNuxtModule({
@@ -17,34 +17,7 @@ const module = defineNuxtModule({
17
17
  });
18
18
  const resolve = createResolver(import.meta.url).resolve;
19
19
  addImportsDir(resolve("runtime/composables"));
20
- addImportsDir(resolve("runtime/server/utils"));
21
- nuxt.hook("nitro:config", (_config) => {
22
- _config.alias = _config.alias || {};
23
- _config.externals = defu(typeof _config.externals === "object" ? _config.externals : {}, {
24
- inline: [resolve("./runtime")]
25
- });
26
- _config.alias["#nuxt/file-storage"] = resolve("./runtime/server/utils/storage");
27
- });
28
- const template = addTemplate({
29
- filename: "types/nuxt-file-storage.d.ts",
30
- getContents: () => [
31
- "declare module '#nuxt/file-storage' {",
32
- ` const storeFileLocally: typeof import('${resolve(
33
- "./runtime/server/utils/storage"
34
- )}').storeFileLocally`,
35
- ` const deleteFile: typeof import('${resolve(
36
- "./runtime/server/utils/storage"
37
- )}').deleteFile`,
38
- "}",
39
- ` const parseDataUrl: typeof import('${resolve(
40
- "./runtime/server/utils/storage"
41
- )}').parseDataUrl`,
42
- "}"
43
- ].join("\n")
44
- });
45
- nuxt.hook("prepare:types", ({ references }) => {
46
- references.push({ path: template.dst });
47
- });
20
+ addServerScanDir(resolve("./runtime/server"));
48
21
  }
49
22
  });
50
23
 
@@ -12,5 +12,5 @@ Parses a data URL and returns an object with the binary data and the file extens
12
12
  */
13
13
  export declare const parseDataUrl: (file: string) => {
14
14
  binaryString: Buffer;
15
- ext: any;
15
+ ext: string;
16
16
  };
@@ -1,5 +1,5 @@
1
- import mimeTypes from "mime-types";
2
1
  import { writeFile, rm, mkdir } from "fs/promises";
2
+ import { useRuntimeConfig } from "#imports";
3
3
  export const storeFileLocally = async (dataurl, fileNameOrIdLength, filelocation = "") => {
4
4
  const { binaryString, ext } = parseDataUrl(dataurl);
5
5
  const location = useRuntimeConfig().public.fileStorage.mount;
@@ -31,6 +31,6 @@ export const parseDataUrl = (file) => {
31
31
  const mime = mimeMatch[1];
32
32
  const base64String = arr[1];
33
33
  const binaryString = Buffer.from(base64String, "base64");
34
- const ext = mimeTypes.extension(mime);
34
+ const ext = mime.split("/")[1];
35
35
  return { binaryString, ext };
36
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-file-storage",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Easy solution to store files in your nuxt apps. Be able to upload files from the frontend and recieve them from the backend to then save the files in your project.",
5
5
  "repository": "NyllRE/nuxt-file-storage",
6
6
  "license": "MIT",
@@ -37,11 +37,9 @@
37
37
  "@nuxt/module-builder": "^0.5.5",
38
38
  "@nuxt/schema": "^3.9.3",
39
39
  "@nuxt/test-utils": "^3.9.0",
40
- "@types/mime-types": "^2.1.4",
41
40
  "@types/node": "^20.11.5",
42
41
  "changelogen": "^0.5.5",
43
42
  "eslint": "^8.56.0",
44
- "mime-types": "^2.1.35",
45
43
  "nuxt": "^3.9.3",
46
44
  "vitest": "^1.0.0"
47
45
  }