refactor: move barcode generation to document server
This commit is contained in:
@@ -5,7 +5,6 @@ import { z } from 'zod'
|
||||
import { EmailService } from '../services/email'
|
||||
import { getEmailTemplate } from '../templates'
|
||||
import { Language } from '../types'
|
||||
import { toBuffer } from 'bwip-js/node'
|
||||
|
||||
const emailRouter = new Hono()
|
||||
const emailService = new EmailService()
|
||||
@@ -18,20 +17,7 @@ const sendEmailSchema = z.object({
|
||||
})
|
||||
|
||||
async function generateBarcodeDataURL(data) {
|
||||
return `https://barcodeapi.org/api/128/${data}`
|
||||
const buffer = await toBuffer({
|
||||
bcid: 'code128',
|
||||
text: data,
|
||||
scale: 3,
|
||||
height: 10,
|
||||
includetext: true,
|
||||
textxalign: 'center',
|
||||
});
|
||||
|
||||
const base64Data = buffer.toString('base64');
|
||||
const dataURL = `data:image/png;base64,${base64Data}`;
|
||||
|
||||
return dataURL;
|
||||
return `${process.env.DOCUMENT_SERVER_URL}/v1/barcodes/code128/${data}`
|
||||
}
|
||||
|
||||
emailRouter.post('/', bearerAuth({ token: process.env.AUTHKEY }), zValidator('json', sendEmailSchema), async (c) => {
|
||||
|
||||
Reference in New Issue
Block a user