-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathservice.js
33 lines (29 loc) · 1.08 KB
/
service.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import * as Sentry from '@sentry/serverless'
import * as UploadAPI from '@web3-storage/upload-api'
Sentry.AWSLambda.init({
environment: process.env.SST_STAGE,
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 0,
})
export const createServiceRouter = UploadAPI.createService
// S3 Put command has hard-limit of 5GiB.
// By limiting CAR size to 127*(1<<25), we guarantee max-4GiB-padded Filecoin pieces
// and have better utilization of Fil sector space.
// By receiving one more byte, we would immediatly get to 8GiB padded piece.
export const MAX_UPLOAD_SIZE = 127*(1<<25)
/**
* @param {import('@ucanto/interface').Signer} servicePrincipal
* @param {Omit<UploadAPI.UcantoServerContext, 'errorReporter'|'id'|'maxUploadSize'|'validateAuthorization'>} context
*/
export const createUcantoServer = (servicePrincipal, context) =>
UploadAPI.createServer({
...context,
id: servicePrincipal,
maxUploadSize: MAX_UPLOAD_SIZE,
errorReporter: {
catch: (/** @type {string | Error} */ err) => {
console.warn(err)
Sentry.AWSLambda.captureException(err)
},
},
})