Skip to content

Commit

Permalink
add some typings for name
Browse files Browse the repository at this point in the history
  • Loading branch information
cmunns committed Mar 22, 2022
1 parent 26fd543 commit 7bdfba3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/api/src/bindings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export type NFT = {
/**
* Name of the JWT token used to create this NFT.
*/
name?: string
/**
* Optional name of the file(s) uploaded as NFT.
*/
scope: string
/**
* Date this NFT was created in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: YYYY-MM-DDTHH:MM:SSZ.
Expand Down
6 changes: 5 additions & 1 deletion packages/api/src/routes/nfts-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export async function nftUpload(event, ctx) {
let structure
/** @type {Blob} */
let car
/** @type {string} */
let name

if (isCar) {
car = blob
Expand Down Expand Up @@ -111,6 +113,7 @@ export async function nftUpload(event, ctx) {
* structure: DagStructure
* files: Array<{ name: string; type?: string }>
* meta?: Record<string, unknown>
* name?: string
* }} UploadCarInput
* @param {UploadCarInput} params
*/
Expand All @@ -127,7 +130,7 @@ export async function uploadCar(params) {
* @param {CarStat} stat
*/
export async function uploadCarWithStat(
{ ctx, user, key, car, uploadType = 'Car', mimeType, files, meta },
{ ctx, user, key, car, uploadType = 'Car', mimeType, files, meta, name },
stat
) {
const [added, backupUrl] = await Promise.all([
Expand All @@ -150,6 +153,7 @@ export async function uploadCarWithStat(
meta,
key_id: key?.id,
backup_urls: backupUrl ? [backupUrl] : [],
name: name,
})

return upload
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/utils/db-transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function toNFTResponse(upload, sourceCid) {
scope: upload.key ? upload.key.name : 'session',
files: upload.files,
size: upload.content.dag_size || 0,
name: upload.name,
pin: {
cid: sourceCid || upload.source_cid,
created: upload.content.pin[0].inserted_at,
Expand Down

0 comments on commit 7bdfba3

Please sign in to comment.