Skip to content

Commit 0aa1709

Browse files
committed
feat(S3): init handler to list all objetcs of bucket
1 parent c23c29f commit 0aa1709

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

src/api/modules/v1/components/AWS/s3.component.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import {
33
CreateBucketOutput,
44
CreateBucketRequest,
55
PutObjectOutput,
6-
S3,
76
GetObjectOutput,
7+
ListObjectsOutput,
8+
S3,
89
} from "$deps";
910
import {
1011
env,
@@ -71,6 +72,24 @@ export class SimpleCloudStorage {
7172
}
7273
}
7374

75+
public async listObjects(): Promise<ListObjectsOutput | undefined> {
76+
return this.handleListObjects();
77+
}
78+
79+
private async handleListObjects() {
80+
const s3 = this.makeNewBucket();
81+
82+
try {
83+
const listObjects = await s3.listObjects({
84+
Bucket: this.bucketName,
85+
});
86+
87+
return listObjects;
88+
} catch (er) {
89+
log.error(er.message);
90+
}
91+
}
92+
7493
public async downloadFileFromS3(objectKey: string): Promise<string | undefined> {
7594
return this.handleDownloadFile(objectKey);
7695
}

src/api/modules/v1/components/Commands/Slinger.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { PersonService } from "$service/person/PersonService.ts";
33
import {
44
everyMinute,
55
every15Minute,
6+
start
67
} from '$deps';
78

89
export class Slinger {
@@ -11,8 +12,9 @@ export class Slinger {
1112
}
1213

1314
private init() {
14-
this.handleDisareByMinute();
15+
// this.handleDisareByMinute();
1516
this.handleDispareByFiftyMinute();
17+
start();
1618
}
1719

1820
private handleDisareByMinute() {
@@ -22,7 +24,7 @@ export class Slinger {
2224
}
2325

2426
private handleDispareByFiftyMinute() {
25-
every15Minute(async () => {
27+
everyMinute(async () => {
2628
await new PersonService().listenAndInsertPersonFromQueue();
2729
});
2830
}

src/deps/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export {
2424
export {
2525
type CreateBucketOutput,
2626
type CreateBucketRequest,
27-
type PutObjectOutput
27+
type PutObjectOutput,
28+
type ListObjectsOutput,
2829
} from "https://deno.land/x/[email protected]/services/s3/structs.ts";
2930

3031
export {
@@ -53,7 +54,8 @@ export {
5354
daily,
5455
monthly,
5556
weekly,
56-
yearly
57+
yearly,
58+
start
5759
} from "https://deno.land/x/[email protected]/cron.ts";
5860

5961
export {

0 commit comments

Comments
 (0)