fix: make canvas import optional for ARM64 compatibility
This commit is contained in:
@@ -2,7 +2,16 @@ import { Injectable, Logger, OnModuleInit } from "@nestjs/common";
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { createCanvas, loadImage } from "canvas";
|
// Canvas is optional – native module may fail on ARM64 (RPi)
|
||||||
|
let createCanvas: any;
|
||||||
|
let loadImage: any;
|
||||||
|
try {
|
||||||
|
const canvas = require("canvas");
|
||||||
|
createCanvas = canvas.createCanvas;
|
||||||
|
loadImage = canvas.loadImage;
|
||||||
|
} catch {
|
||||||
|
// Canvas unavailable – ImageRendererService methods will throw at runtime if called
|
||||||
|
}
|
||||||
import { PredictionCardDto } from "./dto/prediction-card.dto";
|
import { PredictionCardDto } from "./dto/prediction-card.dto";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|||||||
Reference in New Issue
Block a user