Convert all API endpoints into ESM modules

This commit is contained in:
Alicia Sykes
2024-05-06 21:51:32 +01:00
parent e255c358cb
commit c9e57400fd
34 changed files with 191 additions and 194 deletions

View File

@ -1,8 +1,8 @@
const traceroute = require('traceroute');
const url = require('url');
const middleware = require('./_common/middleware');
import url from 'url';
import traceroute from 'traceroute';
import middleware from './_common/middleware.js';
const handler = async (urlString, context) => {
const traceRouteHandler = async (urlString, context) => {
// Parse the URL and get the hostname
const urlObject = url.parse(urlString);
const host = urlObject.hostname;
@ -28,5 +28,5 @@ const handler = async (urlString, context) => {
};
};
module.exports = middleware(handler);
module.exports.handler = middleware(handler);
export const handler = middleware(traceRouteHandler);
export default handler;