nuxt-file-storage 0.2.0 → 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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ![Nuxt Storage Banner](./playground/public/nuxt-file-storage-banner.svg)
1
+ ![Nuxt File Storage Banner](./playground/public/nuxt-file-storage-banner.svg)
2
2
 
3
3
  # Nuxt File Storage
4
4
 
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.0"
4
+ "version": "0.2.2"
5
5
  }
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, addImportsDir } 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({
@@ -8,17 +8,16 @@ const module = defineNuxtModule({
8
8
  },
9
9
  //? Default configuration options of the Nuxt module
10
10
  // defaults: {
11
+ // mount: 'userFiles',
11
12
  // },
12
13
  setup(options, nuxt) {
13
- nuxt.options.runtimeConfig.public.fileStorage = defu(
14
- nuxt.options.runtimeConfig.public.fileStorage,
15
- {
16
- ...options
17
- }
18
- );
19
- const resolver = createResolver(import.meta.url);
20
- addImportsDir(resolver.resolve("runtime/composables"));
21
- addImportsDir(resolver.resolve("runtime/server/utils"));
14
+ const config = nuxt.options.runtimeConfig;
15
+ config.public.fileStorage = defu(config.public.fileStorage, {
16
+ ...options
17
+ });
18
+ const resolve = createResolver(import.meta.url).resolve;
19
+ addImportsDir(resolve("runtime/composables"));
20
+ addServerScanDir(resolve("./runtime/server"));
22
21
  }
23
22
  });
24
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,48 +1,46 @@
1
1
  {
2
- "name": "nuxt-file-storage",
3
- "version": "0.2.0",
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
- "repository": "NyllRE/nuxt-file-storage",
6
- "license": "MIT",
7
- "type": "module",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/types.d.ts",
11
- "import": "./dist/module.mjs",
12
- "require": "./dist/module.cjs"
13
- }
14
- },
15
- "main": "./dist/module.cjs",
16
- "types": "./dist/types.d.ts",
17
- "files": [
18
- "dist"
19
- ],
20
- "scripts": {
21
- "prepack": "nuxt-module-build build",
22
- "dev": "nuxi dev playground",
23
- "dev:build": "nuxi build playground",
24
- "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
25
- "release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
26
- "lint": "eslint .",
27
- "test": "vitest run",
28
- "test:watch": "vitest watch"
29
- },
30
- "dependencies": {
31
- "@nuxt/kit": "^3.9.3",
32
- "defu": "^6.1.4"
33
- },
34
- "devDependencies": {
35
- "@nuxt/devtools": "latest",
36
- "@nuxt/eslint-config": "^0.2.0",
37
- "@nuxt/module-builder": "^0.5.5",
38
- "@nuxt/schema": "^3.9.3",
39
- "@nuxt/test-utils": "^3.9.0",
40
- "@types/mime-types": "^2.1.4",
41
- "@types/node": "^20.11.5",
42
- "changelogen": "^0.5.5",
43
- "eslint": "^8.56.0",
44
- "mime-types": "^2.1.35",
45
- "nuxt": "^3.9.3",
46
- "vitest": "^1.0.0"
47
- }
2
+ "name": "nuxt-file-storage",
3
+ "version": "0.2.2",
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
+ "repository": "NyllRE/nuxt-file-storage",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/types.d.ts",
11
+ "import": "./dist/module.mjs",
12
+ "require": "./dist/module.cjs"
13
+ }
14
+ },
15
+ "main": "./dist/module.cjs",
16
+ "types": "./dist/types.d.ts",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "prepack": "nuxt-module-build build",
22
+ "dev": "nuxi dev playground",
23
+ "dev:build": "nuxi build playground",
24
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
25
+ "release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
26
+ "lint": "eslint .",
27
+ "test": "vitest run",
28
+ "test:watch": "vitest watch"
29
+ },
30
+ "dependencies": {
31
+ "@nuxt/kit": "^3.9.3",
32
+ "defu": "^6.1.4"
33
+ },
34
+ "devDependencies": {
35
+ "@nuxt/devtools": "latest",
36
+ "@nuxt/eslint-config": "^0.2.0",
37
+ "@nuxt/module-builder": "^0.5.5",
38
+ "@nuxt/schema": "^3.9.3",
39
+ "@nuxt/test-utils": "^3.9.0",
40
+ "@types/node": "^20.11.5",
41
+ "changelogen": "^0.5.5",
42
+ "eslint": "^8.56.0",
43
+ "nuxt": "^3.9.3",
44
+ "vitest": "^1.0.0"
45
+ }
48
46
  }