-
Notifications
You must be signed in to change notification settings - Fork 56
feat: sign record's public url #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
17241fe
3b40e57
13cdc63
b01c22a
7a74be9
a404dbf
23505f1
af0f70b
d2a11f3
1bf60b2
d830ed1
9477a14
cf7144e
00a96f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { Actor, log } from 'apify'; | ||
|
|
||
| await Actor.init(); | ||
|
|
||
| const { data, recordKey } = await Actor.getInput(); | ||
|
|
||
| await Actor.setValue(recordKey, JSON.stringify(data), { contentType: `application/json` }); | ||
|
|
||
| const defaultKeyValueStore = await Actor.openKeyValueStore(); | ||
| const publicUrl = defaultKeyValueStore.getPublicUrl(recordKey); | ||
|
|
||
| // Here we store the url itself | ||
| await Actor.setValue('urlToPublicData', publicUrl); | ||
|
|
||
| log.info('Generated public url', { publicUrl }); | ||
|
|
||
| await Actor.pushData({ publicUrl }); | ||
|
|
||
| await Actor.exit(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import assert from 'node:assert/strict'; | ||
|
|
||
| import { ApifyClient } from 'apify'; | ||
|
|
||
| const PUBLIC_DATA = { exposedData: 'test' }; | ||
|
|
||
| const client = new ApifyClient({ | ||
| token: process.env.APIFY_TOKEN, | ||
| }); | ||
|
|
||
| const actor = client.actor(process.argv[2]); | ||
|
|
||
| const run = await actor.call({ data: PUBLIC_DATA, recordKey: 'public-record-key' }, { waitSecs: 15 }); | ||
|
||
| assert.equal(run.exitCode, 0); | ||
|
|
||
| const publicUrl = await client.keyValueStore(run.defaultKeyValueStoreId).getRecord('urlToPublicData'); | ||
| const data = await fetch(publicUrl.value).then((res) => res.json()); | ||
|
|
||
| assert.deepEqual(data, PUBLIC_DATA); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets add a comment here about the difference between
apiBaseUrlandapiPublicBaseUrl