File tree Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env tsx
2+
3+ import * as readline from "readline/promises" ;
4+
5+ const rl = readline . createInterface ( {
6+ input : process . stdin ,
7+ output : process . stdout ,
8+ } ) ;
9+
10+ const endpoint =
11+ process . env . RIVET_ENDPOINT ||
12+ ( await rl . question ( "Endpoint (default: api.rivet.dev): " ) ) . trim ( ) ||
13+ "api.rivet.dev" ;
14+
15+ const rivetToken =
16+ process . env . RIVET_TOKEN ||
17+ ( await rl . question ( "Rivet Token: " ) ) . trim ( ) ;
18+
19+ if ( ! rivetToken ) {
20+ console . error ( "Error: Rivet Token is required" ) ;
21+ process . exit ( 1 ) ;
22+ }
23+
24+ const actorId = ( await rl . question ( "Actor ID: " ) ) . trim ( ) ;
25+
26+ if ( ! actorId ) {
27+ console . error ( "Error: Actor ID is required" ) ;
28+ process . exit ( 1 ) ;
29+ }
30+
31+ rl . close ( ) ;
32+
33+ const url = endpoint . startsWith ( "http" ) ? endpoint : `https://${ endpoint } ` ;
34+
35+ // Print equivalent curl command
36+ console . log ( "Equivalent curl command:" ) ;
37+ console . log (
38+ `curl -H "x-rivet-target: actor" -H "x-rivet-actor: ${ actorId } " -H "x-rivet-token: ${ rivetToken } " ${ url } ` ,
39+ ) ;
40+ console . log ( ) ;
41+
42+ const response = await fetch ( url , {
43+ method : "GET" ,
44+ headers : {
45+ "x-rivet-target" : "actor" ,
46+ "x-rivet-actor" : actorId ,
47+ "x-rivet-token" : rivetToken ,
48+ } ,
49+ } ) ;
50+
51+ if ( ! response . ok ) {
52+ console . error ( `Error: ${ response . status } ${ response . statusText } ` ) ;
53+ console . error ( await response . text ( ) ) ;
54+ process . exit ( 1 ) ;
55+ }
56+
57+ const data = await response . text ( ) ;
58+
59+ console . log ( data ) ;
You can’t perform that action at this time.
0 commit comments