Another error occurs in src/config.js, src/metadata/controller.js, and node_modules/webrtc-polyfill/lib/Blob.js
netlify/functions/api.js
import express from 'express';
import cors from 'cors';
import { envConfigFile, MONGODB_URL } from '../../src/config.js';
import validateEnvFile from '../../src/envValidation.js';
import connectToDatabase from '../../src/database.js';
import router from '../../src/routes.js';
import serverless from "serverless-http";
export const app = express();
const startServer = async () => {
await validateEnvFile(envConfigFile, ['MONGODB_URL']);
await connectToDatabase(MONGODB_URL);
app.use(express.json({ limit: '5mb' }));
app.use(cors());
app.use('/api/v1', router);
app.use((req, res, next) => {
res.status(404).json('The requested resource was not found on this server');
});
};
startServer();
export const handler = serverless(app);
src/config.js
const __filename = fileURLToPath(import.meta.url); #9th line
src/metadata/controller.js (ignore)
const __filename = fileURLToPath(import.meta.url);
node_modules/webrtc-polyfill/lib/Blob.js:1:34:
[ERROR] Top-level await is currently not supported with the "cjs" output format
4:50:54 PM: node_modules/webrtc-polyfill/lib/Blob.js:1:34:
4:50:54 PM: 1 │ const _Blob = globalThis.Blob || (await import('node:buffer')).Blob