微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

nodejs passkit 无法将 req 类型设置为 passkit

如何解决nodejs passkit 无法将 req 类型设置为 passkit

我正在尝试创建一个端点来为 ios 生成钱包通行证。 因此我创建了这个端点:

const express = require('express');
const router = express.Router();
const nodemailer = require("nodemailer");
const fs = require('fs');
const { promisify } = require('util');
const readFile = promisify(fs.readFile);
 const { Template } = require("@walletpass/pass-js");

router.get('/create',async(req,res) => {
    const template = new Template("coupon",{
    passtypeIdentifier: "pass.eatsmart.smartcard",teamIdentifier: "76GERHHTV9",backgroundColor: "red",organizationName: "CLATE UG",sharingProhibited: true
  });

  await template.images.add("logo","templates/templatesV2/images/facebook-logo-white.png")
  await template.images.add("icon","templates/templatesV2/images/facebook-logo-white.png")

    await template.loadCertificate(
    "routes/pass.pem","mysecret"
    );

    const pass = template.createPass({
        serialNumber: "123456",description: "20% off"
      });

    req.status = 200;
    req.type = passkit.constants.PASS_MIME_TYPE;
    req.body = await pass.asBuffer();
      

});

module.exports = 路由器;

问题是 req.type 我还没有导入像 passkit 这样的东西,但我不知道我必须导入什么。或者有没有其他方法可以将密码包作为文件而不是原始文件返回。我认为创建过程应该可行,但我如何返回创建的密码包?

谢谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。