nuxt-file-storage 0.2.0 → 0.2.1

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.1"
5
5
  }
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, addImportsDir } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addImportsDir, addTemplate } from '@nuxt/kit';
2
2
  import defu from 'defu';
3
3
 
4
4
  const module = defineNuxtModule({
@@ -8,17 +8,43 @@ 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
+ 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
+ });
22
48
  }
23
49
  });
24
50
 
package/package.json CHANGED
@@ -1,48 +1,48 @@
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.1",
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
+ }
48
48
  }