Skip to content

Commit 88aadee

Browse files
authored
feat: Add get-public-url command (#756)
This is a temporary solution, a new mechanisms for securely sharing keyvalue store items is in development.
1 parent f413d83 commit 88aadee

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { ACTOR_ENV_VARS, APIFY_ENV_VARS } from '@apify/consts';
2+
import { Args } from '@oclif/core';
3+
4+
import { ApifyCommand } from '../../lib/apify_command.js';
5+
import { CommandExitCodes } from '../../lib/consts.js';
6+
import { error } from '../../lib/outputs.js';
7+
8+
export class GetPublicUrlCommand extends ApifyCommand<typeof GetPublicUrlCommand> {
9+
static override description = 'Get an HTTP URL that allows public access to a key-value store item.';
10+
11+
static override args = {
12+
key: Args.string({
13+
required: true,
14+
description: 'Key of the record in key-value store',
15+
}),
16+
};
17+
18+
async run() {
19+
const { key } = this.args;
20+
21+
if ([undefined, 'false', ''].includes(process.env[APIFY_ENV_VARS.IS_AT_HOME])) {
22+
error({ message: 'get-public-url is not yet implemented for local development' });
23+
process.exitCode = CommandExitCodes.NotImplemented;
24+
return;
25+
}
26+
27+
const apiBase = process.env[APIFY_ENV_VARS.API_PUBLIC_BASE_URL];
28+
const storeId = process.env[ACTOR_ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID];
29+
30+
console.log(`${apiBase}/v2/key-value-stores/${storeId}/records/${key}`);
31+
}
32+
}

src/lib/consts.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,6 @@ export enum CommandExitCodes {
111111

112112
InvalidInput = 5,
113113
InvalidActorJson = 5,
114+
115+
NotImplemented = 255,
114116
}

0 commit comments

Comments
 (0)