Feat: es modules (#139)

* All file imports change from commonjs to es-module

* Improved plex error responses back from api

* Converted viewHistory to es module

* Es-module requires file extension, updated all imports

* Fix esmodule not having __dirname defined in scope

* Replace dynamic-require with fs readFileSync

* Short message service module function is exported as default

* Resolved lint issues & ignore import/extension rule until typescript

* All tests file imports changed from commonjs to es-module

* Import json fixtures with new helper
This commit is contained in:
2022-08-25 17:19:23 +02:00
committed by GitHub
parent 628ed52012
commit 7168950dfe
119 changed files with 624 additions and 527 deletions

View File

@@ -1,10 +1,9 @@
const http = require("http");
const { URL } = require("url");
const PythonShell = require("python-shell");
import http from "http";
import { URL } from "url";
import PythonShell from "python-shell";
const establishedDatabase = require("../database/database");
const cache = require("../cache/redis");
import establishedDatabase from "../database/database.js";
import cache from "../cache/redis.js";
function getMagnetFromURL(url) {
return new Promise(resolve => {
@@ -46,7 +45,7 @@ async function callPythonAddMagnet(url, callback) {
});
}
async function SearchPiratebay(_query) {
export async function SearchPiratebay(_query) {
let query = String(_query);
if (query?.includes("+")) {
@@ -76,7 +75,7 @@ async function SearchPiratebay(_query) {
);
}
function AddMagnet(magnet, name, tmdbId) {
export function AddMagnet(magnet, name, tmdbId) {
return new Promise((resolve, reject) =>
callPythonAddMagnet(magnet, (err, results) => {
if (err) {
@@ -98,5 +97,3 @@ function AddMagnet(magnet, name, tmdbId) {
})
);
}
module.exports = { SearchPiratebay, AddMagnet };