Update to Node.js v24 (#10419)
This commit is contained in:
@@ -20,10 +20,13 @@ export class AppContext {
|
||||
fonts: {name: string; data: Buffer}[]
|
||||
abortController = new AbortController()
|
||||
|
||||
constructor(private opts: AppContextOptions) {
|
||||
this.cfg = this.opts.cfg
|
||||
this.appviewAgent = this.opts.appviewAgent
|
||||
this.fonts = this.opts.fonts
|
||||
private opts: AppContextOptions
|
||||
|
||||
constructor(opts: AppContextOptions) {
|
||||
this.opts = opts
|
||||
this.cfg = opts.cfg
|
||||
this.appviewAgent = opts.appviewAgent
|
||||
this.fonts = opts.fonts
|
||||
}
|
||||
|
||||
static async fromConfig(cfg: Config, overrides?: Partial<AppContextOptions>) {
|
||||
|
||||
@@ -19,10 +19,13 @@ export class CardService {
|
||||
private terminator?: HttpTerminator
|
||||
private metricsTerminator?: HttpTerminator
|
||||
|
||||
constructor(
|
||||
public app: express.Application,
|
||||
public ctx: AppContext,
|
||||
) {}
|
||||
public app: express.Application
|
||||
public ctx: AppContext
|
||||
|
||||
constructor(app: express.Application, ctx: AppContext) {
|
||||
this.app = app
|
||||
this.ctx = ctx
|
||||
}
|
||||
|
||||
static async create(cfg: Config): Promise<CardService> {
|
||||
let app = express()
|
||||
|
||||
@@ -38,11 +38,11 @@ export default function (ctx: AppContext, app: Express) {
|
||||
}
|
||||
const imageEntries = await Promise.all(
|
||||
[starterPack.creator]
|
||||
.concat(starterPack.listItemsSample.map(li => li.subject))
|
||||
.concat((starterPack.listItemsSample ?? []).map(li => li.subject))
|
||||
// has avatar
|
||||
.filter(p => p.avatar)
|
||||
// no sensitive labels
|
||||
.filter(p => !p.labels.some(l => hideAvatarLabels.has(l.val)))
|
||||
.filter(p => !p.labels?.some(l => hideAvatarLabels.has(l.val)))
|
||||
.map(async p => {
|
||||
try {
|
||||
assert(p.avatar)
|
||||
@@ -58,7 +58,12 @@ export default function (ctx: AppContext, app: Express) {
|
||||
}),
|
||||
)
|
||||
const images = new Map(
|
||||
imageEntries.filter(([_, image]) => image !== null).slice(0, 7),
|
||||
imageEntries
|
||||
.filter(
|
||||
(entry): entry is readonly [string, Buffer<ArrayBuffer>] =>
|
||||
entry[1] !== null,
|
||||
)
|
||||
.slice(0, 7),
|
||||
)
|
||||
const svg = await satori(
|
||||
<StarterPack starterPack={starterPack} images={images} />,
|
||||
@@ -68,8 +73,9 @@ export default function (ctx: AppContext, app: Express) {
|
||||
width: STARTERPACK_WIDTH,
|
||||
loadAdditionalAsset: async (code, text) => {
|
||||
if (code === 'emoji') {
|
||||
return await loadEmojiAsSvg(text)
|
||||
return (await loadEmojiAsSvg(text)) ?? ''
|
||||
}
|
||||
return ''
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user