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,5 +1,5 @@
const axios = require('axios');
const middleware = require('./_common/middleware');
import axios from 'axios';
import middleware from './_common/middleware.js';
const parseRobotsTxt = (content) => {
const lines = content.split('\n');
@ -31,7 +31,7 @@ const parseRobotsTxt = (content) => {
return { robots: rules };
}
const handler = async function(url) {
const robotsHandler = async function(url) {
let parsedURL;
try {
parsedURL = new URL(url);
@ -67,5 +67,5 @@ const handler = async function(url) {
}
};
module.exports = middleware(handler);
module.exports.handler = middleware(handler);
export const handler = middleware(robotsHandler);
export default handler;