Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
5 replies
Forsto

Call tRPC from the Next.js API folder

I'm working on calling an event that deletes old files when calld from a github actions cron job.

this is the code:
import type { NextApiRequest, NextApiResponse } from "next";
import { api } from "../../utils/api";

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse
) {
  if (req.method === "POST") {
    console.log("Cron job started");
    const { authorization } = req.headers;

    if (!authorization) return res.status(401).json({ success: false });

    try {
      const result = await api.cron.deleteOldTracks(authorization);
      res.status(200).json({ success: true, result });
    } catch (err) {
      if (err instanceof Error) {
        res.status(500).json({ success: false, message: err.message });
      }
    }
  } else {
    res.setHeader("Allow", "POST");
    res.status(405).end("Method Not Allowed");
  }
}


it keeps giving me this problem at deleteOldTracks: This expression is not callable.

any suggestions on a fix?
Was this page helpful?