@simo777/fastify-storage 1.0.0 → 1.0.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/dist/src/app.js +1 -0
- package/dist/src/app.js.map +1 -1
- package/dist/src/lib/storage/index.d.ts +1 -0
- package/dist/src/lib/storage/index.js.map +1 -1
- package/dist/src/plugins/storage.js +7 -1
- package/dist/src/plugins/storage.js.map +1 -1
- package/dist/src/storage-internal/index.d.ts +2 -0
- package/dist/src/storage-internal/index.js +76 -0
- package/dist/src/storage-internal/index.js.map +1 -0
- package/dist/src/storage-internal/storage.controller.d.ts +119 -0
- package/dist/src/storage-internal/storage.controller.js +99 -0
- package/dist/src/storage-internal/storage.controller.js.map +1 -0
- package/dist/src/storage-internal/storage.service.d.ts +111 -0
- package/dist/src/storage-internal/storage.service.js +191 -0
- package/dist/src/storage-internal/storage.service.js.map +1 -0
- package/package.json +1 -1
package/dist/src/app.js
CHANGED
|
@@ -52,6 +52,7 @@ export async function buildApp() {
|
|
|
52
52
|
await app.register(storagePlugin, {
|
|
53
53
|
provider: app.config.STORAGE_PROVIDER,
|
|
54
54
|
defaultPath: app.config.STORAGE_DEFAULT_PATH,
|
|
55
|
+
routePrefix: '/storage', // This will be prefixed by API_PREFIX if registered inside a scoped block
|
|
55
56
|
local: {
|
|
56
57
|
storagePath: app.config.LOCAL_STORAGE_PATH,
|
|
57
58
|
publicUrl: app.config.LOCAL_STORAGE_PUBLIC_URL
|
package/dist/src/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,IAAI,MAAM,eAAe,CAAC;AACjC,OAAO,UA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AAU,IAAI,GAAG;YACpG,CAAC,CAAC,eAAe,CAAC,UAAU;YAC5B,CAAC,CAAC,GAAG,CAAC;QACR,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC;QAE5E,OAAO,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;YACnC,KAAK,EAAE,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,OAAO;YAC7D,UAAU;SACX,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AAqBxB,MAAM,UAAU,qBAAqB,CAAC,OAA6B;IACjE,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,MAAM,CAAC,eAAe,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACxG,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,IAAI,iBAAiB,CAAC;YAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,MAAM,EAAE,MAAM,CAAC,UAAU;YACzB,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B,CAAC,CAAC;IACL,CAAC;IAED,mBAAmB;IACnB,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAC7B,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,IAAI,oBAAoB,CAC7B,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC,WAAW;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fp from 'fastify-plugin';
|
|
2
2
|
import { createStorageProvider } from '../lib/storage/index.js';
|
|
3
|
+
import storageRoutes from '../storage-internal/index.js';
|
|
3
4
|
const storagePlugin = async (fastify, options) => {
|
|
4
5
|
const storage = createStorageProvider(options);
|
|
5
6
|
const bucket = options.provider === 'r2' ? options.r2?.bucketName || 'r2' : 'local';
|
|
@@ -8,8 +9,13 @@ const storagePlugin = async (fastify, options) => {
|
|
|
8
9
|
bucket: bucket,
|
|
9
10
|
defaultPath: options.defaultPath
|
|
10
11
|
}));
|
|
12
|
+
// Register the storage routes automatically
|
|
13
|
+
await fastify.register(storageRoutes, {
|
|
14
|
+
prefix: options.routePrefix || '/storage'
|
|
15
|
+
});
|
|
11
16
|
};
|
|
12
17
|
export default fp(storagePlugin, {
|
|
13
|
-
name: 'storage'
|
|
18
|
+
name: 'storage',
|
|
19
|
+
fastify: '5.x'
|
|
14
20
|
});
|
|
15
21
|
//# sourceMappingURL=storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/plugins/storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAyC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/plugins/storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAyC,MAAM,yBAAyB,CAAC;AACvG,OAAO,aAAa,MAAM,8BAA8B,CAAC;AAczD,MAAM,aAAa,GAA6C,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IACzF,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;IAEpF,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QACjD,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,MAAM,EAAE,MAAM;QACd,WAAW,EAAE,OAAO,CAAC,WAAW;KACjC,CAAC,CAAC,CAAC;IAEJ,4CAA4C;IAC5C,MAAM,OAAO,CAAC,QAAQ,CAAC,aAAa,EAAE;QACpC,MAAM,EAAE,OAAO,CAAC,WAAW,IAAI,UAAU;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC,aAAa,EAAE;IAC/B,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,KAAK;CACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { StorageController } from './storage.controller.js';
|
|
2
|
+
import { StorageService } from './storage.service.js';
|
|
3
|
+
import { Type } from '@sinclair/typebox';
|
|
4
|
+
export default async function (fastify) {
|
|
5
|
+
const service = new StorageService(fastify);
|
|
6
|
+
const controller = new StorageController(service);
|
|
7
|
+
fastify.post('/upload', {
|
|
8
|
+
schema: {
|
|
9
|
+
response: {
|
|
10
|
+
200: Type.Object({
|
|
11
|
+
id: Type.String(),
|
|
12
|
+
key: Type.String(),
|
|
13
|
+
url: Type.String(),
|
|
14
|
+
originalName: Type.String(),
|
|
15
|
+
mimeType: Type.String(),
|
|
16
|
+
size: Type.Number(),
|
|
17
|
+
type: Type.String(),
|
|
18
|
+
hash: Type.String(),
|
|
19
|
+
width: Type.Optional(Type.Number()),
|
|
20
|
+
height: Type.Optional(Type.Number()),
|
|
21
|
+
duration: Type.Optional(Type.Number()),
|
|
22
|
+
}),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
handler: controller.upload.bind(controller),
|
|
26
|
+
});
|
|
27
|
+
fastify.put('/:id', {
|
|
28
|
+
schema: {
|
|
29
|
+
params: Type.Object({
|
|
30
|
+
id: Type.String(),
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
handler: controller.replace.bind(controller),
|
|
34
|
+
});
|
|
35
|
+
fastify.patch('/:id', {
|
|
36
|
+
schema: {
|
|
37
|
+
params: Type.Object({
|
|
38
|
+
id: Type.String(),
|
|
39
|
+
}),
|
|
40
|
+
body: Type.Object({
|
|
41
|
+
originalName: Type.Optional(Type.String()),
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
handler: controller.patch.bind(controller),
|
|
45
|
+
});
|
|
46
|
+
fastify.get('/signed-url', {
|
|
47
|
+
schema: {
|
|
48
|
+
querystring: Type.Object({
|
|
49
|
+
key: Type.String(),
|
|
50
|
+
contentType: Type.Optional(Type.String()),
|
|
51
|
+
}),
|
|
52
|
+
},
|
|
53
|
+
handler: controller.getSignedUrl.bind(controller),
|
|
54
|
+
});
|
|
55
|
+
fastify.get('/', {
|
|
56
|
+
schema: {},
|
|
57
|
+
handler: controller.list.bind(controller),
|
|
58
|
+
});
|
|
59
|
+
fastify.get('/:id', {
|
|
60
|
+
schema: {
|
|
61
|
+
params: Type.Object({
|
|
62
|
+
id: Type.String(),
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
65
|
+
handler: controller.get.bind(controller),
|
|
66
|
+
});
|
|
67
|
+
fastify.delete('/:id', {
|
|
68
|
+
schema: {
|
|
69
|
+
params: Type.Object({
|
|
70
|
+
id: Type.String(),
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
handler: controller.delete.bind(controller),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/storage-internal/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,MAAM,CAAC,OAAO,CAAC,KAAK,WAAW,OAAwB;IACrD,MAAM,OAAO,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAElD,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE;QACtB,MAAM,EAAE;YACN,QAAQ,EAAE;gBACR,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC;oBACf,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE;oBACjB,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE;oBAClB,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE;oBAClB,YAAY,EAAE,IAAI,CAAC,MAAM,EAAE;oBAC3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AG,EAAE,IAAI,CAAC,MAAM,EAAE;gBAClB,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;aAC1C,CAAC;SACH;QACD,OAAO,EAAE,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC;KAClD,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE;QACf,MAAM,EAAE,EACP;QACD,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;KAC1C,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE;QAClB,MAAM,EAAE;YACN,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;gBAClB,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE;aAClB,CAAC;SACH;QACD,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;KACzC,CAAC,CAAC;IAEH,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE;QACrB,MAAM,EAAE;YACN,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;gBAClB,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE;aAClB,CAAC;SACH;QACD,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;KAC5C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { FastifyReply, FastifyRequest } from 'fastify';
|
|
2
|
+
import { StorageService } from './storage.service.js';
|
|
3
|
+
export declare class StorageController {
|
|
4
|
+
private service;
|
|
5
|
+
constructor(service: StorageService);
|
|
6
|
+
upload(request: FastifyRequest, reply: FastifyReply): Promise<{
|
|
7
|
+
id: string;
|
|
8
|
+
key: string;
|
|
9
|
+
bucket: string;
|
|
10
|
+
provider: string;
|
|
11
|
+
originalName: string;
|
|
12
|
+
mimeType: string;
|
|
13
|
+
size: number;
|
|
14
|
+
url: string;
|
|
15
|
+
type: string;
|
|
16
|
+
hash: string;
|
|
17
|
+
width: number | null;
|
|
18
|
+
height: number | null;
|
|
19
|
+
duration: number | null;
|
|
20
|
+
createdAt: Date;
|
|
21
|
+
updatedAt: Date;
|
|
22
|
+
}>;
|
|
23
|
+
replace(request: FastifyRequest<{
|
|
24
|
+
Params: {
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
}>, reply: FastifyReply): Promise<{
|
|
28
|
+
id: string;
|
|
29
|
+
key: string;
|
|
30
|
+
bucket: string;
|
|
31
|
+
provider: string;
|
|
32
|
+
originalName: string;
|
|
33
|
+
mimeType: string;
|
|
34
|
+
size: number;
|
|
35
|
+
url: string;
|
|
36
|
+
type: string;
|
|
37
|
+
hash: string;
|
|
38
|
+
width: number | null;
|
|
39
|
+
height: number | null;
|
|
40
|
+
duration: number | null;
|
|
41
|
+
createdAt: Date;
|
|
42
|
+
updatedAt: Date;
|
|
43
|
+
}>;
|
|
44
|
+
patch(request: FastifyRequest<{
|
|
45
|
+
Params: {
|
|
46
|
+
id: string;
|
|
47
|
+
};
|
|
48
|
+
Body: {
|
|
49
|
+
originalName?: string;
|
|
50
|
+
};
|
|
51
|
+
}>, reply: FastifyReply): Promise<{
|
|
52
|
+
id: string;
|
|
53
|
+
key: string;
|
|
54
|
+
bucket: string;
|
|
55
|
+
provider: string;
|
|
56
|
+
originalName: string;
|
|
57
|
+
mimeType: string;
|
|
58
|
+
size: number;
|
|
59
|
+
url: string;
|
|
60
|
+
type: string;
|
|
61
|
+
hash: string;
|
|
62
|
+
width: number | null;
|
|
63
|
+
height: number | null;
|
|
64
|
+
duration: number | null;
|
|
65
|
+
createdAt: Date;
|
|
66
|
+
updatedAt: Date;
|
|
67
|
+
}>;
|
|
68
|
+
getSignedUrl(request: FastifyRequest<{
|
|
69
|
+
Querystring: {
|
|
70
|
+
key: string;
|
|
71
|
+
contentType?: string;
|
|
72
|
+
};
|
|
73
|
+
}>, reply: FastifyReply): Promise<{
|
|
74
|
+
url: string;
|
|
75
|
+
}>;
|
|
76
|
+
list(request: FastifyRequest, reply: FastifyReply): Promise<{
|
|
77
|
+
id: string;
|
|
78
|
+
key: string;
|
|
79
|
+
bucket: string;
|
|
80
|
+
provider: string;
|
|
81
|
+
originalName: string;
|
|
82
|
+
mimeType: string;
|
|
83
|
+
size: number;
|
|
84
|
+
url: string;
|
|
85
|
+
type: string;
|
|
86
|
+
hash: string;
|
|
87
|
+
width: number | null;
|
|
88
|
+
height: number | null;
|
|
89
|
+
duration: number | null;
|
|
90
|
+
createdAt: Date;
|
|
91
|
+
updatedAt: Date;
|
|
92
|
+
}[]>;
|
|
93
|
+
get(request: FastifyRequest<{
|
|
94
|
+
Params: {
|
|
95
|
+
id: string;
|
|
96
|
+
};
|
|
97
|
+
}>, reply: FastifyReply): Promise<{
|
|
98
|
+
id: string;
|
|
99
|
+
key: string;
|
|
100
|
+
bucket: string;
|
|
101
|
+
provider: string;
|
|
102
|
+
originalName: string;
|
|
103
|
+
mimeType: string;
|
|
104
|
+
size: number;
|
|
105
|
+
url: string;
|
|
106
|
+
type: string;
|
|
107
|
+
hash: string;
|
|
108
|
+
width: number | null;
|
|
109
|
+
height: number | null;
|
|
110
|
+
duration: number | null;
|
|
111
|
+
createdAt: Date;
|
|
112
|
+
updatedAt: Date;
|
|
113
|
+
}>;
|
|
114
|
+
delete(request: FastifyRequest<{
|
|
115
|
+
Params: {
|
|
116
|
+
id: string;
|
|
117
|
+
};
|
|
118
|
+
}>, reply: FastifyReply): Promise<never>;
|
|
119
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export class StorageController {
|
|
2
|
+
service;
|
|
3
|
+
constructor(service) {
|
|
4
|
+
this.service = service;
|
|
5
|
+
}
|
|
6
|
+
async upload(request, reply) {
|
|
7
|
+
let path;
|
|
8
|
+
let fileBuffer;
|
|
9
|
+
let filename;
|
|
10
|
+
let mimetype;
|
|
11
|
+
const parts = request.parts();
|
|
12
|
+
for await (const part of parts) {
|
|
13
|
+
if (part.type === 'file') {
|
|
14
|
+
fileBuffer = await part.toBuffer();
|
|
15
|
+
filename = part.filename;
|
|
16
|
+
mimetype = part.mimetype;
|
|
17
|
+
}
|
|
18
|
+
else if (part.type === 'field' && part.fieldname === 'path') {
|
|
19
|
+
path = part.value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
console.log(path, 'sssssssssssssssjjjj');
|
|
23
|
+
if (!fileBuffer || !filename || !mimetype) {
|
|
24
|
+
return reply.status(400).send({ message: 'No file uploaded' });
|
|
25
|
+
}
|
|
26
|
+
const file = await this.service.uploadFile(fileBuffer, filename, mimetype, path);
|
|
27
|
+
return file;
|
|
28
|
+
}
|
|
29
|
+
async replace(request, reply) {
|
|
30
|
+
let fileBuffer;
|
|
31
|
+
let filename;
|
|
32
|
+
let mimetype;
|
|
33
|
+
const parts = request.parts();
|
|
34
|
+
for await (const part of parts) {
|
|
35
|
+
if (part.type === 'file') {
|
|
36
|
+
fileBuffer = await part.toBuffer();
|
|
37
|
+
filename = part.filename;
|
|
38
|
+
mimetype = part.mimetype;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (!fileBuffer || !filename || !mimetype) {
|
|
42
|
+
return reply.status(400).send({ message: 'No file uploaded' });
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const file = await this.service.replaceFile(request.params.id, fileBuffer, filename, mimetype);
|
|
46
|
+
return file;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (error.message === 'File not found') {
|
|
50
|
+
return reply.status(404).send({ message: error.message });
|
|
51
|
+
}
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async patch(request, reply) {
|
|
56
|
+
try {
|
|
57
|
+
const file = await this.service.patchMetadata(request.params.id, request.body);
|
|
58
|
+
return file;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (error.message === 'File not found') {
|
|
62
|
+
return reply.status(404).send({ message: error.message });
|
|
63
|
+
}
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async getSignedUrl(request, reply) {
|
|
68
|
+
try {
|
|
69
|
+
const url = await this.service.getSignedUploadUrl(request.query.key, request.query.contentType);
|
|
70
|
+
return { url };
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
return reply.status(400).send({ message: error.message });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async list(request, reply) {
|
|
77
|
+
return this.service.listFiles();
|
|
78
|
+
}
|
|
79
|
+
async get(request, reply) {
|
|
80
|
+
const file = await this.service.getFile(request.params.id);
|
|
81
|
+
if (!file) {
|
|
82
|
+
return reply.status(404).send({ message: 'File not found' });
|
|
83
|
+
}
|
|
84
|
+
return file;
|
|
85
|
+
}
|
|
86
|
+
async delete(request, reply) {
|
|
87
|
+
try {
|
|
88
|
+
await this.service.deleteFile(request.params.id);
|
|
89
|
+
return reply.status(204).send();
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (error.message === 'File not found') {
|
|
93
|
+
return reply.status(404).send({ message: error.message });
|
|
94
|
+
}
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=storage.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.controller.js","sourceRoot":"","sources":["../../../src/storage-internal/storage.controller.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,iBAAiB;IACR,OAAO;IAA3B,YAAoB,OAAuB;uBAAvB,OAAO;IAAoB,CAAC;IAEhD,KAAK,CAAC,MAAM,CAAC,OAAuB,EAAE,KAAmB;QACvD,IAAI,IAAwB,CAAC;QAC7B,IAAI,UAA8B,CAAC;QACnC,IAAI,QAA4B,CAAC;QACjC,IAAI,QAA4B,CAAC;QAEjC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC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EAAE,CAAC;gBACvC,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC5D,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { FastifyInstance } from 'fastify';
|
|
2
|
+
export declare class StorageService {
|
|
3
|
+
private fastify;
|
|
4
|
+
constructor(fastify: FastifyInstance);
|
|
5
|
+
private getMetadata;
|
|
6
|
+
uploadFile(file: Buffer, originalName: string, mimeType: string, path?: string): Promise<{
|
|
7
|
+
id: string;
|
|
8
|
+
key: string;
|
|
9
|
+
bucket: string;
|
|
10
|
+
provider: string;
|
|
11
|
+
originalName: string;
|
|
12
|
+
mimeType: string;
|
|
13
|
+
size: number;
|
|
14
|
+
url: string;
|
|
15
|
+
type: string;
|
|
16
|
+
hash: string;
|
|
17
|
+
width: number | null;
|
|
18
|
+
height: number | null;
|
|
19
|
+
duration: number | null;
|
|
20
|
+
createdAt: Date;
|
|
21
|
+
updatedAt: Date;
|
|
22
|
+
}>;
|
|
23
|
+
replaceFile(id: string, file: Buffer, originalName: string, mimeType: string): Promise<{
|
|
24
|
+
id: string;
|
|
25
|
+
key: string;
|
|
26
|
+
bucket: string;
|
|
27
|
+
provider: string;
|
|
28
|
+
originalName: string;
|
|
29
|
+
mimeType: string;
|
|
30
|
+
size: number;
|
|
31
|
+
url: string;
|
|
32
|
+
type: string;
|
|
33
|
+
hash: string;
|
|
34
|
+
width: number | null;
|
|
35
|
+
height: number | null;
|
|
36
|
+
duration: number | null;
|
|
37
|
+
createdAt: Date;
|
|
38
|
+
updatedAt: Date;
|
|
39
|
+
}>;
|
|
40
|
+
patchMetadata(id: string, data: {
|
|
41
|
+
originalName?: string;
|
|
42
|
+
}): Promise<{
|
|
43
|
+
id: string;
|
|
44
|
+
key: string;
|
|
45
|
+
bucket: string;
|
|
46
|
+
provider: string;
|
|
47
|
+
originalName: string;
|
|
48
|
+
mimeType: string;
|
|
49
|
+
size: number;
|
|
50
|
+
url: string;
|
|
51
|
+
type: string;
|
|
52
|
+
hash: string;
|
|
53
|
+
width: number | null;
|
|
54
|
+
height: number | null;
|
|
55
|
+
duration: number | null;
|
|
56
|
+
createdAt: Date;
|
|
57
|
+
updatedAt: Date;
|
|
58
|
+
}>;
|
|
59
|
+
getSignedUploadUrl(key: string, contentType?: string | undefined): Promise<string>;
|
|
60
|
+
getFile(id: string): Promise<{
|
|
61
|
+
id: string;
|
|
62
|
+
key: string;
|
|
63
|
+
bucket: string;
|
|
64
|
+
provider: string;
|
|
65
|
+
originalName: string;
|
|
66
|
+
mimeType: string;
|
|
67
|
+
size: number;
|
|
68
|
+
url: string;
|
|
69
|
+
type: string;
|
|
70
|
+
hash: string;
|
|
71
|
+
width: number | null;
|
|
72
|
+
height: number | null;
|
|
73
|
+
duration: number | null;
|
|
74
|
+
createdAt: Date;
|
|
75
|
+
updatedAt: Date;
|
|
76
|
+
} | null>;
|
|
77
|
+
deleteFile(id: string): Promise<{
|
|
78
|
+
id: string;
|
|
79
|
+
key: string;
|
|
80
|
+
bucket: string;
|
|
81
|
+
provider: string;
|
|
82
|
+
originalName: string;
|
|
83
|
+
mimeType: string;
|
|
84
|
+
size: number;
|
|
85
|
+
url: string;
|
|
86
|
+
type: string;
|
|
87
|
+
hash: string;
|
|
88
|
+
width: number | null;
|
|
89
|
+
height: number | null;
|
|
90
|
+
duration: number | null;
|
|
91
|
+
createdAt: Date;
|
|
92
|
+
updatedAt: Date;
|
|
93
|
+
}>;
|
|
94
|
+
listFiles(): Promise<{
|
|
95
|
+
id: string;
|
|
96
|
+
key: string;
|
|
97
|
+
bucket: string;
|
|
98
|
+
provider: string;
|
|
99
|
+
originalName: string;
|
|
100
|
+
mimeType: string;
|
|
101
|
+
size: number;
|
|
102
|
+
url: string;
|
|
103
|
+
type: string;
|
|
104
|
+
hash: string;
|
|
105
|
+
width: number | null;
|
|
106
|
+
height: number | null;
|
|
107
|
+
duration: number | null;
|
|
108
|
+
createdAt: Date;
|
|
109
|
+
updatedAt: Date;
|
|
110
|
+
}[]>;
|
|
111
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { randomUUID, createHash } from 'node:crypto';
|
|
2
|
+
import { extname } from 'node:path';
|
|
3
|
+
import sharp from 'sharp';
|
|
4
|
+
import ffmpeg from 'fluent-ffmpeg';
|
|
5
|
+
import { Readable } from 'node:stream';
|
|
6
|
+
export class StorageService {
|
|
7
|
+
fastify;
|
|
8
|
+
constructor(fastify) {
|
|
9
|
+
this.fastify = fastify;
|
|
10
|
+
}
|
|
11
|
+
async getMetadata(buffer, mimeType) {
|
|
12
|
+
let width;
|
|
13
|
+
let height;
|
|
14
|
+
let duration;
|
|
15
|
+
let type = 'file';
|
|
16
|
+
if (mimeType.startsWith('image/')) {
|
|
17
|
+
type = 'image';
|
|
18
|
+
try {
|
|
19
|
+
const metadata = await sharp(buffer).metadata();
|
|
20
|
+
width = metadata.width ?? undefined;
|
|
21
|
+
height = metadata.height ?? undefined;
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
this.fastify.log.error('Failed to get image metadata', e);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else if (mimeType.startsWith('video/') || mimeType.startsWith('audio/')) {
|
|
28
|
+
type = mimeType.startsWith('video/') ? 'video' : 'audio';
|
|
29
|
+
try {
|
|
30
|
+
const readable = new Readable();
|
|
31
|
+
readable.push(buffer);
|
|
32
|
+
readable.push(null);
|
|
33
|
+
const metadata = await new Promise((resolve, reject) => {
|
|
34
|
+
ffmpeg(readable).ffprobe((err, data) => {
|
|
35
|
+
if (err)
|
|
36
|
+
reject(err);
|
|
37
|
+
else
|
|
38
|
+
resolve(data);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
duration = metadata.format.duration ?? undefined;
|
|
42
|
+
if (type === 'video') {
|
|
43
|
+
const videoStream = metadata.streams.find(s => s.codec_type === 'video');
|
|
44
|
+
width = videoStream?.width ?? undefined;
|
|
45
|
+
height = videoStream?.height ?? undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
this.fastify.log.error('Failed to get media metadata', e);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { type, width, height, duration };
|
|
53
|
+
}
|
|
54
|
+
async uploadFile(file, originalName, mimeType, path) {
|
|
55
|
+
const hash = createHash('sha256').update(file).digest('hex');
|
|
56
|
+
// Check for duplicate
|
|
57
|
+
const existing = await this.fastify.prisma.storedFile.findUnique({
|
|
58
|
+
where: { hash },
|
|
59
|
+
});
|
|
60
|
+
if (existing) {
|
|
61
|
+
return existing;
|
|
62
|
+
}
|
|
63
|
+
const { type, width, height, duration } = await this.getMetadata(file, mimeType);
|
|
64
|
+
const extension = extname(originalName);
|
|
65
|
+
const key = `${randomUUID()}${extension}`;
|
|
66
|
+
const provider = this.fastify.storage.provider;
|
|
67
|
+
const finalPath = path || this.fastify.storage.defaultPath;
|
|
68
|
+
const fullKey = await this.fastify.storage.upload(file, {
|
|
69
|
+
key,
|
|
70
|
+
contentType: mimeType,
|
|
71
|
+
path: finalPath,
|
|
72
|
+
});
|
|
73
|
+
const bucket = this.fastify.storage.bucket;
|
|
74
|
+
const url = this.fastify.storage.getPublicUrl(fullKey);
|
|
75
|
+
const storedFile = await this.fastify.prisma.storedFile.create({
|
|
76
|
+
data: {
|
|
77
|
+
key: fullKey,
|
|
78
|
+
bucket,
|
|
79
|
+
provider,
|
|
80
|
+
originalName,
|
|
81
|
+
mimeType,
|
|
82
|
+
size: file.length,
|
|
83
|
+
url,
|
|
84
|
+
hash,
|
|
85
|
+
type,
|
|
86
|
+
width: width ?? null,
|
|
87
|
+
height: height ?? null,
|
|
88
|
+
duration: duration ? Math.round(duration) : null,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
return storedFile;
|
|
92
|
+
}
|
|
93
|
+
async replaceFile(id, file, originalName, mimeType) {
|
|
94
|
+
const oldFile = await this.getFile(id);
|
|
95
|
+
if (!oldFile) {
|
|
96
|
+
throw new Error('File not found');
|
|
97
|
+
}
|
|
98
|
+
const hash = createHash('sha256').update(file).digest('hex');
|
|
99
|
+
// If new hash matches old hash, just update metadata
|
|
100
|
+
if (hash === oldFile.hash) {
|
|
101
|
+
const { type, width, height, duration } = await this.getMetadata(file, mimeType);
|
|
102
|
+
return this.fastify.prisma.storedFile.update({
|
|
103
|
+
where: { id },
|
|
104
|
+
data: {
|
|
105
|
+
originalName,
|
|
106
|
+
mimeType,
|
|
107
|
+
type,
|
|
108
|
+
width: width ?? null,
|
|
109
|
+
height: height ?? null,
|
|
110
|
+
duration: duration ? Math.round(duration) : null,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
// Check if new hash exists elsewhere (deduplication)
|
|
115
|
+
const existing = await this.fastify.prisma.storedFile.findUnique({
|
|
116
|
+
where: { hash },
|
|
117
|
+
});
|
|
118
|
+
if (existing) {
|
|
119
|
+
// If a duplicate exists, we delete the current record and return the existing one
|
|
120
|
+
// to maintain global deduplication and clean up the old ID.
|
|
121
|
+
await this.deleteFile(id);
|
|
122
|
+
return existing;
|
|
123
|
+
}
|
|
124
|
+
// Perform full update of the existing record
|
|
125
|
+
const { type, width, height, duration } = await this.getMetadata(file, mimeType);
|
|
126
|
+
const extension = extname(originalName);
|
|
127
|
+
const key = `${randomUUID()}${extension}`;
|
|
128
|
+
const url = this.fastify.storage.getPublicUrl(key);
|
|
129
|
+
const oldKey = oldFile.key;
|
|
130
|
+
await this.fastify.storage.upload(file, {
|
|
131
|
+
key,
|
|
132
|
+
contentType: mimeType,
|
|
133
|
+
});
|
|
134
|
+
const updated = await this.fastify.prisma.storedFile.update({
|
|
135
|
+
where: { id },
|
|
136
|
+
data: {
|
|
137
|
+
key,
|
|
138
|
+
hash,
|
|
139
|
+
originalName,
|
|
140
|
+
mimeType,
|
|
141
|
+
size: file.length,
|
|
142
|
+
url,
|
|
143
|
+
type,
|
|
144
|
+
width: width ?? null,
|
|
145
|
+
height: height ?? null,
|
|
146
|
+
duration: duration ? Math.round(duration) : null,
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
// Clean up old physical file
|
|
150
|
+
await this.fastify.storage.delete(oldKey);
|
|
151
|
+
return updated;
|
|
152
|
+
}
|
|
153
|
+
async patchMetadata(id, data) {
|
|
154
|
+
const file = await this.getFile(id);
|
|
155
|
+
if (!file) {
|
|
156
|
+
throw new Error('File not found');
|
|
157
|
+
}
|
|
158
|
+
return this.fastify.prisma.storedFile.update({
|
|
159
|
+
where: { id },
|
|
160
|
+
data,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
async getSignedUploadUrl(key, contentType) {
|
|
164
|
+
if (!this.fastify.storage.generateSignedUploadUrl) {
|
|
165
|
+
throw new Error('Signed URLs are not supported by the current storage provider');
|
|
166
|
+
}
|
|
167
|
+
return this.fastify.storage.generateSignedUploadUrl(key, { contentType });
|
|
168
|
+
}
|
|
169
|
+
async getFile(id) {
|
|
170
|
+
return this.fastify.prisma.storedFile.findUnique({
|
|
171
|
+
where: { id },
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async deleteFile(id) {
|
|
175
|
+
const file = await this.getFile(id);
|
|
176
|
+
if (!file) {
|
|
177
|
+
throw new Error('File not found');
|
|
178
|
+
}
|
|
179
|
+
await this.fastify.storage.delete(file.key);
|
|
180
|
+
await this.fastify.prisma.storedFile.delete({
|
|
181
|
+
where: { id },
|
|
182
|
+
});
|
|
183
|
+
return file;
|
|
184
|
+
}
|
|
185
|
+
async listFiles() {
|
|
186
|
+
return this.fastify.prisma.storedFile.findMany({
|
|
187
|
+
orderBy: { createdAt: 'desc' },
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=storage.service.js.map
|
|
@@ -0,0 +1 @@
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,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;YAC1C,KAAK,EAAE,EAAE,EAAE,EAAE;SACd,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,SAAS;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC7C,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;SAC/B,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simo777/fastify-storage",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Scalable Fastify storage plugin for Local and R2/S3 storage with Prisma metadata tracking and media processing.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/src/plugins/storage.js",
|