diff --git a/src/backend/database/database-wrapper.js b/src/backend/database/database-wrapper.ts similarity index 96% rename from src/backend/database/database-wrapper.js rename to src/backend/database/database-wrapper.ts index 2a5714c..dbe869a 100644 --- a/src/backend/database/database-wrapper.js +++ b/src/backend/database/database-wrapper.ts @@ -1,9 +1,5 @@ -import { - mongoRead, - mongoReadWithReadCredentials, - mongoUpsert, -} from "./mongo-wrapper"; -import { pgRead, pgReadWithReadCredentials, pgUpsert } from "./pg-wrapper"; +import { mongoRead, mongoReadWithReadCredentials, mongoUpsert } from './mongo-wrapper'; +import { pgRead, pgReadWithReadCredentials, pgUpsert } from './pg-wrapper'; export async function databaseUpsert({ contents, group }) { // No, this should be more rational, ({contents, group, schema})? Or should this be managed by this layer? Unclear. diff --git a/src/backend/database/mongo-wrapper.js b/src/backend/database/mongo-wrapper.ts similarity index 98% rename from src/backend/database/mongo-wrapper.js rename to src/backend/database/mongo-wrapper.ts index 02c38d8..f922407 100644 --- a/src/backend/database/mongo-wrapper.js +++ b/src/backend/database/mongo-wrapper.ts @@ -1,5 +1,7 @@ -import pkg from "mongodb"; -import { roughSizeOfObject } from "../utils/roughSize"; +import pkg from 'mongodb'; + +import { roughSizeOfObject } from '../utils/roughSize'; + const { MongoClient } = pkg; export async function mongoUpsert( diff --git a/src/backend/database/pg-wrapper.js b/src/backend/database/pg-wrapper.ts similarity index 98% rename from src/backend/database/pg-wrapper.js rename to src/backend/database/pg-wrapper.ts index 76c59ac..185da83 100644 --- a/src/backend/database/pg-wrapper.js +++ b/src/backend/database/pg-wrapper.ts @@ -1,7 +1,9 @@ -import pkg from "pg"; -import { platformNames } from "../platforms/all/platformNames"; -import { hash } from "../utils/hash"; -import { roughSizeOfObject } from "../utils/roughSize"; +import pkg from 'pg'; + +import { platformNames } from '../platforms/all/platformNames'; +import { hash } from '../utils/hash'; +import { roughSizeOfObject } from '../utils/roughSize'; + const { Pool } = pkg; // Definitions diff --git a/src/backend/flow/doEverything.js b/src/backend/flow/doEverything.ts similarity index 80% rename from src/backend/flow/doEverything.js rename to src/backend/flow/doEverything.ts index 81498c8..eabb4f1 100644 --- a/src/backend/flow/doEverything.js +++ b/src/backend/flow/doEverything.ts @@ -1,8 +1,9 @@ -import { platformFetchers } from "../platforms/all-platforms"; -import { rebuildAlgoliaDatabase } from "../utils/algolia"; -import { updateHistory } from "./history/updateHistory"; -import { mergeEverything } from "./mergeEverything"; -import { rebuildNetlifySiteWithNewData } from "./rebuildNetliftySiteWithNewData"; +import { platformFetchers } from '../platforms/all-platforms'; +import { rebuildAlgoliaDatabase } from '../utils/algolia'; +import { updateHistory } from './history/updateHistory'; +import { mergeEverything } from './mergeEverything'; +import { rebuildNetlifySiteWithNewData } from './rebuildNetliftySiteWithNewData'; + /* Do everything */ function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); diff --git a/src/backend/flow/doEverythingForScheduler.js b/src/backend/flow/doEverythingForScheduler.js deleted file mode 100644 index 4b8e69f..0000000 --- a/src/backend/flow/doEverythingForScheduler.js +++ /dev/null @@ -1,3 +0,0 @@ -import { doEverything } from "./doEverything"; - -doEverything(); diff --git a/src/backend/flow/doEverythingForScheduler.ts b/src/backend/flow/doEverythingForScheduler.ts new file mode 100644 index 0000000..d2753d9 --- /dev/null +++ b/src/backend/flow/doEverythingForScheduler.ts @@ -0,0 +1,3 @@ +import { doEverything } from './doEverything'; + +doEverything(); diff --git a/src/backend/flow/history/updateHistory.js b/src/backend/flow/history/updateHistory.ts similarity index 65% rename from src/backend/flow/history/updateHistory.js rename to src/backend/flow/history/updateHistory.ts index b4733dc..9caf1e0 100644 --- a/src/backend/flow/history/updateHistory.js +++ b/src/backend/flow/history/updateHistory.ts @@ -1,7 +1,4 @@ -import { - databaseReadWithReadCredentials, - databaseUpsert, -} from "../../database/database-wrapper"; +import { databaseReadWithReadCredentials, databaseUpsert } from '../../database/database-wrapper'; export async function updateHistory() { let latest = await databaseReadWithReadCredentials({ group: "combined" }); diff --git a/src/backend/flow/mergeEverything.js b/src/backend/flow/mergeEverything.ts similarity index 84% rename from src/backend/flow/mergeEverything.js rename to src/backend/flow/mergeEverything.ts index 300b5ac..4377bb3 100644 --- a/src/backend/flow/mergeEverything.js +++ b/src/backend/flow/mergeEverything.ts @@ -1,5 +1,6 @@ -import { databaseRead, databaseUpsert } from "../database/database-wrapper"; -import { platformNames } from "../platforms/all-platforms"; +import { databaseRead, databaseUpsert } from '../database/database-wrapper'; +import { platformNames } from '../platforms/all-platforms'; + /* Merge everything */ export async function mergeEverythingInner() { diff --git a/src/backend/flow/rebuildNetliftySiteWithNewData.js b/src/backend/flow/rebuildNetliftySiteWithNewData.ts similarity index 80% rename from src/backend/flow/rebuildNetliftySiteWithNewData.js rename to src/backend/flow/rebuildNetliftySiteWithNewData.ts index 5204ead..7d4fe71 100644 --- a/src/backend/flow/rebuildNetliftySiteWithNewData.js +++ b/src/backend/flow/rebuildNetliftySiteWithNewData.ts @@ -1,5 +1,6 @@ -import axios from "axios"; -import { applyIfSecretExists } from "../utils/getSecrets"; +import axios from 'axios'; + +import { applyIfSecretExists } from '../utils/getSecrets'; async function rebuildNetlifySiteWithNewData_inner(cookie) { let payload = {}; diff --git a/src/backend/manual/manualDownload.js b/src/backend/manual/manualDownload.ts similarity index 69% rename from src/backend/manual/manualDownload.js rename to src/backend/manual/manualDownload.ts index c5eb4ea..f229616 100644 --- a/src/backend/manual/manualDownload.js +++ b/src/backend/manual/manualDownload.ts @@ -1,6 +1,8 @@ -import "dotenv/config"; -import fs from "fs"; -import { databaseReadWithReadCredentials } from "../database/database-wrapper"; +import 'dotenv/config'; + +import fs from 'fs'; + +import { databaseReadWithReadCredentials } from '../database/database-wrapper'; let main = async () => { let json = await databaseReadWithReadCredentials({ group: "combined" }); diff --git a/src/backend/manual/manualInitialize.js b/src/backend/manual/manualInitialize.js deleted file mode 100644 index 1427013..0000000 --- a/src/backend/manual/manualInitialize.js +++ /dev/null @@ -1,3 +0,0 @@ -import { pgInitialize } from "../database/pg-wrapper"; - -pgInitialize(); diff --git a/src/backend/manual/manualInitialize.ts b/src/backend/manual/manualInitialize.ts new file mode 100644 index 0000000..cdb1d09 --- /dev/null +++ b/src/backend/manual/manualInitialize.ts @@ -0,0 +1,3 @@ +import { pgInitialize } from '../database/pg-wrapper'; + +pgInitialize(); diff --git a/src/backend/manual/manualSendToMongo.js b/src/backend/manual/manualSendToMongo.ts similarity index 83% rename from src/backend/manual/manualSendToMongo.js rename to src/backend/manual/manualSendToMongo.ts index 2aea360..19ddcfd 100644 --- a/src/backend/manual/manualSendToMongo.js +++ b/src/backend/manual/manualSendToMongo.ts @@ -1,5 +1,6 @@ -import fs from "fs"; -import { databaseUpsert } from "../database/database-wrapper"; +import fs from 'fs'; + +import { databaseUpsert } from '../database/database-wrapper'; /* This is necessary for estimize, the database of x-risk estimates, and for the OpenPhil/GiveWell predictions. Unlike the others, I'm not fetching them constantly, but only once. */ @@ -9,7 +10,9 @@ let suffixMongo = "-questions"; let main = async () => { for (let file of pushManualFiles) { - let fileRaw = fs.readFileSync(`./input/${file + suffixFiles}`); + let fileRaw = fs.readFileSync(`./input/${file + suffixFiles}`, { + encoding: "utf-8", + }); let fileContents = JSON.parse(fileRaw); console.log(fileContents); await databaseUpsert({ contents: fileContents, group: file }); diff --git a/src/backend/manual/pullSuperforecastsManually.js b/src/backend/manual/pullSuperforecastsManually.ts similarity index 61% rename from src/backend/manual/pullSuperforecastsManually.js rename to src/backend/manual/pullSuperforecastsManually.ts index 1a4829a..8f64ca3 100644 --- a/src/backend/manual/pullSuperforecastsManually.js +++ b/src/backend/manual/pullSuperforecastsManually.ts @@ -1,5 +1,5 @@ /* Imports */ -import { goodjudgment } from "../platforms/goodjudgment-fetch"; +import { goodjudgment } from '../platforms/goodjudgment-fetch'; /* Definitions */ diff --git a/src/backend/platforms/all/platformFetchers.js b/src/backend/platforms/all/platformFetchers.ts similarity index 50% rename from src/backend/platforms/all/platformFetchers.js rename to src/backend/platforms/all/platformFetchers.ts index 04c1ce5..5bf174f 100644 --- a/src/backend/platforms/all/platformFetchers.js +++ b/src/backend/platforms/all/platformFetchers.ts @@ -1,17 +1,17 @@ -import { betfair } from "../betfair-fetch"; -import { fantasyscotus } from "../fantasyscotus-fetch"; -import { foretold } from "../foretold-fetch"; -import { goodjudgment } from "../goodjudgment-fetch"; -import { goodjudgmentopen } from "../goodjudmentopen-fetch"; -import { infer } from "../infer-fetch"; -import { kalshi } from "../kalshi-fetch"; -import { manifoldmarkets } from "../manifoldmarkets-fetch"; -import { metaculus } from "../metaculus-fetch"; -import { polymarket } from "../polymarket-fetch"; -import { predictit } from "../predictit-fetch"; -import { rootclaim } from "../rootclaim-fetch"; -import { smarkets } from "../smarkets-fetch"; -import { wildeford } from "../wildeford-fetch"; +import { betfair } from '../betfair-fetch'; +import { fantasyscotus } from '../fantasyscotus-fetch'; +import { foretold } from '../foretold-fetch'; +import { goodjudgment } from '../goodjudgment-fetch'; +import { goodjudgmentopen } from '../goodjudmentopen-fetch'; +import { infer } from '../infer-fetch'; +import { kalshi } from '../kalshi-fetch'; +import { manifoldmarkets } from '../manifoldmarkets-fetch'; +import { metaculus } from '../metaculus-fetch'; +import { polymarket } from '../polymarket-fetch'; +import { predictit } from '../predictit-fetch'; +import { rootclaim } from '../rootclaim-fetch'; +import { smarkets } from '../smarkets-fetch'; +import { wildeford } from '../wildeford-fetch'; /* Deprecated import { astralcodexten } from "../platforms/astralcodexten-fetch" diff --git a/src/backend/platforms/all/platformNames.js b/src/backend/platforms/all/platformNames.ts similarity index 100% rename from src/backend/platforms/all/platformNames.js rename to src/backend/platforms/all/platformNames.ts diff --git a/src/backend/platforms/deprecated/astralcodexten-fetch.js b/src/backend/platforms/deprecated/astralcodexten-fetch.ts similarity index 95% rename from src/backend/platforms/deprecated/astralcodexten-fetch.js rename to src/backend/platforms/deprecated/astralcodexten-fetch.ts index 5615238..a7296ab 100644 --- a/src/backend/platforms/deprecated/astralcodexten-fetch.js +++ b/src/backend/platforms/deprecated/astralcodexten-fetch.ts @@ -1,7 +1,8 @@ /* Imports */ -import axios from "axios"; -import { databaseUpsert } from "../utils/database-wrapper"; -import { calculateStars } from "../utils/stars"; +import axios from 'axios'; + +import { databaseUpsert } from '../utils/database-wrapper'; +import { calculateStars } from '../utils/stars'; /* Definitions */ let graphQLendpoint = "https://api.foretold.io/graphql"; diff --git a/src/pages/api/platform/[platform].js b/src/pages/api/platform/[platform].js deleted file mode 100644 index 0e88130..0000000 --- a/src/pages/api/platform/[platform].js +++ /dev/null @@ -1,6 +0,0 @@ -// see: https://nextjs.org/docs/api-routes/dynamic-api-routes - -export default function handler(req, res) { - const { platform } = req.query; - res.end(`Platform: ${platform}`); -} diff --git a/src/pages/api/platform/index.js b/src/pages/api/platform/index.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/api/question/[question].js b/src/pages/api/question/[question].js deleted file mode 100644 index 134c9b8..0000000 --- a/src/pages/api/question/[question].js +++ /dev/null @@ -1,6 +0,0 @@ -// see: https://nextjs.org/docs/api-routes/dynamic-api-routes - -export default function handler(req, res) { - const { question } = req.query; - res.end(`Platform: ${question}`); -} diff --git a/src/pages/api/question/index.js b/src/pages/api/question/index.js deleted file mode 100644 index e69de29..0000000