dn-react-router-toolkit 0.1.11 → 0.2.0
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/auth/apple_auth.d.mts +38 -0
- package/dist/auth/apple_auth.d.ts +38 -0
- package/dist/{auth-kit → auth}/apple_auth.js +31 -18
- package/dist/auth/apple_auth.mjs +63 -0
- package/dist/{auth-kit/repository.d.mts → auth/auth_repository.d.mts} +6 -9
- package/dist/{auth-kit/repository.d.ts → auth/auth_repository.d.ts} +6 -9
- package/dist/{file-kit/repository.js → auth/auth_repository.js} +3 -3
- package/dist/{auth-kit → auth}/auth_service.d.mts +12 -22
- package/dist/{auth-kit → auth}/auth_service.d.ts +12 -22
- package/dist/{auth-kit → auth}/auth_service.js +30 -77
- package/dist/{auth-kit → auth}/auth_service.mjs +30 -77
- package/dist/auth/client/google_login_button.d.mts +7 -0
- package/dist/auth/client/google_login_button.d.ts +7 -0
- package/dist/{auth-kit → auth}/client/google_login_button.js +24 -19
- package/dist/auth/client/google_login_button.mjs +37 -0
- package/dist/auth/client/provider.d.mts +23 -0
- package/dist/auth/client/provider.d.ts +23 -0
- package/dist/auth/client/provider.js +137 -0
- package/dist/auth/client/provider.mjs +101 -0
- package/dist/{auth-kit → auth}/client/redirect_page.js +1 -1
- package/dist/{auth-kit → auth}/client/redirect_page.mjs +1 -1
- package/dist/auth/google_auth.d.mts +33 -0
- package/dist/auth/google_auth.d.ts +33 -0
- package/dist/{auth-kit → auth}/google_auth.js +23 -32
- package/dist/{auth-kit → auth}/google_auth.mjs +22 -31
- package/dist/auth/handlers/find_auth.d.mts +13 -0
- package/dist/auth/handlers/find_auth.d.ts +13 -0
- package/dist/{route/api/auth/route.js → auth/handlers/find_auth.js} +10 -10
- package/dist/{route/api/auth/route.mjs → auth/handlers/find_auth.mjs} +5 -5
- package/dist/auth/handlers/login.d.mts +13 -0
- package/dist/auth/handlers/login.d.ts +13 -0
- package/dist/{route/api/auth/login/route.js → auth/handlers/login.js} +17 -17
- package/dist/{route/api/auth/login/route.mjs → auth/handlers/login.mjs} +12 -12
- package/dist/auth/handlers/login_with_thirdparty.d.mts +15 -0
- package/dist/auth/handlers/login_with_thirdparty.d.ts +15 -0
- package/dist/{route/api/auth/login/[provider]/route.js → auth/handlers/login_with_thirdparty.js} +12 -27
- package/dist/{route/api/auth/login/[provider]/route.mjs → auth/handlers/login_with_thirdparty.mjs} +7 -22
- package/dist/auth/handlers/logout.d.mts +13 -0
- package/dist/auth/handlers/logout.d.ts +13 -0
- package/dist/{route/api/auth/logout/route.js → auth/handlers/logout.js} +15 -11
- package/dist/{route/api/auth/logout/route.mjs → auth/handlers/logout.mjs} +11 -7
- package/dist/auth/handlers/refresh.d.mts +13 -0
- package/dist/auth/handlers/refresh.d.ts +13 -0
- package/dist/{route/api/auth/refresh/route.js → auth/handlers/refresh.js} +12 -12
- package/dist/{route/api/auth/refresh/route.mjs → auth/handlers/refresh.mjs} +7 -7
- package/dist/auth/handlers/signup.d.mts +15 -0
- package/dist/auth/handlers/signup.d.ts +15 -0
- package/dist/auth/handlers/signup.js +135 -0
- package/dist/auth/handlers/signup.mjs +100 -0
- package/dist/auth/handlers/signup_with_thirdparty.d.mts +17 -0
- package/dist/auth/handlers/signup_with_thirdparty.d.ts +17 -0
- package/dist/auth/handlers/signup_with_thirdparty.js +123 -0
- package/dist/auth/handlers/signup_with_thirdparty.mjs +98 -0
- package/dist/auth/handlers/thirdparty_auth_callback.d.mts +16 -0
- package/dist/auth/handlers/thirdparty_auth_callback.d.ts +16 -0
- package/dist/{route/auth/callback/[provider]/route.js → auth/handlers/thirdparty_auth_callback.js} +54 -45
- package/dist/{route/auth/callback/[provider]/route.mjs → auth/handlers/thirdparty_auth_callback.mjs} +49 -40
- package/dist/{auth-kit/jwt.d.mts → auth/jwt_manager.d.mts} +11 -1
- package/dist/{auth-kit/jwt.d.ts → auth/jwt_manager.d.ts} +11 -1
- package/dist/{auth-kit/jwt.js → auth/jwt_manager.js} +25 -11
- package/dist/{auth-kit/jwt.mjs → auth/jwt_manager.mjs} +22 -8
- package/dist/auth/kakao_auth.d.mts +27 -0
- package/dist/auth/kakao_auth.d.ts +27 -0
- package/dist/auth/kakao_auth.js +56 -0
- package/dist/auth/kakao_auth.mjs +31 -0
- package/dist/auth/thirdparty_auth.d.mts +41 -0
- package/dist/auth/thirdparty_auth.d.ts +41 -0
- package/dist/{auth-kit/kakao_auth.js → auth/thirdparty_auth.js} +31 -33
- package/dist/{auth-kit/kakao_auth.mjs → auth/thirdparty_auth.mjs} +26 -28
- package/dist/{auth-kit → auth}/with_auth.d.mts +5 -6
- package/dist/{auth-kit → auth}/with_auth.d.ts +5 -6
- package/dist/{auth-kit → auth}/with_auth.js +26 -42
- package/dist/auth/with_auth.mjs +63 -0
- package/dist/date.d.mts +2 -0
- package/dist/date.d.ts +2 -0
- package/dist/date.js +4 -2
- package/dist/date.mjs +2 -1
- package/dist/{file-kit → file}/cdn.js +1 -1
- package/dist/{file-kit → file}/cdn.mjs +1 -1
- package/dist/{file-kit → file}/client/drop_file_input.js +3 -3
- package/dist/{file-kit → file}/client/drop_file_input.mjs +3 -3
- package/dist/{file-kit → file}/client/file_upload_button.js +1 -1
- package/dist/{file-kit → file}/client/file_upload_button.mjs +1 -1
- package/dist/{file-kit → file}/client/file_uploader.js +3 -3
- package/dist/{file-kit → file}/client/file_uploader.mjs +2 -2
- package/dist/{file-kit → file}/client/format_size.js +1 -1
- package/dist/{file-kit → file}/client/format_size.mjs +1 -1
- package/dist/{file-kit → file}/client/metadata.js +1 -1
- package/dist/{file-kit → file}/client/metadata.mjs +1 -1
- package/dist/{file-kit/repository.d.mts → file/file_repository.d.mts} +4 -4
- package/dist/{file-kit/repository.d.ts → file/file_repository.d.ts} +4 -4
- package/dist/{auth-kit/repository.js → file/file_repository.js} +3 -3
- package/dist/file/file_service.d.mts +32 -0
- package/dist/file/file_service.d.ts +32 -0
- package/dist/{file-kit → file}/file_service.js +27 -21
- package/dist/file/file_service.mjs +41 -0
- package/dist/file/handlers/delete_file.d.mts +17 -0
- package/dist/file/handlers/delete_file.d.ts +17 -0
- package/dist/{route/api/files/[fileId]/route.js → file/handlers/delete_file.js} +15 -15
- package/dist/{route/api/files/[fileId]/route.mjs → file/handlers/delete_file.mjs} +10 -10
- package/dist/file/handlers/upload_file.d.mts +16 -0
- package/dist/file/handlers/upload_file.d.ts +16 -0
- package/dist/{route/api/files/route.js → file/handlers/upload_file.js} +13 -13
- package/dist/{route/api/files/route.mjs → file/handlers/upload_file.mjs} +8 -8
- package/dist/{file-kit → file}/object_storage.d.mts +3 -1
- package/dist/{file-kit → file}/object_storage.d.ts +3 -1
- package/dist/{file-kit → file}/object_storage.js +2 -2
- package/dist/{file-kit → file}/object_storage.mjs +2 -2
- package/dist/{file-kit → file}/responsive_image.d.mts +4 -4
- package/dist/{file-kit → file}/responsive_image.d.ts +4 -4
- package/dist/{file-kit → file}/responsive_image.js +18 -9
- package/dist/{file-kit → file}/responsive_image.mjs +18 -9
- package/dist/{http-kit → http}/index.js +5 -5
- package/dist/{http-kit → http}/index.mjs +1 -1
- package/dist/{http-kit → http}/response.js +1 -1
- package/dist/{http-kit → http}/response.mjs +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.mjs +1 -0
- package/dist/route/api.d.mts +15 -25
- package/dist/route/api.d.ts +15 -25
- package/dist/route/api.js +325 -178
- package/dist/route/api.mjs +314 -177
- package/dist/{seo-kit → seo}/seo.js +1 -1
- package/dist/{seo-kit → seo}/seo.mjs +1 -1
- package/package.json +74 -74
- package/dist/auth-kit/apple_auth.d.mts +0 -24
- package/dist/auth-kit/apple_auth.d.ts +0 -24
- package/dist/auth-kit/apple_auth.mjs +0 -50
- package/dist/auth-kit/client/google_login_button.d.mts +0 -9
- package/dist/auth-kit/client/google_login_button.d.ts +0 -9
- package/dist/auth-kit/client/google_login_button.mjs +0 -32
- package/dist/auth-kit/client/logout.d.mts +0 -3
- package/dist/auth-kit/client/logout.d.ts +0 -3
- package/dist/auth-kit/client/logout.js +0 -49
- package/dist/auth-kit/client/logout.mjs +0 -24
- package/dist/auth-kit/google_auth.d.mts +0 -27
- package/dist/auth-kit/google_auth.d.ts +0 -27
- package/dist/auth-kit/kakao_auth.d.mts +0 -24
- package/dist/auth-kit/kakao_auth.d.ts +0 -24
- package/dist/auth-kit/with_auth.mjs +0 -67
- package/dist/file-kit/file_service.d.mts +0 -26
- package/dist/file-kit/file_service.d.ts +0 -26
- package/dist/file-kit/file_service.mjs +0 -35
- package/dist/route/api/auth/login/_provider_/route.d.mts +0 -20
- package/dist/route/api/auth/login/_provider_/route.d.ts +0 -20
- package/dist/route/api/auth/login/route.d.mts +0 -14
- package/dist/route/api/auth/login/route.d.ts +0 -14
- package/dist/route/api/auth/logout/route.d.mts +0 -14
- package/dist/route/api/auth/logout/route.d.ts +0 -14
- package/dist/route/api/auth/refresh/route.d.mts +0 -13
- package/dist/route/api/auth/refresh/route.d.ts +0 -13
- package/dist/route/api/auth/route.d.mts +0 -13
- package/dist/route/api/auth/route.d.ts +0 -13
- package/dist/route/api/files/_fileId_/route.d.mts +0 -17
- package/dist/route/api/files/_fileId_/route.d.ts +0 -17
- package/dist/route/api/files/route.d.mts +0 -16
- package/dist/route/api/files/route.d.ts +0 -16
- package/dist/route/auth/callback/_provider_/route.d.mts +0 -20
- package/dist/route/auth/callback/_provider_/route.d.ts +0 -20
- /package/dist/{auth-kit/repository.mjs → auth/auth_repository.mjs} +0 -0
- /package/dist/{auth-kit → auth}/client/redirect_page.d.mts +0 -0
- /package/dist/{auth-kit → auth}/client/redirect_page.d.ts +0 -0
- /package/dist/{file-kit → file}/cdn.d.mts +0 -0
- /package/dist/{file-kit → file}/cdn.d.ts +0 -0
- /package/dist/{file-kit → file}/client/drop_file_input.d.mts +0 -0
- /package/dist/{file-kit → file}/client/drop_file_input.d.ts +0 -0
- /package/dist/{file-kit → file}/client/file_upload_button.d.mts +0 -0
- /package/dist/{file-kit → file}/client/file_upload_button.d.ts +0 -0
- /package/dist/{file-kit → file}/client/file_uploader.d.mts +0 -0
- /package/dist/{file-kit → file}/client/file_uploader.d.ts +0 -0
- /package/dist/{file-kit → file}/client/format_size.d.mts +0 -0
- /package/dist/{file-kit → file}/client/format_size.d.ts +0 -0
- /package/dist/{file-kit → file}/client/metadata.d.mts +0 -0
- /package/dist/{file-kit → file}/client/metadata.d.ts +0 -0
- /package/dist/{file-kit/repository.mjs → file/file_repository.mjs} +0 -0
- /package/dist/{http-kit → http}/index.d.mts +0 -0
- /package/dist/{http-kit → http}/index.d.ts +0 -0
- /package/dist/{http-kit → http}/response.d.mts +0 -0
- /package/dist/{http-kit → http}/response.d.ts +0 -0
- /package/dist/{seo-kit → seo}/seo.d.mts +0 -0
- /package/dist/{seo-kit → seo}/seo.d.ts +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
interface FileRepository<TFile> {
|
|
1
|
+
interface FileRepository<TFile = unknown> {
|
|
2
2
|
findFileById(fileId: string): Promise<TFile | undefined>;
|
|
3
3
|
hasPermission(file: TFile, userId?: string): boolean;
|
|
4
4
|
createFile(fileData: {
|
|
5
5
|
id: string;
|
|
6
6
|
userId?: string;
|
|
7
7
|
name: string;
|
|
8
|
-
type
|
|
9
|
-
size
|
|
10
|
-
metadata
|
|
8
|
+
type?: string;
|
|
9
|
+
size?: number;
|
|
10
|
+
metadata?: Record<string, any>;
|
|
11
11
|
key: string;
|
|
12
12
|
}): Promise<TFile>;
|
|
13
13
|
deleteFile(fileId: string): Promise<void>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
interface FileRepository<TFile> {
|
|
1
|
+
interface FileRepository<TFile = unknown> {
|
|
2
2
|
findFileById(fileId: string): Promise<TFile | undefined>;
|
|
3
3
|
hasPermission(file: TFile, userId?: string): boolean;
|
|
4
4
|
createFile(fileData: {
|
|
5
5
|
id: string;
|
|
6
6
|
userId?: string;
|
|
7
7
|
name: string;
|
|
8
|
-
type
|
|
9
|
-
size
|
|
10
|
-
metadata
|
|
8
|
+
type?: string;
|
|
9
|
+
size?: number;
|
|
10
|
+
metadata?: Record<string, any>;
|
|
11
11
|
key: string;
|
|
12
12
|
}): Promise<TFile>;
|
|
13
13
|
deleteFile(fileId: string): Promise<void>;
|
|
@@ -13,6 +13,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
13
|
};
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
15
|
|
|
16
|
-
// src/
|
|
17
|
-
var
|
|
18
|
-
module.exports = __toCommonJS(
|
|
16
|
+
// src/file/file_repository.ts
|
|
17
|
+
var file_repository_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(file_repository_exports);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ObjectStorage } from './object_storage.mjs';
|
|
2
|
+
import { FileRepository } from './file_repository.mjs';
|
|
3
|
+
import '@aws-sdk/client-s3';
|
|
4
|
+
|
|
5
|
+
type UploadFileParams = {
|
|
6
|
+
name: string;
|
|
7
|
+
userId?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
size?: number;
|
|
10
|
+
metadata?: Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
declare class FileService<TFile> {
|
|
13
|
+
prefix: string;
|
|
14
|
+
fileRepository: FileRepository<TFile>;
|
|
15
|
+
objectStorage: ObjectStorage;
|
|
16
|
+
constructor({ prefix, fileRepository, objectStorage, }: {
|
|
17
|
+
prefix?: string;
|
|
18
|
+
fileRepository: FileRepository<TFile>;
|
|
19
|
+
objectStorage: ObjectStorage;
|
|
20
|
+
});
|
|
21
|
+
generateSignedUrl(params: UploadFileParams): Promise<{
|
|
22
|
+
file: Awaited<TFile>;
|
|
23
|
+
signedUrl: string;
|
|
24
|
+
}>;
|
|
25
|
+
putFile(buffer: Buffer, params: UploadFileParams): Promise<{
|
|
26
|
+
key: string;
|
|
27
|
+
file: Awaited<TFile>;
|
|
28
|
+
}>;
|
|
29
|
+
private createFileReference;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { FileService, type UploadFileParams };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ObjectStorage } from './object_storage.js';
|
|
2
|
+
import { FileRepository } from './file_repository.js';
|
|
3
|
+
import '@aws-sdk/client-s3';
|
|
4
|
+
|
|
5
|
+
type UploadFileParams = {
|
|
6
|
+
name: string;
|
|
7
|
+
userId?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
size?: number;
|
|
10
|
+
metadata?: Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
declare class FileService<TFile> {
|
|
13
|
+
prefix: string;
|
|
14
|
+
fileRepository: FileRepository<TFile>;
|
|
15
|
+
objectStorage: ObjectStorage;
|
|
16
|
+
constructor({ prefix, fileRepository, objectStorage, }: {
|
|
17
|
+
prefix?: string;
|
|
18
|
+
fileRepository: FileRepository<TFile>;
|
|
19
|
+
objectStorage: ObjectStorage;
|
|
20
|
+
});
|
|
21
|
+
generateSignedUrl(params: UploadFileParams): Promise<{
|
|
22
|
+
file: Awaited<TFile>;
|
|
23
|
+
signedUrl: string;
|
|
24
|
+
}>;
|
|
25
|
+
putFile(buffer: Buffer, params: UploadFileParams): Promise<{
|
|
26
|
+
key: string;
|
|
27
|
+
file: Awaited<TFile>;
|
|
28
|
+
}>;
|
|
29
|
+
private createFileReference;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { FileService, type UploadFileParams };
|
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/file
|
|
20
|
+
// src/file/file_service.ts
|
|
21
21
|
var file_service_exports = {};
|
|
22
22
|
__export(file_service_exports, {
|
|
23
23
|
FileService: () => FileService
|
|
@@ -26,32 +26,38 @@ module.exports = __toCommonJS(file_service_exports);
|
|
|
26
26
|
var import_uuid = require("uuid");
|
|
27
27
|
var FileService = class {
|
|
28
28
|
prefix;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
constructor(
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
fileRepository;
|
|
30
|
+
objectStorage;
|
|
31
|
+
constructor({
|
|
32
|
+
prefix = "user",
|
|
33
|
+
fileRepository,
|
|
34
|
+
objectStorage
|
|
34
35
|
}) {
|
|
35
36
|
this.prefix = prefix;
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
37
|
+
this.fileRepository = fileRepository;
|
|
38
|
+
this.objectStorage = objectStorage;
|
|
38
39
|
}
|
|
39
|
-
async generateSignedUrl(
|
|
40
|
+
async generateSignedUrl(params) {
|
|
41
|
+
const { key, file } = await this.createFileReference(params);
|
|
42
|
+
const signedUrl = await this.objectStorage.generateSignedUrl(key, {
|
|
43
|
+
contentType: params.type
|
|
44
|
+
});
|
|
45
|
+
return { file, signedUrl };
|
|
46
|
+
}
|
|
47
|
+
async putFile(buffer, params) {
|
|
48
|
+
const { key, file } = await this.createFileReference(params);
|
|
49
|
+
await this.objectStorage.put(key, buffer);
|
|
50
|
+
return { key, file };
|
|
51
|
+
}
|
|
52
|
+
async createFileReference(params) {
|
|
40
53
|
const id = (0, import_uuid.v4)();
|
|
41
|
-
const key = `${this.prefix}/${id}/${name}`;
|
|
42
|
-
const file = await this.
|
|
54
|
+
const key = `${this.prefix}/${id}/${params.name}`;
|
|
55
|
+
const file = await this.fileRepository.createFile({
|
|
43
56
|
id,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
type,
|
|
47
|
-
size,
|
|
48
|
-
metadata,
|
|
49
|
-
key
|
|
50
|
-
});
|
|
51
|
-
const signedUrl = await this.OBJECT_STORAGE.generateSignedUrl(key, {
|
|
52
|
-
contentType: type
|
|
57
|
+
key,
|
|
58
|
+
...params
|
|
53
59
|
});
|
|
54
|
-
return {
|
|
60
|
+
return { key, file };
|
|
55
61
|
}
|
|
56
62
|
};
|
|
57
63
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/file/file_service.ts
|
|
2
|
+
import { v4 } from "uuid";
|
|
3
|
+
var FileService = class {
|
|
4
|
+
prefix;
|
|
5
|
+
fileRepository;
|
|
6
|
+
objectStorage;
|
|
7
|
+
constructor({
|
|
8
|
+
prefix = "user",
|
|
9
|
+
fileRepository,
|
|
10
|
+
objectStorage
|
|
11
|
+
}) {
|
|
12
|
+
this.prefix = prefix;
|
|
13
|
+
this.fileRepository = fileRepository;
|
|
14
|
+
this.objectStorage = objectStorage;
|
|
15
|
+
}
|
|
16
|
+
async generateSignedUrl(params) {
|
|
17
|
+
const { key, file } = await this.createFileReference(params);
|
|
18
|
+
const signedUrl = await this.objectStorage.generateSignedUrl(key, {
|
|
19
|
+
contentType: params.type
|
|
20
|
+
});
|
|
21
|
+
return { file, signedUrl };
|
|
22
|
+
}
|
|
23
|
+
async putFile(buffer, params) {
|
|
24
|
+
const { key, file } = await this.createFileReference(params);
|
|
25
|
+
await this.objectStorage.put(key, buffer);
|
|
26
|
+
return { key, file };
|
|
27
|
+
}
|
|
28
|
+
async createFileReference(params) {
|
|
29
|
+
const id = v4();
|
|
30
|
+
const key = `${this.prefix}/${id}/${params.name}`;
|
|
31
|
+
const file = await this.fileRepository.createFile({
|
|
32
|
+
id,
|
|
33
|
+
key,
|
|
34
|
+
...params
|
|
35
|
+
});
|
|
36
|
+
return { key, file };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
FileService
|
|
41
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AuthService } from '../../auth/auth_service.mjs';
|
|
2
|
+
import { FileRepository } from '../file_repository.mjs';
|
|
3
|
+
import 'jose';
|
|
4
|
+
import 'react-router';
|
|
5
|
+
import '../../auth/jwt_manager.mjs';
|
|
6
|
+
import '../object_storage.mjs';
|
|
7
|
+
import '@aws-sdk/client-s3';
|
|
8
|
+
import '../../auth/auth_repository.mjs';
|
|
9
|
+
|
|
10
|
+
declare const deleteFileHandler: <TFile>(request: Request, { fileId }: {
|
|
11
|
+
fileId: string;
|
|
12
|
+
}, { authService, fileRepository, }: {
|
|
13
|
+
authService: AuthService;
|
|
14
|
+
fileRepository: FileRepository<TFile>;
|
|
15
|
+
}) => Promise<Response>;
|
|
16
|
+
|
|
17
|
+
export { deleteFileHandler };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AuthService } from '../../auth/auth_service.js';
|
|
2
|
+
import { FileRepository } from '../file_repository.js';
|
|
3
|
+
import 'jose';
|
|
4
|
+
import 'react-router';
|
|
5
|
+
import '../../auth/jwt_manager.js';
|
|
6
|
+
import '../object_storage.js';
|
|
7
|
+
import '@aws-sdk/client-s3';
|
|
8
|
+
import '../../auth/auth_repository.js';
|
|
9
|
+
|
|
10
|
+
declare const deleteFileHandler: <TFile>(request: Request, { fileId }: {
|
|
11
|
+
fileId: string;
|
|
12
|
+
}, { authService, fileRepository, }: {
|
|
13
|
+
authService: AuthService;
|
|
14
|
+
fileRepository: FileRepository<TFile>;
|
|
15
|
+
}) => Promise<Response>;
|
|
16
|
+
|
|
17
|
+
export { deleteFileHandler };
|
|
@@ -17,14 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
23
|
-
|
|
20
|
+
// src/file/handlers/delete_file.ts
|
|
21
|
+
var delete_file_exports = {};
|
|
22
|
+
__export(delete_file_exports, {
|
|
23
|
+
deleteFileHandler: () => deleteFileHandler
|
|
24
24
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
25
|
+
module.exports = __toCommonJS(delete_file_exports);
|
|
26
26
|
|
|
27
|
-
// src/http
|
|
27
|
+
// src/http/response.ts
|
|
28
28
|
var createJsonResponse = (status) => {
|
|
29
29
|
return (data = {}, init) => {
|
|
30
30
|
return Response.json(data, { status, ...init });
|
|
@@ -74,26 +74,26 @@ var INTERNAL_SERVER_ERROR = createException(
|
|
|
74
74
|
"\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
|
|
75
75
|
);
|
|
76
76
|
|
|
77
|
-
// src/
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
// src/file/handlers/delete_file.ts
|
|
78
|
+
var deleteFileHandler = async (request, { fileId }, {
|
|
79
|
+
authService,
|
|
80
|
+
fileRepository
|
|
81
81
|
}) => {
|
|
82
|
-
const auth = await
|
|
83
|
-
const file = await
|
|
82
|
+
const auth = await authService.verifyOrRefresh(request);
|
|
83
|
+
const file = await fileRepository.findFileById(fileId);
|
|
84
84
|
const headers = {
|
|
85
85
|
"Access-Control-Allow-Origin": "*"
|
|
86
86
|
};
|
|
87
87
|
if (!file) {
|
|
88
88
|
return NOT_FOUND("\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.", { headers });
|
|
89
89
|
}
|
|
90
|
-
if (!
|
|
90
|
+
if (!fileRepository.hasPermission(file, auth?.userId)) {
|
|
91
91
|
return FORBIDDEN("\uD30C\uC77C\uC744 \uC0AD\uC81C\uD560 \uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.", { headers });
|
|
92
92
|
}
|
|
93
|
-
await
|
|
93
|
+
await fileRepository.deleteFile(fileId);
|
|
94
94
|
return NO_CONTENT({ headers });
|
|
95
95
|
};
|
|
96
96
|
// Annotate the CommonJS export names for ESM import in node:
|
|
97
97
|
0 && (module.exports = {
|
|
98
|
-
|
|
98
|
+
deleteFileHandler
|
|
99
99
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/http
|
|
1
|
+
// src/http/response.ts
|
|
2
2
|
var createJsonResponse = (status) => {
|
|
3
3
|
return (data = {}, init) => {
|
|
4
4
|
return Response.json(data, { status, ...init });
|
|
@@ -48,25 +48,25 @@ var INTERNAL_SERVER_ERROR = createException(
|
|
|
48
48
|
"\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
|
|
49
49
|
);
|
|
50
50
|
|
|
51
|
-
// src/
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
// src/file/handlers/delete_file.ts
|
|
52
|
+
var deleteFileHandler = async (request, { fileId }, {
|
|
53
|
+
authService,
|
|
54
|
+
fileRepository
|
|
55
55
|
}) => {
|
|
56
|
-
const auth = await
|
|
57
|
-
const file = await
|
|
56
|
+
const auth = await authService.verifyOrRefresh(request);
|
|
57
|
+
const file = await fileRepository.findFileById(fileId);
|
|
58
58
|
const headers = {
|
|
59
59
|
"Access-Control-Allow-Origin": "*"
|
|
60
60
|
};
|
|
61
61
|
if (!file) {
|
|
62
62
|
return NOT_FOUND("\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.", { headers });
|
|
63
63
|
}
|
|
64
|
-
if (!
|
|
64
|
+
if (!fileRepository.hasPermission(file, auth?.userId)) {
|
|
65
65
|
return FORBIDDEN("\uD30C\uC77C\uC744 \uC0AD\uC81C\uD560 \uAD8C\uD55C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.", { headers });
|
|
66
66
|
}
|
|
67
|
-
await
|
|
67
|
+
await fileRepository.deleteFile(fileId);
|
|
68
68
|
return NO_CONTENT({ headers });
|
|
69
69
|
};
|
|
70
70
|
export {
|
|
71
|
-
|
|
71
|
+
deleteFileHandler
|
|
72
72
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AuthService } from '../../auth/auth_service.mjs';
|
|
2
|
+
import { FileService } from '../file_service.mjs';
|
|
3
|
+
import 'jose';
|
|
4
|
+
import 'react-router';
|
|
5
|
+
import '../../auth/jwt_manager.mjs';
|
|
6
|
+
import '../object_storage.mjs';
|
|
7
|
+
import '@aws-sdk/client-s3';
|
|
8
|
+
import '../../auth/auth_repository.mjs';
|
|
9
|
+
import '../file_repository.mjs';
|
|
10
|
+
|
|
11
|
+
declare const uploadFileHandler: <TFile>(request: Request, { authService, fileService, }: {
|
|
12
|
+
authService: AuthService;
|
|
13
|
+
fileService: FileService<TFile>;
|
|
14
|
+
}) => Promise<Response>;
|
|
15
|
+
|
|
16
|
+
export { uploadFileHandler };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AuthService } from '../../auth/auth_service.js';
|
|
2
|
+
import { FileService } from '../file_service.js';
|
|
3
|
+
import 'jose';
|
|
4
|
+
import 'react-router';
|
|
5
|
+
import '../../auth/jwt_manager.js';
|
|
6
|
+
import '../object_storage.js';
|
|
7
|
+
import '@aws-sdk/client-s3';
|
|
8
|
+
import '../../auth/auth_repository.js';
|
|
9
|
+
import '../file_repository.js';
|
|
10
|
+
|
|
11
|
+
declare const uploadFileHandler: <TFile>(request: Request, { authService, fileService, }: {
|
|
12
|
+
authService: AuthService;
|
|
13
|
+
fileService: FileService<TFile>;
|
|
14
|
+
}) => Promise<Response>;
|
|
15
|
+
|
|
16
|
+
export { uploadFileHandler };
|
|
@@ -17,14 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
23
|
-
|
|
20
|
+
// src/file/handlers/upload_file.ts
|
|
21
|
+
var upload_file_exports = {};
|
|
22
|
+
__export(upload_file_exports, {
|
|
23
|
+
uploadFileHandler: () => uploadFileHandler
|
|
24
24
|
});
|
|
25
|
-
module.exports = __toCommonJS(
|
|
25
|
+
module.exports = __toCommonJS(upload_file_exports);
|
|
26
26
|
|
|
27
|
-
// src/http
|
|
27
|
+
// src/http/response.ts
|
|
28
28
|
var createJsonResponse = (status) => {
|
|
29
29
|
return (data = {}, init) => {
|
|
30
30
|
return Response.json(data, { status, ...init });
|
|
@@ -68,12 +68,12 @@ var INTERNAL_SERVER_ERROR = createException(
|
|
|
68
68
|
"\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
|
|
69
69
|
);
|
|
70
70
|
|
|
71
|
-
// src/
|
|
72
|
-
var
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
// src/file/handlers/upload_file.ts
|
|
72
|
+
var uploadFileHandler = async (request, {
|
|
73
|
+
authService,
|
|
74
|
+
fileService
|
|
75
75
|
}) => {
|
|
76
|
-
const auth = await
|
|
76
|
+
const auth = await authService.verifyOrRefresh(request);
|
|
77
77
|
const { name, type, size, metadata } = await request.json();
|
|
78
78
|
const headers = {
|
|
79
79
|
"Access-Control-Allow-Origin": "*"
|
|
@@ -85,7 +85,7 @@ var fileUploadHandler = async (request, {
|
|
|
85
85
|
return BAD_REQUEST("\uD30C\uC77C \uD0C0\uC785\uC774 \uD544\uC694\uD574\uC694.", { headers });
|
|
86
86
|
}
|
|
87
87
|
try {
|
|
88
|
-
const result = await
|
|
88
|
+
const result = await fileService.generateSignedUrl({
|
|
89
89
|
userId: auth?.userId,
|
|
90
90
|
name,
|
|
91
91
|
type,
|
|
@@ -102,5 +102,5 @@ var fileUploadHandler = async (request, {
|
|
|
102
102
|
};
|
|
103
103
|
// Annotate the CommonJS export names for ESM import in node:
|
|
104
104
|
0 && (module.exports = {
|
|
105
|
-
|
|
105
|
+
uploadFileHandler
|
|
106
106
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/http
|
|
1
|
+
// src/http/response.ts
|
|
2
2
|
var createJsonResponse = (status) => {
|
|
3
3
|
return (data = {}, init) => {
|
|
4
4
|
return Response.json(data, { status, ...init });
|
|
@@ -42,12 +42,12 @@ var INTERNAL_SERVER_ERROR = createException(
|
|
|
42
42
|
"\uC608\uAE30\uCE58 \uBABB\uD55C \uC624\uB958\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."
|
|
43
43
|
);
|
|
44
44
|
|
|
45
|
-
// src/
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
// src/file/handlers/upload_file.ts
|
|
46
|
+
var uploadFileHandler = async (request, {
|
|
47
|
+
authService,
|
|
48
|
+
fileService
|
|
49
49
|
}) => {
|
|
50
|
-
const auth = await
|
|
50
|
+
const auth = await authService.verifyOrRefresh(request);
|
|
51
51
|
const { name, type, size, metadata } = await request.json();
|
|
52
52
|
const headers = {
|
|
53
53
|
"Access-Control-Allow-Origin": "*"
|
|
@@ -59,7 +59,7 @@ var fileUploadHandler = async (request, {
|
|
|
59
59
|
return BAD_REQUEST("\uD30C\uC77C \uD0C0\uC785\uC774 \uD544\uC694\uD574\uC694.", { headers });
|
|
60
60
|
}
|
|
61
61
|
try {
|
|
62
|
-
const result = await
|
|
62
|
+
const result = await fileService.generateSignedUrl({
|
|
63
63
|
userId: auth?.userId,
|
|
64
64
|
name,
|
|
65
65
|
type,
|
|
@@ -75,5 +75,5 @@ var fileUploadHandler = async (request, {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
export {
|
|
78
|
-
|
|
78
|
+
uploadFileHandler
|
|
79
79
|
};
|
|
@@ -3,7 +3,9 @@ import * as _aws_sdk_client_s3 from '@aws-sdk/client-s3';
|
|
|
3
3
|
declare class ObjectStorage {
|
|
4
4
|
private client;
|
|
5
5
|
private bucketName;
|
|
6
|
-
constructor(bucketName:
|
|
6
|
+
constructor({ bucketName }: {
|
|
7
|
+
bucketName: string;
|
|
8
|
+
});
|
|
7
9
|
generateSignedUrl(key: string, { contentType, expiresIn, }?: {
|
|
8
10
|
contentType?: string;
|
|
9
11
|
expiresIn?: number;
|
|
@@ -3,7 +3,9 @@ import * as _aws_sdk_client_s3 from '@aws-sdk/client-s3';
|
|
|
3
3
|
declare class ObjectStorage {
|
|
4
4
|
private client;
|
|
5
5
|
private bucketName;
|
|
6
|
-
constructor(bucketName:
|
|
6
|
+
constructor({ bucketName }: {
|
|
7
|
+
bucketName: string;
|
|
8
|
+
});
|
|
7
9
|
generateSignedUrl(key: string, { contentType, expiresIn, }?: {
|
|
8
10
|
contentType?: string;
|
|
9
11
|
expiresIn?: number;
|
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/file
|
|
20
|
+
// src/file/object_storage.ts
|
|
21
21
|
var object_storage_exports = {};
|
|
22
22
|
__export(object_storage_exports, {
|
|
23
23
|
ObjectStorage: () => ObjectStorage
|
|
@@ -30,7 +30,7 @@ var ObjectStorage = class {
|
|
|
30
30
|
region: "ap-northeast-2"
|
|
31
31
|
});
|
|
32
32
|
bucketName;
|
|
33
|
-
constructor(bucketName) {
|
|
33
|
+
constructor({ bucketName }) {
|
|
34
34
|
this.bucketName = bucketName;
|
|
35
35
|
}
|
|
36
36
|
async generateSignedUrl(key, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/file
|
|
1
|
+
// src/file/object_storage.ts
|
|
2
2
|
import {
|
|
3
3
|
GetObjectCommand,
|
|
4
4
|
PutObjectCommand,
|
|
@@ -10,7 +10,7 @@ var ObjectStorage = class {
|
|
|
10
10
|
region: "ap-northeast-2"
|
|
11
11
|
});
|
|
12
12
|
bucketName;
|
|
13
|
-
constructor(bucketName) {
|
|
13
|
+
constructor({ bucketName }) {
|
|
14
14
|
this.bucketName = bucketName;
|
|
15
15
|
}
|
|
16
16
|
async generateSignedUrl(key, {
|
|
@@ -8,11 +8,11 @@ type ResponsiveImageProps = Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes
|
|
|
8
8
|
};
|
|
9
9
|
ratio?: number;
|
|
10
10
|
};
|
|
11
|
-
declare const createResponsiveImage: (
|
|
12
|
-
|
|
13
|
-
}) =>
|
|
11
|
+
declare const createResponsiveImage: ({ cdnOrigin }: {
|
|
12
|
+
cdnOrigin: string;
|
|
13
|
+
}) => React.FC<ResponsiveImageProps>;
|
|
14
14
|
|
|
15
|
-
declare function generateSrcSet(image: HTMLImageElement | string, ratio?: number, props?: {
|
|
15
|
+
declare function generateSrcSet(cdnOrigin: string, image: HTMLImageElement | string, ratio?: number, props?: {
|
|
16
16
|
width?: string | number;
|
|
17
17
|
height?: string | number;
|
|
18
18
|
}): string | undefined;
|
|
@@ -8,11 +8,11 @@ type ResponsiveImageProps = Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes
|
|
|
8
8
|
};
|
|
9
9
|
ratio?: number;
|
|
10
10
|
};
|
|
11
|
-
declare const createResponsiveImage: (
|
|
12
|
-
|
|
13
|
-
}) =>
|
|
11
|
+
declare const createResponsiveImage: ({ cdnOrigin }: {
|
|
12
|
+
cdnOrigin: string;
|
|
13
|
+
}) => React.FC<ResponsiveImageProps>;
|
|
14
14
|
|
|
15
|
-
declare function generateSrcSet(image: HTMLImageElement | string, ratio?: number, props?: {
|
|
15
|
+
declare function generateSrcSet(cdnOrigin: string, image: HTMLImageElement | string, ratio?: number, props?: {
|
|
16
16
|
width?: string | number;
|
|
17
17
|
height?: string | number;
|
|
18
18
|
}): string | undefined;
|