Skip to content

Commit 186bc43

Browse files
committed
feat: add sourceBus()
1 parent 9540bf2 commit 186bc43

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/helix-shared-storage/src/storage.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function sanitizeKey(keyOrPath) {
8585
return keyOrPath;
8686
}
8787

88-
const BUCKET_KEYS = ['config', 'code', 'content', 'media'];
88+
const BUCKET_KEYS = ['config', 'code', 'content', 'media', 'source'];
8989

9090
export function parseBucketNames(bucketNames) {
9191
if (!bucketNames) {
@@ -800,6 +800,13 @@ export class HelixStorage {
800800
return this.bucket(this._bucketMap.media);
801801
}
802802

803+
/**
804+
* @returns {Bucket}
805+
*/
806+
sourceBus(disableR2 = false) {
807+
return this.bucket(this._bucketMap.source, disableR2);
808+
}
809+
803810
/**
804811
* @returns {Bucket}
805812
*/

packages/helix-shared-storage/test/storage.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ describe('Storage test', () => {
115115
config: 'helix-config-bus',
116116
content: 'helix-content-bus',
117117
media: 'helix-media-bus',
118+
source: 'helix-source-bus',
118119
});
119120
});
120121

@@ -124,6 +125,7 @@ describe('Storage test', () => {
124125
config: 'bucket-02',
125126
content: 'bucket-03',
126127
media: 'bucket-04',
128+
source: 'bucket-05',
127129
};
128130
assert.deepStrictEqual(parseBucketNames(JSON.stringify(map)), map);
129131
});
@@ -134,6 +136,7 @@ describe('Storage test', () => {
134136
config: 'bucket-02',
135137
content: 'bucket-03',
136138
media: 'bucket-04',
139+
source: 'bucket-05',
137140
};
138141
storage = new HelixStorage({
139142
region: AWS_REGION,
@@ -198,6 +201,10 @@ describe('Storage test', () => {
198201
assert.strictEqual(storage.configBus().bucket, 'helix-config-bus');
199202
});
200203

204+
it('can get the source-bus', () => {
205+
assert.strictEqual(storage.sourceBus().bucket, 'helix-source-bus');
206+
});
207+
201208
it('can get an object', async () => {
202209
nock('https://helix-code-bus.s3.fake.amazonaws.com')
203210
.get('/foo?x-id=GetObject')

0 commit comments

Comments
 (0)