const Mustache = require('mustache'); const github = require('./package.json').homepage; // class OpenGraph { http; domain; resourceId; filename; type; size; title = ''; author = ''; color = ''; showSize = false; constructor(http, domain, resourceId, { originalname, mimetype, size }) { this.http = http; this.domain = domain; this.resourceId = resourceId; this.type = mimetype; this.filename = originalname; this.size = size; } setTitle(title) { this.title = title; return this; } setAuthor(author) { this.author = author; return this; } setColor(color) { this.color = color; return this; } setShowSize(showSize) { this.showSize = showSize; return this; } build() { let view = { github, http: this.http, domain: this.domain, resourceId: this.resourceId, ogtype: this.type.includes('video') ? 'video.other' : 'image', type: this.type.includes('video') ? 'video' : 'image', ext: this.type.includes('video') ? '.mp4' : '', }; view.title = (this.title.length != 0) ? `` : ''; view.site = (this.author.length != 0) ? `` : ''; view.color = (this.color.length != 0) ? `` : ''; view.card = !this.type.includes('video') ? `` : ''; return Mustache.render(html, view); } } const html = `