File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -111,4 +111,6 @@ export enum CommandExitCodes {
111111
112112 InvalidInput = 5 ,
113113 InvalidActorJson = 5 ,
114+
115+ NotImplemented = 255 ,
114116}
You can’t perform that action at this time.
0 commit comments