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 +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +9 -10
- package/dist/runtime/server/utils/storage.d.ts +1 -1
- package/dist/runtime/server/utils/storage.mjs +2 -2
- package/package.json +44 -46
package/README.md
CHANGED
package/dist/module.json
CHANGED
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
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
);
|
|
19
|
-
|
|
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
|
|
|
@@ -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 =
|
|
34
|
+
const ext = mime.split("/")[1];
|
|
35
35
|
return { binaryString, ext };
|
|
36
36
|
};
|
package/package.json
CHANGED
|
@@ -1,48 +1,46 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
}
|