neater types directory

This commit is contained in:
lingdocs 2021-08-27 08:05:45 +04:00
parent 96c1212d29
commit 62cf2ef4d4
26 changed files with 30 additions and 34 deletions

View File

@ -2,7 +2,7 @@ import Nano from "nano";
import { DocumentInsertResponse } from "nano";
import { getTimestamp } from "./time-utils";
import env from "./env-vars";
import * as T from "../../../website/src/lib/account-types";
import * as T from "../../../website/src/types/account-types";
const nano = Nano(env.couchDbURL);
const usersDb = nano.db.use("lingdocs-users");

View File

@ -1,7 +1,7 @@
import nodemailer from "nodemailer";
import inProd from "./inProd";
import env from "./env-vars";
import * as T from "../../../website/src/lib/account-types";
import * as T from "../../../website/src/types/account-types";
type Address = string | { name: string, address: string };

View File

@ -1,7 +1,7 @@
import { hash, compare } from "bcryptjs";
import { randomBytes } from "crypto";
import base64url from "base64url";
import * as T from "../../../website/src/lib/account-types";
import * as T from "../../../website/src/types/account-types";
const tokenSize = 24;

View File

@ -1,4 +1,4 @@
import * as T from "../../../website/src/lib/account-types";
import * as T from "../../../website/src/types/account-types";
export function getTimestamp(): T.TimeStamp {
return Date.now() as T.TimeStamp;

View File

@ -14,7 +14,7 @@ import {
sendAccountUpgradeMessage,
} from "../lib/mail-utils";
import { outsideProviders } from "../middleware/setup-passport";
import * as T from "../../../website/src/lib/account-types";
import * as T from "../../../website/src/types/account-types";
function getUUID(): T.UUID {
return uuidv4() as T.UUID;

View File

@ -7,7 +7,6 @@ import { Strategy as TwitterStrategy } from "passport-twitter";
import {
getLingdocsUser,
insertLingdocsUser,
updateLastActive,
updateLastLogin,
updateLingdocsUser,
} from "../lib/couch-db";
@ -16,7 +15,7 @@ import {
getVerifiedEmail,
} from "../lib/user-utils";
import env from "../lib/env-vars";
import * as T from "../../../website/src/lib/account-types";
import * as T from "../../../website/src/types/account-types";
import { getTimestamp } from "../lib/time-utils";
export const outsideProviders: ("github" | "google" | "twitter")[] = ["github", "google", "twitter"];

View File

@ -17,7 +17,7 @@ import {
import {
upgradeUser,
} from "../lib/user-utils";
import * as T from "../../../website/src/lib/account-types";
import * as T from "../../../website/src/types/account-types";
import env from "../lib/env-vars";
// TODO: ADD PROPER ERROR HANDLING THAT WILL RETURN JSON ALWAYS

View File

@ -27,7 +27,7 @@ import {
} from "../lib/mail-utils";
import { outsideProviders } from "../middleware/setup-passport";
import inProd from "../lib/inProd";
import * as T from "../../../website/src/lib/account-types";
import * as T from "../../../website/src/types/account-types";
const authRouter = (passport: PassportStatic) => {
const router = Router();

View File

@ -1,5 +1,5 @@
import * as functions from "firebase-functions";
import * as FT from "../../website/src/lib/functions-types";
import * as FT from "../../website/src/types/functions-types";
import { receiveSubmissions } from "./submissions";
import lingdocsAuth from "./middleware/lingdocs-auth";
import publish from "./publish";

View File

@ -1,8 +1,8 @@
import cors from "cors";
import fetch from "node-fetch";
import type { https, Response } from "firebase-functions";
import * as FT from "../../../website/src/lib/functions-types";
import type { LingdocsUser } from "../../../website/src/lib/account-types";
import * as FT from "../../../website/src/types/functions-types";
import type { LingdocsUser } from "../../../website/src/types/account-types";
const useCors = cors({ credentials: true, origin: /\.lingdocs\.com$/ });
@ -15,11 +15,8 @@ interface ReqWUser extends https.Request {
*
*/
export default function makeHandler(toRun: (req: ReqWUser, res: Response<FT.FunctionResponse>) => any | Promise<any>) {
console.log("returning handler");
return function(reqPlain: https.Request, resPlain: Response<any>) {
console.log("first level");
useCors(reqPlain, resPlain, async () => {
console.log("got in here");
const { req, res } = await authorize(reqPlain, resPlain);
if (!req) {
res.status(401).send({ ok: false, error: "unauthorized" });

View File

@ -16,7 +16,7 @@ import {
// } from "./word-list-maker";
import {
PublishDictionaryResponse,
} from "../../website/src/lib/functions-types";
} from "../../website/src/types/functions-types";
import { Storage } from "@google-cloud/storage";
const storage = new Storage({
projectId: "lingdocs",

View File

@ -5,7 +5,7 @@ import {
dictionaryEntryBooleanFields,
dictionaryEntryNumberFields,
} from "@lingdocs/pashto-inflector";
import * as FT from "../../website/src/lib/functions-types";
import * as FT from "../../website/src/types/functions-types";
import * as functions from "firebase-functions";
const fieldsForEdit = [

View File

@ -63,7 +63,7 @@ import {
import {
textBadge,
} from "./lib/badges";
import * as AT from "./lib/account-types";
import * as AT from "./types/account-types";
import ReactGA from "react-ga";
// tslint:disable-next-line
import "@fortawesome/fontawesome-free/css/all.css";

View File

@ -1,5 +1,5 @@
import * as FT from "./functions-types";
import * as AT from "./account-types";
import * as FT from "../types/functions-types";
import * as AT from "../types/account-types";
type Service = "account" | "functions";

View File

@ -1,4 +1,4 @@
import type { LingdocsUser } from "./account-types";
import type { LingdocsUser } from "../types/account-types";
export function wordlistEnabled(user: LingdocsUser | undefined): boolean {
if (!user) return false;

View File

@ -6,7 +6,7 @@
*
*/
import * as AT from "./account-types";
import * as AT from "../types/account-types";
export const optionsLocalStorageName = "options3";
export const userLocalStorageName = "user1";

View File

@ -1,5 +1,5 @@
import { Types as IT } from "@lingdocs/pashto-inflector";
import * as AT from "./account-types";
import * as AT from "../types/account-types";
export function optionsReducer(options: Options, action: OptionsAction): Options {
if (action.type === "toggleLanguage") {

View File

@ -1,6 +1,6 @@
import PouchDB from "pouchdb";
import * as AT from "./account-types";
import * as FT from "./functions-types";
import * as AT from "../types/account-types";
import * as FT from "../types/functions-types";
type LocalDbType = "submissions" | "wordlist" | "reviewTasks";

View File

@ -1,5 +1,5 @@
import * as FT from "./functions-types";
import * as AT from "./account-types";
import * as FT from "../types/functions-types";
import * as AT from "../types/account-types";
import {
postSubmissions,
} from "./backend-calls";

View File

@ -11,7 +11,7 @@ import {
} from "../lib/backend-calls";
import LoadingElipses from "../components/LoadingElipses";
import { Helmet } from "react-helmet";
import * as AT from "../lib/account-types";
import * as AT from "../types/account-types";
const providers: ("google" | "twitter" | "github")[] = ["google", "twitter", "github"];

View File

@ -18,7 +18,7 @@ import {
validateEntry,
} from "@lingdocs/pashto-inflector";
import Entry from "../components/Entry";
import * as FT from "../lib/functions-types";
import * as FT from "../types/functions-types";
import {
submissionBase,
addSubmission,

View File

@ -7,7 +7,7 @@
*/
import { useEffect, useState } from "react";
import * as FT from "../lib/functions-types";
import * as FT from "../types/functions-types";
import {
submissionBase,
addSubmission,

View File

@ -1,6 +1,6 @@
import Entry from "../components/Entry";
import { Link } from "react-router-dom";
import * as FT from "../lib/functions-types";
import * as FT from "../types/functions-types";
import {
deleteFromLocalDb,
} from "../lib/pouch-dbs";

View File

@ -18,7 +18,7 @@ type SearchBarPosition = "top" | "bottom";
type WordlistMode = "browse" | "review";
type TextOptionsRecord = {
lastModified: import("./lib/account-types").TimeStamp,
lastModified: import("./types/account-types").TimeStamp,
textOptions: import("@lingdocs/pashto-inflector").Types.TextOptions,
};
@ -43,9 +43,9 @@ type State = {
isolatedEntry: import("@lingdocs/pashto-inflector").Types.DictionaryEntry | undefined,
results: import("@lingdocs/pashto-inflector").Types.DictionaryEntry[],
wordlist: WordlistWord[],
reviewTasks: import("./lib/functions-types").ReviewTask[],
reviewTasks: import("./types/functions-types").ReviewTask[],
dictionaryInfo: import("@lingdocs/pashto-inflector").Types.DictionaryInfo | undefined,
user: undefined | import("./lib/account-types").LingdocsUser,
user: undefined | import("./types/account-types").LingdocsUser,
}
type OptionsAction = {