import { y as defineEventHandler, X as get, aa as getRouterParam, aR as sendRedirect, af as handleCache, aW as setHeader, aS as sendStream } from '../../nitro/nitro.mjs';
import { join } from 'path';
import { createReadStream } from 'fs';
import { stat } from 'fs/promises';
import 'luxon';
import '@sequelize/core';
import 'html-to-text';
import 'zod';
import 'crypto';
import 'node:fs';
import 'sharp';
import 'node:stream';
import 'jsdom';
import 'dompurify';
import 'mime-types';
import 'linkify-html';
import '@peertube/http-signature';
import 'jsonld';
import 'lodash.intersection';
import 'email-templates';
import 'node:http';
import 'node:https';
import 'node:crypto';
import 'node:events';
import 'node:buffer';
import 'node:path';
import 'vue';
import 'vue-router';
import 'dotenv';
import 'url';
import 'bcryptjs';
import 'slugify';
import 'umzug';
import 'consola';
import '@sequelize/core/decorators-legacy';
import 'util';
import 'mitt';
import 'ical.js';
import 'node:url';
import 'fast-xml-parser';

const ____path_ = defineEventHandler(async (event) => {
  const config = get();
  const path = getRouterParam(event, "path");
  const filePath = join(config.upload_path, path || "");
  const s = await stat(filePath).then((s2) => s2.isFile() ? s2 : null).catch(() => null);
  if (!s) {
    return sendRedirect(event, "/fallbackimage.png", 302);
  }
  if (await handleCache(event, s)) return;
  setHeader(event, "Content-Length", s.size);
  return sendStream(event, createReadStream(filePath));
});

export { ____path_ as default };
