-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: ucanto invocation router with bare minimal store add invocation #4
Conversation
e9e5124
to
ac9e58c
Compare
7bdca7d
to
09f69bd
Compare
}) | ||
|
||
// TODO: Need to set ENV for dbEndpoint... | ||
test.skip('ucan-invocation-router', async (t) => { |
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.
@olizilla should we just drop this test to the lambda directly?
It is quite hard to inject the needed resources here... I would suggest follow up PR with more integration kind of tests, where we run the API Stack with all routes and perform tests using HTTP Calls.
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.
AYE
// Only use capability account for now to check if account is registered. | ||
// This must change to access account/info!! | ||
// We need to use https://github.com/web3-storage/w3protocol/blob/9d4b5bec1f0e870233b071ecb1c7a1e09189624b/packages/access/src/agent.js#L270 | ||
const account = capability.with |
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.
Will handle account/agent stuff in follow up PR
09f69bd
to
32ce987
Compare
32ce987
to
85fe048
Compare
payloadCID: 'string', | ||
applicationDID: 'string', | ||
origin: 'string', | ||
size: 'number', |
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.
is it size in bytes?
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.
*/ | ||
const storeTable = new Table(stack, 'store_table', { | ||
fields: { | ||
uploaderDID: 'string', |
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.
- Is this the account DID or the agent DID?
- camelCase?
stacks/api-stack.js
Outdated
* Force name of bucket to be "car-park-prod-0" in prod. | ||
*/ | ||
const ingestBucketCdkConfig = | ||
stack.stage === 'prod' ? { cdk: { bucket: { bucketName: 'car-park-prod-0' } } } : {} |
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.
Some of our per env config is in config.js. We should try and be consistent
stacks/api-stack.js
Outdated
const ingestBucketCdkConfig = | ||
stack.stage === 'prod' ? { cdk: { bucket: { bucketName: 'car-park-prod-0' } } } : {} | ||
|
||
const carStore = new Bucket(stack, 'carStore', { |
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.
in this file we have
- kebab-case
- camelCase
- snake_case
for resource ids. plz can we not.
stacks/api-stack.js
Outdated
permissions: [storeTable, carStore], | ||
environment: { | ||
STORE_TABLE_NAME: storeTable.tableName, | ||
CAR_STORE_BUCKET_NAME: carStore.bucketName |
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.
CAR_STORE_BUCKET_NAME: carStore.bucketName | |
STORE_BUCKET_NAME: carStore.bucketName |
import * as CBOR from '@ucanto/transport/cbor' | ||
|
||
import getServiceDid from '../authority.js' | ||
import { create as createCarStore } from '../buckets/car-store.js' |
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.
let's make the export from car-store be createCarStore
const AWS_REGION = process.env.AWS_REGION || 'us-west-2' | ||
|
||
/** | ||
* AWS API Gateway handler for POST / with ucan invocation router. |
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.
* AWS API Gateway handler for POST / with ucan invocation router. | |
* AWS HTTP Gateway handler for POST / with ucan invocation router. |
signingOptions: { | ||
region: AWS_REGION, | ||
secretAccessKey: AWS_SECRET_ACCESS_KEY, | ||
accessKeyId: AWS_ACCESS_KEY_ID, | ||
sessionToken: AWS_SESSION_TOKEN, | ||
bucket: bucketName, | ||
} |
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.
pass in a UrlSigner or similar to follow the pattern of holding the state in an object that we set in StoreTable and CarStore
} | ||
}) | ||
const response = await server.request({ | ||
// @ts-ignore - type is Record<string, string|string[]|undefined> |
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.
// @ts-ignore - type is Record<string, string|string[]|undefined> | |
// @ts-expect-error - type is Record<string, string|string[]|undefined> |
also i think we should review the type sig that ucanto server is using here. that seems like a reasonable thing to pass in.
api/database/store.js
Outdated
* Bind a link CID to an account | ||
* | ||
* @param {object} data | ||
* @param {string} data.accountDID |
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.
is really string type?
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.
Good start. Lots of nitpicks that we can iterate on together. GOOOOO VASCO!
This PR adds ucanto invocation router with
store/add
invocation.It integrates following AWS Resources in ApiStack:
w3up-cars
, but it is in wrong region, so let's just be coherent with CF naming and usecarpark-prod-0
? :)store_table
to track mapping between Users and stored CARsNotes:
services
folder renamed into API, so that we can useservice
folder per ucanto framework current used namesauthority.js
+config.js
in w3up repostore_table
like previously done inw3up
repo. Probably worth considering as follow up to add a column that tracks wether the CAR already made it to the bucket. On S3 Put Event, we would update that boolean. Otherwise, we have things in the DB that we don't have immediate visibility if the given CARs ever made itFollow up needs (will create issues):
store/add