mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-25 11:43:07 +01:00
Revert "Merge pull request #1008 from spacebarchat/dev/samuel"
This reverts commit69ea71aa9e
, reversing changes made to8b2faf0b18
.
This commit is contained in:
parent
c8f65ca4c7
commit
698ad90d3e
4
.gitignore
vendored
4
.gitignore
vendored
@ -9,10 +9,6 @@ assets/cache
|
|||||||
.env
|
.env
|
||||||
config.json
|
config.json
|
||||||
assets/cacheMisses
|
assets/cacheMisses
|
||||||
assets/client_test
|
|
||||||
scripts/client.js
|
|
||||||
src/api/middlewares/TestClient.ts
|
|
||||||
yarn.lock
|
|
||||||
|
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
|
|
||||||
|
5480
package-lock.json
generated
5480
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -38,13 +38,14 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://fosscord.com",
|
"homepage": "https://fosscord.com",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/amqplib": "^0.10.1",
|
"@types/amqplib": "^0.8.2",
|
||||||
"@types/bcrypt": "^5.0.0",
|
"@types/bcrypt": "^5.0.0",
|
||||||
"@types/body-parser": "^1.19.2",
|
"@types/body-parser": "^1.19.2",
|
||||||
"@types/cookie-parser": "^1.4.3",
|
"@types/cookie-parser": "^1.4.3",
|
||||||
"@types/express": "^4.17.15",
|
"@types/express": "^4.17.15",
|
||||||
|
"@types/i18next-node-fs-backend": "^2.1.1",
|
||||||
"@types/json-bigint": "^1.0.1",
|
"@types/json-bigint": "^1.0.1",
|
||||||
"@types/jsonwebtoken": "^9.0.1",
|
"@types/jsonwebtoken": "^8.5.9",
|
||||||
"@types/morgan": "^1.9.3",
|
"@types/morgan": "^1.9.3",
|
||||||
"@types/multer": "^1.4.7",
|
"@types/multer": "^1.4.7",
|
||||||
"@types/node": "^18.7.20",
|
"@types/node": "^18.7.20",
|
||||||
@ -61,7 +62,7 @@
|
|||||||
"husky": "^8.0.0",
|
"husky": "^8.0.0",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"pretty-quick": "^3.1.3",
|
"pretty-quick": "^3.1.3",
|
||||||
"typescript": "^5.0.2"
|
"typescript": "^4.9.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.178.0",
|
"@aws-sdk/client-s3": "^3.178.0",
|
||||||
@ -79,20 +80,21 @@
|
|||||||
"exif-be-gone": "^1.3.1",
|
"exif-be-gone": "^1.3.1",
|
||||||
"fast-zlib": "^2.0.1",
|
"fast-zlib": "^2.0.1",
|
||||||
"fido2-lib": "^3.3.5",
|
"fido2-lib": "^3.3.5",
|
||||||
"file-type": "16.5.4",
|
"file-type": "16.5",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"i18next": "^22.4.12",
|
"i18next": "^21.9.2",
|
||||||
"i18next-fs-backend": "^2.1.1",
|
"i18next-http-middleware": "^3.2.1",
|
||||||
|
"i18next-node-fs-backend": "^2.1.3",
|
||||||
"image-size": "^1.0.2",
|
"image-size": "^1.0.2",
|
||||||
"json-bigint": "^1.0.0",
|
"json-bigint": "^1.0.0",
|
||||||
"jsonwebtoken": "^9.0.0",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"lambert-server": "^1.2.12",
|
"lambert-server": "^1.2.12",
|
||||||
"missing-native-js-functions": "^1.2.18",
|
"missing-native-js-functions": "^1.2.18",
|
||||||
"module-alias": "^2.2.2",
|
"module-alias": "^2.2.2",
|
||||||
"morgan": "^1.10.0",
|
"morgan": "^1.10.0",
|
||||||
"multer": "^1.4.5-lts.1",
|
"multer": "^1.4.5-lts.1",
|
||||||
"node-2fa": "^2.0.3",
|
"node-2fa": "^2.0.3",
|
||||||
"node-fetch": "^2.6.9",
|
"node-fetch": "^2.6.7",
|
||||||
"node-os-utils": "^1.3.7",
|
"node-os-utils": "^1.3.7",
|
||||||
"nodemailer": "^6.9.0",
|
"nodemailer": "^6.9.0",
|
||||||
"picocolors": "^1.0.0",
|
"picocolors": "^1.0.0",
|
||||||
@ -112,10 +114,10 @@
|
|||||||
"@fosscord/util": "dist/util"
|
"@fosscord/util": "dist/util"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"better-sqlite3": "^8.2.0",
|
|
||||||
"erlpack": "^0.1.4",
|
"erlpack": "^0.1.4",
|
||||||
"nodemailer-mailgun-transport": "^2.1.5",
|
"nodemailer-mailgun-transport": "^2.1.5",
|
||||||
"nodemailer-mailjet-transport": "github:n0script22/nodemailer-mailjet-transport",
|
"nodemailer-mailjet-transport": "github:n0script22/nodemailer-mailjet-transport",
|
||||||
"nodemailer-sendgrid-transport": "github:Maria-Golomb/nodemailer-sendgrid-transport"
|
"nodemailer-sendgrid-transport": "github:Maria-Golomb/nodemailer-sendgrid-transport",
|
||||||
|
"sqlite3": "^5.1.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ import "missing-native-js-functions";
|
|||||||
import morgan from "morgan";
|
import morgan from "morgan";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { red } from "picocolors";
|
import { red } from "picocolors";
|
||||||
import { CORS, initAuthentication } from "./middlewares/";
|
import { Authentication, CORS } from "./middlewares/";
|
||||||
import { BodyParser } from "./middlewares/BodyParser";
|
import { BodyParser } from "./middlewares/BodyParser";
|
||||||
import { ErrorHandler } from "./middlewares/ErrorHandler";
|
import { ErrorHandler } from "./middlewares/ErrorHandler";
|
||||||
import { initRateLimits } from "./middlewares/RateLimit";
|
import { initRateLimits } from "./middlewares/RateLimit";
|
||||||
@ -106,7 +106,7 @@ export class FosscordServer extends Server {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.app = api;
|
this.app = api;
|
||||||
|
|
||||||
initAuthentication(api);
|
api.use(Authentication);
|
||||||
await initRateLimits(api);
|
await initRateLimits(api);
|
||||||
await initTranslation(api);
|
await initTranslation(api);
|
||||||
|
|
||||||
|
@ -18,9 +18,8 @@
|
|||||||
|
|
||||||
import { checkToken, Config, Rights } from "@fosscord/util";
|
import { checkToken, Config, Rights } from "@fosscord/util";
|
||||||
import * as Sentry from "@sentry/node";
|
import * as Sentry from "@sentry/node";
|
||||||
import { NextFunction, Request, Response, Router } from "express";
|
import { NextFunction, Request, Response } from "express";
|
||||||
import { HTTPError } from "lambert-server";
|
import { HTTPError } from "lambert-server";
|
||||||
import { createSecretKey, KeyObject } from "crypto";
|
|
||||||
|
|
||||||
export const NO_AUTHORIZATION_ROUTES = [
|
export const NO_AUTHORIZATION_ROUTES = [
|
||||||
// Authentication routes
|
// Authentication routes
|
||||||
@ -70,16 +69,6 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let jwtPublicKey: KeyObject;
|
|
||||||
|
|
||||||
// Initialize the jwt secret as a key object so it does not need to be regenerated for each request.
|
|
||||||
export function initAuthentication(api: Router) {
|
|
||||||
jwtPublicKey = createSecretKey(
|
|
||||||
Buffer.from(Config.get().security.jwtSecret),
|
|
||||||
);
|
|
||||||
api.use(Authentication);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function Authentication(
|
export async function Authentication(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response,
|
res: Response,
|
||||||
@ -101,9 +90,11 @@ export async function Authentication(
|
|||||||
Sentry.setUser({ id: req.user_id });
|
Sentry.setUser({ id: req.user_id });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const { jwtSecret } = Config.get().security;
|
||||||
|
|
||||||
const { decoded, user } = await checkToken(
|
const { decoded, user } = await checkToken(
|
||||||
req.headers.authorization,
|
req.headers.authorization,
|
||||||
jwtPublicKey,
|
jwtSecret,
|
||||||
);
|
);
|
||||||
|
|
||||||
req.token = decoded;
|
req.token = decoded;
|
||||||
|
@ -18,20 +18,11 @@
|
|||||||
|
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import i18next, { TFunction } from "i18next";
|
import i18next from "i18next";
|
||||||
import i18nextBackend from "i18next-fs-backend";
|
import i18nextMiddleware from "i18next-http-middleware";
|
||||||
|
import i18nextBackend from "i18next-node-fs-backend";
|
||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
|
|
||||||
declare global {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
||||||
namespace Express {
|
|
||||||
interface Request {
|
|
||||||
t: TFunction;
|
|
||||||
language?: string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const ASSET_FOLDER_PATH = path.join(__dirname, "..", "..", "..", "assets");
|
const ASSET_FOLDER_PATH = path.join(__dirname, "..", "..", "..", "assets");
|
||||||
|
|
||||||
export async function initTranslation(router: Router) {
|
export async function initTranslation(router: Router) {
|
||||||
@ -43,33 +34,21 @@ export async function initTranslation(router: Router) {
|
|||||||
.filter((x) => x.endsWith(".json"))
|
.filter((x) => x.endsWith(".json"))
|
||||||
.map((x) => x.slice(0, x.length - 5));
|
.map((x) => x.slice(0, x.length - 5));
|
||||||
|
|
||||||
await i18next.use(i18nextBackend).init({
|
await i18next
|
||||||
preload: languages,
|
.use(i18nextBackend)
|
||||||
// debug: true,
|
.use(i18nextMiddleware.LanguageDetector)
|
||||||
fallbackLng: "en",
|
.init({
|
||||||
ns,
|
preload: languages,
|
||||||
backend: {
|
// debug: true,
|
||||||
loadPath:
|
fallbackLng: "en",
|
||||||
path.join(ASSET_FOLDER_PATH, "locales") +
|
ns,
|
||||||
"/{{lng}}/{{ns}}.json",
|
backend: {
|
||||||
},
|
loadPath:
|
||||||
load: "all",
|
path.join(ASSET_FOLDER_PATH, "locales") +
|
||||||
});
|
"/{{lng}}/{{ns}}.json",
|
||||||
|
},
|
||||||
|
load: "all",
|
||||||
|
});
|
||||||
|
|
||||||
router.use((req, res, next) => {
|
router.use(i18nextMiddleware.handle(i18next, {}));
|
||||||
let lng = "en";
|
|
||||||
if (req.headers["accept-language"]) {
|
|
||||||
lng = req.headers["accept-language"].split(",")[0];
|
|
||||||
}
|
|
||||||
req.language = lng;
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
req.t = (key: string | string[], options?: any) => {
|
|
||||||
return i18next.t(key, {
|
|
||||||
...options,
|
|
||||||
lng,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ const TemplateGuildProjection: (keyof Guild)[] = [
|
|||||||
"system_channel_id",
|
"system_channel_id",
|
||||||
"system_channel_flags",
|
"system_channel_flags",
|
||||||
"icon",
|
"icon",
|
||||||
"id",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
router.get("/", route({}), async (req: Request, res: Response) => {
|
router.get("/", route({}), async (req: Request, res: Response) => {
|
||||||
|
@ -52,17 +52,17 @@ router.put("/:id", route({}), async (req: Request, res: Response) => {
|
|||||||
where: { owner: { id: owner.id }, target: { id: target.id } },
|
where: { owner: { id: owner.id }, target: { id: target.id } },
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
await Note.update(
|
Note.update(
|
||||||
{ owner: { id: owner.id }, target: { id: target.id } },
|
{ owner: { id: owner.id }, target: { id: target.id } },
|
||||||
{ owner, target, content: note },
|
{ owner, target, content: note },
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
await Note.create({
|
Note.insert({
|
||||||
id: Snowflake.generate(),
|
id: Snowflake.generate(),
|
||||||
owner,
|
owner,
|
||||||
target,
|
target,
|
||||||
content: note,
|
content: note,
|
||||||
}).save();
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await Note.delete({
|
await Note.delete({
|
||||||
|
@ -274,7 +274,7 @@ export async function sendMessage(opts: MessageOptions) {
|
|||||||
const message = await handleMessage({ ...opts, timestamp: new Date() });
|
const message = await handleMessage({ ...opts, timestamp: new Date() });
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
message.save(),
|
Message.insert(message),
|
||||||
emitEvent({
|
emitEvent({
|
||||||
event: "MESSAGE_CREATE",
|
event: "MESSAGE_CREATE",
|
||||||
channel_id: opts.channel_id,
|
channel_id: opts.channel_id,
|
||||||
|
85
src/util/cache/Cache.ts
vendored
85
src/util/cache/Cache.ts
vendored
@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
|
|
||||||
Copyright (C) 2023 Fosscord and Fosscord Contributors
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published
|
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
|
|
||||||
import { EntityMetadata, FindOptionsWhere } from "typeorm";
|
|
||||||
import { LocalCache } from "./LocalCache";
|
|
||||||
|
|
||||||
declare module "typeorm" {
|
|
||||||
interface BaseEntity {
|
|
||||||
metadata?: EntityMetadata;
|
|
||||||
cache: CacheManager;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type BaseEntityWithId = { id: string; [name: string]: any };
|
|
||||||
export type Criteria =
|
|
||||||
| string
|
|
||||||
| string[]
|
|
||||||
| number
|
|
||||||
| number[]
|
|
||||||
| FindOptionsWhere<never>;
|
|
||||||
|
|
||||||
export interface Cache {
|
|
||||||
get(id: string): BaseEntityWithId | undefined;
|
|
||||||
set(id: string, entity: BaseEntityWithId): this;
|
|
||||||
find(options: Record<string, never>): BaseEntityWithId | undefined;
|
|
||||||
filter(options: Record<string, never>): BaseEntityWithId[];
|
|
||||||
delete(id: string): boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CacheManager {
|
|
||||||
// last access time to automatically remove old entities from cache after 5 minutes of inactivity (to prevent memory leaks)
|
|
||||||
cache: Cache;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.cache = new LocalCache();
|
|
||||||
// TODO: Config.get().cache.redis;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(id: string) {
|
|
||||||
return this.cache.delete(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
insert(entity: BaseEntityWithId) {
|
|
||||||
if (!entity.id) return;
|
|
||||||
|
|
||||||
return this.cache.set(entity.id, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
find(options?: Record<string, never>, select?: string[] | undefined) {
|
|
||||||
if (!options) return null;
|
|
||||||
const entity = this.cache.find(options);
|
|
||||||
if (!entity) return null;
|
|
||||||
if (!select) return entity;
|
|
||||||
|
|
||||||
const result = {};
|
|
||||||
for (const prop of select) {
|
|
||||||
// @ts-ignore
|
|
||||||
result[prop] = entity[prop];
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
return entity.constructor.create(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
filter(options: Record<string, never>) {
|
|
||||||
return this.cache.filter(options);
|
|
||||||
}
|
|
||||||
}
|
|
162
src/util/cache/EntityCache.ts
vendored
162
src/util/cache/EntityCache.ts
vendored
@ -1,162 +0,0 @@
|
|||||||
/*
|
|
||||||
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
|
|
||||||
Copyright (C) 2023 Fosscord and Fosscord Contributors
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published
|
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
/* eslint-disable */
|
|
||||||
import {
|
|
||||||
DataSource,
|
|
||||||
FindOneOptions,
|
|
||||||
EntityNotFoundError,
|
|
||||||
FindOptionsWhere,
|
|
||||||
} from "typeorm";
|
|
||||||
import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity";
|
|
||||||
import { BaseClassWithId } from "../entities/BaseClass";
|
|
||||||
import { Config, getDatabase, RabbitMQ } from "../util";
|
|
||||||
import { CacheManager } from "./Cache";
|
|
||||||
|
|
||||||
function getObjectKeysAsArray(obj?: Record<string, any>) {
|
|
||||||
if (!obj) return [];
|
|
||||||
if (Array.isArray(obj)) return obj;
|
|
||||||
return Object.keys(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ThisType<T> = {
|
|
||||||
new (): T;
|
|
||||||
} & typeof BaseEntityCache;
|
|
||||||
|
|
||||||
interface BaseEntityCache {
|
|
||||||
constructor: typeof BaseEntityCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
class BaseEntityCache extends BaseClassWithId {
|
|
||||||
static cache: CacheManager;
|
|
||||||
static cacheEnabled: boolean;
|
|
||||||
|
|
||||||
public get metadata() {
|
|
||||||
return getDatabase()?.getMetadata(this.constructor)!;
|
|
||||||
}
|
|
||||||
|
|
||||||
static useDataSource(dataSource: DataSource | null) {
|
|
||||||
super.useDataSource(dataSource);
|
|
||||||
const isMultiThreaded =
|
|
||||||
process.env.EVENT_TRANSMISSION === "process" || RabbitMQ.connection;
|
|
||||||
this.cacheEnabled = Config.get().cache.enabled ?? !isMultiThreaded;
|
|
||||||
if (Config.get().cache.redis) return; // TODO: Redis cache
|
|
||||||
if (!this.cacheEnabled) return;
|
|
||||||
this.cache = new CacheManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
static async findOne<T extends BaseEntityCache>(
|
|
||||||
this: ThisType<T>,
|
|
||||||
options: FindOneOptions<T>,
|
|
||||||
) {
|
|
||||||
// @ts-ignore
|
|
||||||
if (!this.cacheEnabled) return super.findOne(options);
|
|
||||||
let select = getObjectKeysAsArray(options.select);
|
|
||||||
|
|
||||||
if (!select.length) {
|
|
||||||
// get all columns that are marked as select
|
|
||||||
getDatabase()
|
|
||||||
?.getMetadata(this)
|
|
||||||
.columns.forEach((x) => {
|
|
||||||
if (!x.isSelect) return;
|
|
||||||
select.push(x.propertyName);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (options.relations) {
|
|
||||||
select.push(...getObjectKeysAsArray(options.relations));
|
|
||||||
}
|
|
||||||
|
|
||||||
const cacheResult = this.cache.find(options.where as never, select);
|
|
||||||
if (cacheResult) {
|
|
||||||
const hasAllProps = select.every((key) => {
|
|
||||||
if (key.includes(".")) return true; // @ts-ignore
|
|
||||||
return cacheResult[key] !== undefined;
|
|
||||||
});
|
|
||||||
// console.log(`[Cache] get ${cacheResult.id} from ${cacheResult.constructor.name}`,);
|
|
||||||
if (hasAllProps) return cacheResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const result = await super.findOne<T>(options);
|
|
||||||
if (!result) return null;
|
|
||||||
|
|
||||||
this.cache.insert(result as any);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static async findOneOrFail<T extends BaseEntityCache>(
|
|
||||||
this: ThisType<T>,
|
|
||||||
options: FindOneOptions<T>,
|
|
||||||
) {
|
|
||||||
const result = await this.findOne<T>(options);
|
|
||||||
if (!result) throw new EntityNotFoundError(this, options);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
save() {
|
|
||||||
if (this.constructor.cacheEnabled) this.constructor.cache.insert(this);
|
|
||||||
return super.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
remove() {
|
|
||||||
if (this.constructor.cacheEnabled)
|
|
||||||
this.constructor.cache.delete(this.id);
|
|
||||||
return super.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
static async update<T extends BaseEntityCache>(
|
|
||||||
this: ThisType<T>,
|
|
||||||
criteria: FindOptionsWhere<T>,
|
|
||||||
partialEntity: QueryDeepPartialEntity<T>,
|
|
||||||
) {
|
|
||||||
// @ts-ignore
|
|
||||||
const result = super.update<T>(criteria, partialEntity);
|
|
||||||
if (!this.cacheEnabled) return result;
|
|
||||||
|
|
||||||
const entities = this.cache.filter(criteria as never);
|
|
||||||
for (const entity of entities) {
|
|
||||||
// @ts-ignore
|
|
||||||
partialEntity.id = entity.id;
|
|
||||||
this.cache.insert(partialEntity as never);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static async delete<T extends BaseEntityCache>(
|
|
||||||
this: ThisType<T>,
|
|
||||||
criteria: FindOptionsWhere<T>,
|
|
||||||
) {
|
|
||||||
// @ts-ignore
|
|
||||||
const result = super.delete<T>(criteria);
|
|
||||||
if (!this.cacheEnabled) return result;
|
|
||||||
|
|
||||||
const entities = this.cache.filter(criteria as never);
|
|
||||||
for (const entity of entities) {
|
|
||||||
this.cache.delete(entity.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// needed, because typescript can't infer the type of the static methods with generics
|
|
||||||
const EntityCache = BaseEntityCache as unknown as typeof BaseClassWithId;
|
|
||||||
|
|
||||||
export { EntityCache };
|
|
94
src/util/cache/LocalCache.ts
vendored
94
src/util/cache/LocalCache.ts
vendored
@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
|
|
||||||
Copyright (C) 2023 Fosscord and Fosscord Contributors
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published
|
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
||||||
import { BaseEntityWithId, Cache } from "./Cache";
|
|
||||||
|
|
||||||
export const cacheTimeout = 1000 * 60 * 5;
|
|
||||||
|
|
||||||
export class LocalCache extends Map<string, BaseEntityWithId> implements Cache {
|
|
||||||
last_access = new Map<string, number>();
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
setInterval(() => {
|
|
||||||
const now = Date.now();
|
|
||||||
for (const [key, value] of this.last_access) {
|
|
||||||
if (now - value > cacheTimeout) {
|
|
||||||
this.delete(key);
|
|
||||||
this.last_access.delete(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, cacheTimeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
set(key: string, value: BaseEntityWithId): this {
|
|
||||||
if (this.has(key)) {
|
|
||||||
this.update(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
this.last_access.set(key, Date.now());
|
|
||||||
return super.set(key, value as never);
|
|
||||||
}
|
|
||||||
|
|
||||||
get(key: string) {
|
|
||||||
const value = super.get(key);
|
|
||||||
if (value) this.last_access.set(key, Date.now());
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
update(id: string, entity: BaseEntityWithId) {
|
|
||||||
const oldEntity = this.get(id);
|
|
||||||
if (!oldEntity) return;
|
|
||||||
for (const key in entity) {
|
|
||||||
// @ts-ignore
|
|
||||||
if (entity[key] === undefined) continue; // @ts-ignore
|
|
||||||
oldEntity[key] = entity[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
find(options: Record<string, never>): BaseEntityWithId | undefined {
|
|
||||||
if (options.id && Object.keys(options).length === 1) {
|
|
||||||
return this.get(options.id);
|
|
||||||
}
|
|
||||||
for (const entity of this.values()) {
|
|
||||||
if (objectFulfillsQuery(entity, options)) return entity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
filter(options: Record<string, never>): BaseEntityWithId[] {
|
|
||||||
const result = [];
|
|
||||||
for (const entity of this.values()) {
|
|
||||||
if (objectFulfillsQuery(entity, options)) {
|
|
||||||
result.push(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function objectFulfillsQuery(
|
|
||||||
entity: BaseEntityWithId,
|
|
||||||
options: Record<string, never>,
|
|
||||||
) {
|
|
||||||
for (const key in options) {
|
|
||||||
// @ts-ignore
|
|
||||||
if (entity[key] !== options[key]) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
3
src/util/cache/index.ts
vendored
3
src/util/cache/index.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
export * from "./EntityCache";
|
|
||||||
export * from "./Cache";
|
|
||||||
export * from "./LocalCache";
|
|
@ -37,7 +37,6 @@ import {
|
|||||||
SecurityConfiguration,
|
SecurityConfiguration,
|
||||||
SentryConfiguration,
|
SentryConfiguration,
|
||||||
TemplateConfiguration,
|
TemplateConfiguration,
|
||||||
CacheConfiguration,
|
|
||||||
} from "../config";
|
} from "../config";
|
||||||
|
|
||||||
export class ConfigValue {
|
export class ConfigValue {
|
||||||
@ -62,5 +61,4 @@ export class ConfigValue {
|
|||||||
email: EmailConfiguration = new EmailConfiguration();
|
email: EmailConfiguration = new EmailConfiguration();
|
||||||
passwordReset: PasswordResetConfiguration =
|
passwordReset: PasswordResetConfiguration =
|
||||||
new PasswordResetConfiguration();
|
new PasswordResetConfiguration();
|
||||||
cache: CacheConfiguration = new CacheConfiguration();
|
|
||||||
}
|
}
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
|
|
||||||
Copyright (C) 2023 Fosscord and Fosscord Contributors
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published
|
|
||||||
by the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export class CacheConfiguration {
|
|
||||||
enabled: boolean | null = true;
|
|
||||||
redis: string | null = null;
|
|
||||||
}
|
|
@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export * from "./ApiConfiguration";
|
export * from "./ApiConfiguration";
|
||||||
export * from "./CacheConfiguration";
|
|
||||||
export * from "./CdnConfiguration";
|
export * from "./CdnConfiguration";
|
||||||
export * from "./DefaultsConfiguration";
|
export * from "./DefaultsConfiguration";
|
||||||
export * from "./EmailConfiguration";
|
export * from "./EmailConfiguration";
|
||||||
|
@ -17,12 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, OneToOne } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, OneToOne } from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Team } from "./Team";
|
import { Team } from "./Team";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
|
|
||||||
@Entity("applications")
|
@Entity("applications")
|
||||||
export class Application extends EntityCache {
|
export class Application extends BaseClass {
|
||||||
@Column()
|
@Column()
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
|
@ -25,11 +25,11 @@ import {
|
|||||||
RelationId,
|
RelationId,
|
||||||
} from "typeorm";
|
} from "typeorm";
|
||||||
import { URL } from "url";
|
import { URL } from "url";
|
||||||
import { EntityCache } from "../cache";
|
|
||||||
import { deleteFile } from "../util/cdn";
|
import { deleteFile } from "../util/cdn";
|
||||||
|
import { BaseClass } from "./BaseClass";
|
||||||
|
|
||||||
@Entity("attachments")
|
@Entity("attachments")
|
||||||
export class Attachment extends EntityCache {
|
export class Attachment extends BaseClass {
|
||||||
@Column()
|
@Column()
|
||||||
filename: string; // name of file attached
|
filename: string; // name of file attached
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { ChannelPermissionOverwrite } from "./Channel";
|
import { ChannelPermissionOverwrite } from "./Channel";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ export enum AuditLogEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Entity("audit_logs")
|
@Entity("audit_logs")
|
||||||
export class AuditLog extends EntityCache {
|
export class AuditLog extends BaseClass {
|
||||||
@JoinColumn({ name: "target_id" })
|
@JoinColumn({ name: "target_id" })
|
||||||
@ManyToOne(() => User)
|
@ManyToOne(() => User)
|
||||||
target?: User;
|
target?: User;
|
||||||
|
@ -17,12 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne } from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
import crypto from "crypto";
|
import crypto from "crypto";
|
||||||
|
|
||||||
@Entity("backup_codes")
|
@Entity("backup_codes")
|
||||||
export class BackupCode extends EntityCache {
|
export class BackupCode extends BaseClass {
|
||||||
@JoinColumn({ name: "user_id" })
|
@JoinColumn({ name: "user_id" })
|
||||||
@ManyToOne(() => User, { onDelete: "CASCADE" })
|
@ManyToOne(() => User, { onDelete: "CASCADE" })
|
||||||
user: User;
|
user: User;
|
||||||
|
@ -17,12 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Guild } from "./Guild";
|
import { Guild } from "./Guild";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
|
|
||||||
@Entity("bans")
|
@Entity("bans")
|
||||||
export class Ban extends EntityCache {
|
export class Ban extends BaseClass {
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
@RelationId((ban: Ban) => ban.user)
|
@RelationId((ban: Ban) => ban.user)
|
||||||
user_id: string;
|
user_id: string;
|
||||||
|
@ -25,12 +25,16 @@ import {
|
|||||||
PrimaryColumn,
|
PrimaryColumn,
|
||||||
} from "typeorm";
|
} from "typeorm";
|
||||||
import { Snowflake } from "../util/Snowflake";
|
import { Snowflake } from "../util/Snowflake";
|
||||||
|
import { getDatabase } from "../util/Database";
|
||||||
import { OrmUtils } from "../imports/OrmUtils";
|
import { OrmUtils } from "../imports/OrmUtils";
|
||||||
import { getDatabase } from "../util";
|
|
||||||
|
|
||||||
export class BaseClassWithoutId extends BaseEntity {
|
export class BaseClassWithoutId extends BaseEntity {
|
||||||
public get metadata() {
|
private get construct() {
|
||||||
return getDatabase()?.getMetadata(this.constructor);
|
return this.constructor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private get metadata() {
|
||||||
|
return getDatabase()?.getMetadata(this.construct);
|
||||||
}
|
}
|
||||||
|
|
||||||
assign(props: object) {
|
assign(props: object) {
|
||||||
@ -57,23 +61,8 @@ export class BaseClassWithoutId extends BaseEntity {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export const PrimaryIdColumn = process.env.DATABASE?.startsWith("mongodb")
|
static increment<T extends BaseClass>(
|
||||||
? ObjectIdColumn
|
|
||||||
: PrimaryColumn;
|
|
||||||
|
|
||||||
export class BaseClassWithId extends BaseClassWithoutId {
|
|
||||||
@PrimaryIdColumn()
|
|
||||||
id: string = Snowflake.generate();
|
|
||||||
|
|
||||||
@BeforeUpdate()
|
|
||||||
@BeforeInsert()
|
|
||||||
_do_validate() {
|
|
||||||
if (!this.id) this.id = Snowflake.generate();
|
|
||||||
}
|
|
||||||
|
|
||||||
static increment<T extends BaseClassWithId>(
|
|
||||||
conditions: FindOptionsWhere<T>,
|
conditions: FindOptionsWhere<T>,
|
||||||
propertyPath: string,
|
propertyPath: string,
|
||||||
value: number | string,
|
value: number | string,
|
||||||
@ -82,7 +71,7 @@ export class BaseClassWithId extends BaseClassWithoutId {
|
|||||||
return repository.increment(conditions, propertyPath, value);
|
return repository.increment(conditions, propertyPath, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static decrement<T extends BaseClassWithId>(
|
static decrement<T extends BaseClass>(
|
||||||
conditions: FindOptionsWhere<T>,
|
conditions: FindOptionsWhere<T>,
|
||||||
propertyPath: string,
|
propertyPath: string,
|
||||||
value: number | string,
|
value: number | string,
|
||||||
@ -91,3 +80,18 @@ export class BaseClassWithId extends BaseClassWithoutId {
|
|||||||
return repository.decrement(conditions, propertyPath, value);
|
return repository.decrement(conditions, propertyPath, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const PrimaryIdColumn = process.env.DATABASE?.startsWith("mongodb")
|
||||||
|
? ObjectIdColumn
|
||||||
|
: PrimaryColumn;
|
||||||
|
|
||||||
|
export class BaseClass extends BaseClassWithoutId {
|
||||||
|
@PrimaryIdColumn()
|
||||||
|
id: string = Snowflake.generate();
|
||||||
|
|
||||||
|
@BeforeUpdate()
|
||||||
|
@BeforeInsert()
|
||||||
|
_do_validate() {
|
||||||
|
if (!this.id) this.id = Snowflake.generate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -24,7 +24,7 @@ import {
|
|||||||
OneToMany,
|
OneToMany,
|
||||||
RelationId,
|
RelationId,
|
||||||
} from "typeorm";
|
} from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Guild } from "./Guild";
|
import { Guild } from "./Guild";
|
||||||
import { PublicUserProjection, User } from "./User";
|
import { PublicUserProjection, User } from "./User";
|
||||||
import { HTTPError } from "lambert-server";
|
import { HTTPError } from "lambert-server";
|
||||||
@ -70,7 +70,7 @@ export enum ChannelType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Entity("channels")
|
@Entity("channels")
|
||||||
export class Channel extends EntityCache {
|
export class Channel extends BaseClass {
|
||||||
@Column()
|
@Column()
|
||||||
created_at: Date;
|
created_at: Date;
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity } from "typeorm";
|
import { Column, Entity } from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
|
|
||||||
@Entity("client_release")
|
@Entity("client_release")
|
||||||
export class Release extends EntityCache {
|
export class Release extends BaseClass {
|
||||||
@Column()
|
@Column()
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
|
|
||||||
export type PublicConnectedAccount = Pick<
|
export type PublicConnectedAccount = Pick<
|
||||||
@ -26,7 +26,7 @@ export type PublicConnectedAccount = Pick<
|
|||||||
>;
|
>;
|
||||||
|
|
||||||
@Entity("connected_accounts")
|
@Entity("connected_accounts")
|
||||||
export class ConnectedAccount extends EntityCache {
|
export class ConnectedAccount extends BaseClass {
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
@RelationId((account: ConnectedAccount) => account.user)
|
@RelationId((account: ConnectedAccount) => account.user)
|
||||||
user_id: string;
|
user_id: string;
|
||||||
|
@ -16,12 +16,12 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Entity, Column } from "typeorm";
|
import { Entity, Column } from "typeorm";
|
||||||
import { Embed } from "./Message";
|
import { Embed } from "./Message";
|
||||||
|
|
||||||
@Entity("embed_cache")
|
@Entity("embed_cache")
|
||||||
export class EmbedCache extends EntityCache {
|
export class EmbedCache extends BaseClass {
|
||||||
@Column()
|
@Column()
|
||||||
url: string;
|
url: string;
|
||||||
|
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||||
import { User } from ".";
|
import { User } from ".";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Guild } from "./Guild";
|
import { Guild } from "./Guild";
|
||||||
|
|
||||||
@Entity("emojis")
|
@Entity("emojis")
|
||||||
export class Emoji extends EntityCache {
|
export class Emoji extends BaseClass {
|
||||||
@Column()
|
@Column()
|
||||||
animated: boolean;
|
animated: boolean;
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity } from "typeorm";
|
import { Column, Entity } from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
|
|
||||||
@Entity("security_settings")
|
@Entity("security_settings")
|
||||||
export class SecuritySettings extends EntityCache {
|
export class SecuritySettings extends BaseClass {
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
guild_id: string;
|
guild_id: string;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ import {
|
|||||||
} from "typeorm";
|
} from "typeorm";
|
||||||
import { Config, handleFile, Snowflake } from "..";
|
import { Config, handleFile, Snowflake } from "..";
|
||||||
import { Ban } from "./Ban";
|
import { Ban } from "./Ban";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Channel } from "./Channel";
|
import { Channel } from "./Channel";
|
||||||
import { Emoji } from "./Emoji";
|
import { Emoji } from "./Emoji";
|
||||||
import { Invite } from "./Invite";
|
import { Invite } from "./Invite";
|
||||||
@ -67,7 +67,7 @@ export const PublicGuildRelations = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
@Entity("guilds")
|
@Entity("guilds")
|
||||||
export class Guild extends EntityCache {
|
export class Guild extends BaseClass {
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
@RelationId((guild: Guild) => guild.afk_channel)
|
@RelationId((guild: Guild) => guild.afk_channel)
|
||||||
afk_channel_id?: string;
|
afk_channel_id?: string;
|
||||||
|
@ -34,7 +34,7 @@ import {
|
|||||||
OneToMany,
|
OneToMany,
|
||||||
RelationId,
|
RelationId,
|
||||||
} from "typeorm";
|
} from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Guild } from "./Guild";
|
import { Guild } from "./Guild";
|
||||||
import { Webhook } from "./Webhook";
|
import { Webhook } from "./Webhook";
|
||||||
import { Sticker } from "./Sticker";
|
import { Sticker } from "./Sticker";
|
||||||
@ -70,7 +70,7 @@ export enum MessageType {
|
|||||||
|
|
||||||
@Entity("messages")
|
@Entity("messages")
|
||||||
@Index(["channel_id", "id"], { unique: true })
|
@Index(["channel_id", "id"], { unique: true })
|
||||||
export class Message extends EntityCache {
|
export class Message extends BaseClass {
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
@RelationId((message: Message) => message.channel)
|
@RelationId((message: Message) => message.channel)
|
||||||
@Index()
|
@Index()
|
||||||
|
@ -17,12 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, Unique } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, Unique } from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
|
|
||||||
@Entity("notes")
|
@Entity("notes")
|
||||||
@Unique(["owner", "target"])
|
@Unique(["owner", "target"])
|
||||||
export class Note extends EntityCache {
|
export class Note extends BaseClass {
|
||||||
@JoinColumn({ name: "owner_id" })
|
@JoinColumn({ name: "owner_id" })
|
||||||
@ManyToOne(() => User, { onDelete: "CASCADE" })
|
@ManyToOne(() => User, { onDelete: "CASCADE" })
|
||||||
owner: User;
|
owner: User;
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity } from "typeorm";
|
import { Column, Entity } from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
|
|
||||||
@Entity("rate_limits")
|
@Entity("rate_limits")
|
||||||
export class RateLimit extends EntityCache {
|
export class RateLimit extends BaseClass {
|
||||||
@Column() // no relation as it also
|
@Column() // no relation as it also
|
||||||
executor_id: string;
|
executor_id: string;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ import {
|
|||||||
ManyToOne,
|
ManyToOne,
|
||||||
RelationId,
|
RelationId,
|
||||||
} from "typeorm";
|
} from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Channel } from "./Channel";
|
import { Channel } from "./Channel";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ import { User } from "./User";
|
|||||||
|
|
||||||
@Entity("read_states")
|
@Entity("read_states")
|
||||||
@Index(["channel_id", "user_id"], { unique: true })
|
@Index(["channel_id", "user_id"], { unique: true })
|
||||||
export class ReadState extends EntityCache {
|
export class ReadState extends BaseClass {
|
||||||
@Column()
|
@Column()
|
||||||
@RelationId((read_state: ReadState) => read_state.channel)
|
@RelationId((read_state: ReadState) => read_state.channel)
|
||||||
channel_id: string;
|
channel_id: string;
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
|
|
||||||
@Entity("recipients")
|
@Entity("recipients")
|
||||||
export class Recipient extends EntityCache {
|
export class Recipient extends BaseClass {
|
||||||
@Column()
|
@Column()
|
||||||
@RelationId((recipient: Recipient) => recipient.channel)
|
@RelationId((recipient: Recipient) => recipient.channel)
|
||||||
channel_id: string;
|
channel_id: string;
|
||||||
|
@ -24,7 +24,7 @@ import {
|
|||||||
ManyToOne,
|
ManyToOne,
|
||||||
RelationId,
|
RelationId,
|
||||||
} from "typeorm";
|
} from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
|
|
||||||
export enum RelationshipType {
|
export enum RelationshipType {
|
||||||
@ -36,7 +36,7 @@ export enum RelationshipType {
|
|||||||
|
|
||||||
@Entity("relationships")
|
@Entity("relationships")
|
||||||
@Index(["from_id", "to_id"], { unique: true })
|
@Index(["from_id", "to_id"], { unique: true })
|
||||||
export class Relationship extends EntityCache {
|
export class Relationship extends BaseClass {
|
||||||
@Column({})
|
@Column({})
|
||||||
@RelationId((relationship: Relationship) => relationship.from)
|
@RelationId((relationship: Relationship) => relationship.from)
|
||||||
from_id: string;
|
from_id: string;
|
||||||
|
@ -18,11 +18,11 @@
|
|||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||||
|
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Guild } from "./Guild";
|
import { Guild } from "./Guild";
|
||||||
|
|
||||||
@Entity("roles")
|
@Entity("roles")
|
||||||
export class Role extends EntityCache {
|
export class Role extends BaseClass {
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
@RelationId((role: Role) => role.guild)
|
@RelationId((role: Role) => role.guild)
|
||||||
guild_id: string;
|
guild_id: string;
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
|
|
||||||
@Entity("security_keys")
|
@Entity("security_keys")
|
||||||
export class SecurityKey extends EntityCache {
|
export class SecurityKey extends BaseClass {
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
@RelationId((key: SecurityKey) => key.user)
|
@RelationId((key: SecurityKey) => key.user)
|
||||||
user_id: string;
|
user_id: string;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||||
import { Status } from "../interfaces/Status";
|
import { Status } from "../interfaces/Status";
|
||||||
import { Activity } from "../interfaces/Activity";
|
import { Activity } from "../interfaces/Activity";
|
||||||
@ -25,7 +25,7 @@ import { Activity } from "../interfaces/Activity";
|
|||||||
//TODO we need to remove all sessions on server start because if the server crashes without closing websockets it won't delete them
|
//TODO we need to remove all sessions on server start because if the server crashes without closing websockets it won't delete them
|
||||||
|
|
||||||
@Entity("sessions")
|
@Entity("sessions")
|
||||||
export class Session extends EntityCache {
|
export class Session extends BaseClass {
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
@RelationId((session: Session) => session.user)
|
@RelationId((session: Session) => session.user)
|
||||||
user_id: string;
|
user_id: string;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Guild } from "./Guild";
|
import { Guild } from "./Guild";
|
||||||
|
|
||||||
export enum StickerType {
|
export enum StickerType {
|
||||||
@ -34,7 +34,7 @@ export enum StickerFormatType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Entity("stickers")
|
@Entity("stickers")
|
||||||
export class Sticker extends EntityCache {
|
export class Sticker extends BaseClass {
|
||||||
@Column()
|
@Column()
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@ import {
|
|||||||
RelationId,
|
RelationId,
|
||||||
} from "typeorm";
|
} from "typeorm";
|
||||||
import { Sticker } from ".";
|
import { Sticker } from ".";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
|
|
||||||
@Entity("sticker_packs")
|
@Entity("sticker_packs")
|
||||||
export class StickerPack extends EntityCache {
|
export class StickerPack extends BaseClass {
|
||||||
@Column()
|
@Column()
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
|
@ -24,12 +24,12 @@ import {
|
|||||||
OneToMany,
|
OneToMany,
|
||||||
RelationId,
|
RelationId,
|
||||||
} from "typeorm";
|
} from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { TeamMember } from "./TeamMember";
|
import { TeamMember } from "./TeamMember";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
|
|
||||||
@Entity("teams")
|
@Entity("teams")
|
||||||
export class Team extends EntityCache {
|
export class Team extends BaseClass {
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
icon?: string;
|
icon?: string;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
|
|
||||||
export enum TeamMemberState {
|
export enum TeamMemberState {
|
||||||
@ -26,7 +26,7 @@ export enum TeamMemberState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Entity("team_members")
|
@Entity("team_members")
|
||||||
export class TeamMember extends EntityCache {
|
export class TeamMember extends BaseClass {
|
||||||
@Column({ type: "int" })
|
@Column({ type: "int" })
|
||||||
membership_state: TeamMemberState;
|
membership_state: TeamMemberState;
|
||||||
|
|
||||||
|
@ -17,12 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Guild } from "./Guild";
|
import { Guild } from "./Guild";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
|
|
||||||
@Entity("templates")
|
@Entity("templates")
|
||||||
export class Template extends EntityCache {
|
export class Template extends BaseClass {
|
||||||
@Column({ unique: true })
|
@Column({ unique: true })
|
||||||
code: string;
|
code: string;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import {
|
|||||||
trimSpecial,
|
trimSpecial,
|
||||||
} from "..";
|
} from "..";
|
||||||
import { BitField } from "../util/BitField";
|
import { BitField } from "../util/BitField";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { ConnectedAccount } from "./ConnectedAccount";
|
import { ConnectedAccount } from "./ConnectedAccount";
|
||||||
import { Member } from "./Member";
|
import { Member } from "./Member";
|
||||||
import { Relationship } from "./Relationship";
|
import { Relationship } from "./Relationship";
|
||||||
@ -94,7 +94,7 @@ export interface UserPrivate extends Pick<User, PrivateUserKeys> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Entity("users")
|
@Entity("users")
|
||||||
export class User extends EntityCache {
|
export class User extends BaseClass {
|
||||||
@Column()
|
@Column()
|
||||||
username: string; // username max length 32, min 2 (should be configurable)
|
username: string; // username max length 32, min 2 (should be configurable)
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Channel } from "./Channel";
|
import { Channel } from "./Channel";
|
||||||
import { Guild } from "./Guild";
|
import { Guild } from "./Guild";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
@ -25,7 +25,7 @@ import { Member } from "./Member";
|
|||||||
|
|
||||||
//https://gist.github.com/vassjozsef/e482c65df6ee1facaace8b3c9ff66145#file-voice_state-ex
|
//https://gist.github.com/vassjozsef/e482c65df6ee1facaace8b3c9ff66145#file-voice_state-ex
|
||||||
@Entity("voice_states")
|
@Entity("voice_states")
|
||||||
export class VoiceState extends EntityCache {
|
export class VoiceState extends BaseClass {
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
@RelationId((voice_state: VoiceState) => voice_state.guild)
|
@RelationId((voice_state: VoiceState) => voice_state.guild)
|
||||||
guild_id: string;
|
guild_id: string;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||||
import { Application } from "./Application";
|
import { Application } from "./Application";
|
||||||
import { EntityCache } from "../cache";
|
import { BaseClass } from "./BaseClass";
|
||||||
import { Channel } from "./Channel";
|
import { Channel } from "./Channel";
|
||||||
import { Guild } from "./Guild";
|
import { Guild } from "./Guild";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
@ -30,7 +30,7 @@ export enum WebhookType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Entity("webhooks")
|
@Entity("webhooks")
|
||||||
export class Webhook extends EntityCache {
|
export class Webhook extends BaseClass {
|
||||||
@Column({ type: "int" })
|
@Column({ type: "int" })
|
||||||
type: WebhookType;
|
type: WebhookType;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ export const ajv = new Ajv({
|
|||||||
allowUnionTypes: true,
|
allowUnionTypes: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
addFormats(ajv as never);
|
addFormats(ajv);
|
||||||
|
|
||||||
export function validateSchema<G extends object>(schema: string, data: G): G {
|
export function validateSchema<G extends object>(schema: string, data: G): G {
|
||||||
const valid = ajv.validate(schema, normalizeBody(data));
|
const valid = ajv.validate(schema, normalizeBody(data));
|
||||||
|
@ -38,8 +38,7 @@ const dbConnectionString =
|
|||||||
|
|
||||||
const DatabaseType = dbConnectionString.includes("://")
|
const DatabaseType = dbConnectionString.includes("://")
|
||||||
? dbConnectionString.split(":")[0]?.replace("+srv", "")
|
? dbConnectionString.split(":")[0]?.replace("+srv", "")
|
||||||
: "better-sqlite3";
|
: "sqlite";
|
||||||
|
|
||||||
const isSqlite = DatabaseType.includes("sqlite");
|
const isSqlite = DatabaseType.includes("sqlite");
|
||||||
|
|
||||||
const DataSourceOptions = new DataSource({
|
const DataSourceOptions = new DataSource({
|
||||||
@ -51,7 +50,7 @@ const DataSourceOptions = new DataSource({
|
|||||||
database: isSqlite ? dbConnectionString : undefined,
|
database: isSqlite ? dbConnectionString : undefined,
|
||||||
entities: [path.join(__dirname, "..", "entities", "*.js")],
|
entities: [path.join(__dirname, "..", "entities", "*.js")],
|
||||||
synchronize: !!process.env.DB_SYNC,
|
synchronize: !!process.env.DB_SYNC,
|
||||||
logging: process.env["DB_LOGGING"] === "true",
|
logging: false,
|
||||||
bigNumberStrings: false,
|
bigNumberStrings: false,
|
||||||
supportBigNumbers: true,
|
supportBigNumbers: true,
|
||||||
name: "default",
|
name: "default",
|
||||||
@ -78,13 +77,7 @@ export async function initDatabase(): Promise<DataSource> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!process.env.DB_SYNC) {
|
if (!process.env.DB_SYNC) {
|
||||||
const supported = [
|
const supported = ["mysql", "mariadb", "postgres", "sqlite"];
|
||||||
"mysql",
|
|
||||||
"mariadb",
|
|
||||||
"postgres",
|
|
||||||
"sqlite",
|
|
||||||
"better-sqlite3",
|
|
||||||
];
|
|
||||||
if (!supported.includes(DatabaseType)) {
|
if (!supported.includes(DatabaseType)) {
|
||||||
console.log(
|
console.log(
|
||||||
"[Database]" +
|
"[Database]" +
|
||||||
@ -120,10 +113,10 @@ export async function initDatabase(): Promise<DataSource> {
|
|||||||
// Manually insert every current migration to prevent this:
|
// Manually insert every current migration to prevent this:
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
dbConnection.migrations.map((migration) =>
|
dbConnection.migrations.map((migration) =>
|
||||||
Migration.create({
|
Migration.insert({
|
||||||
name: migration.name,
|
name: migration.name,
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
}).save(),
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -257,26 +257,23 @@ export async function getPermission(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (guild_id) {
|
if (guild_id) {
|
||||||
const result = await Promise.all([
|
guild = await Guild.findOneOrFail({
|
||||||
Guild.findOneOrFail({
|
where: { id: guild_id },
|
||||||
where: { id: guild_id },
|
select: ["id", "owner_id", ...(opts.guild_select || [])],
|
||||||
select: ["id", "owner_id", ...(opts.guild_select || [])],
|
relations: opts.guild_relations,
|
||||||
relations: opts.guild_relations,
|
});
|
||||||
}),
|
|
||||||
Member.findOneOrFail({
|
|
||||||
where: { guild_id, id: user_id },
|
|
||||||
relations: ["roles", ...(opts.member_relations || [])],
|
|
||||||
// select: [
|
|
||||||
// "id", // TODO: Bug in typeorm? adding these selects breaks the query.
|
|
||||||
// "roles",
|
|
||||||
// ...(opts.member_select || []),
|
|
||||||
// ],
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
guild = result[0];
|
|
||||||
member = result[1];
|
|
||||||
if (guild.owner_id === user_id)
|
if (guild.owner_id === user_id)
|
||||||
return new Permissions(Permissions.FLAGS.ADMINISTRATOR);
|
return new Permissions(Permissions.FLAGS.ADMINISTRATOR);
|
||||||
|
|
||||||
|
member = await Member.findOneOrFail({
|
||||||
|
where: { guild_id, id: user_id },
|
||||||
|
relations: ["roles", ...(opts.member_relations || [])],
|
||||||
|
// select: [
|
||||||
|
// "id", // TODO: Bug in typeorm? adding these selects breaks the query.
|
||||||
|
// "roles",
|
||||||
|
// ...(opts.member_select || []),
|
||||||
|
// ],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let recipient_ids = channel?.recipients?.map((x) => x.user_id);
|
let recipient_ids = channel?.recipients?.map((x) => x.user_id);
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
import jwt, { VerifyOptions } from "jsonwebtoken";
|
import jwt, { VerifyOptions } from "jsonwebtoken";
|
||||||
import { Config } from "./Config";
|
import { Config } from "./Config";
|
||||||
import { User } from "../entities";
|
import { User } from "../entities";
|
||||||
import { KeyObject } from "crypto";
|
|
||||||
|
|
||||||
export const JWTOptions: VerifyOptions = { algorithms: ["HS256"] };
|
export const JWTOptions: VerifyOptions = { algorithms: ["HS256"] };
|
||||||
|
|
||||||
@ -63,7 +62,7 @@ async function checkEmailToken(
|
|||||||
|
|
||||||
export function checkToken(
|
export function checkToken(
|
||||||
token: string,
|
token: string,
|
||||||
jwtSecret: string | KeyObject,
|
jwtSecret: string,
|
||||||
isEmailVerification = false,
|
isEmailVerification = false,
|
||||||
): Promise<UserTokenData> {
|
): Promise<UserTokenData> {
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
@ -87,7 +86,7 @@ export function checkToken(
|
|||||||
|
|
||||||
const user = await User.findOne({
|
const user = await User.findOne({
|
||||||
where: { id: decoded.id },
|
where: { id: decoded.id },
|
||||||
select: ["id", "data", "bot", "disabled", "deleted", "rights"],
|
select: ["data", "bot", "disabled", "deleted", "rights"],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!user) return rej("Invalid Token");
|
if (!user) return rej("Invalid Token");
|
||||||
|
@ -24,7 +24,7 @@ export * from "./cdn";
|
|||||||
export * from "./Config";
|
export * from "./Config";
|
||||||
export * from "./Constants";
|
export * from "./Constants";
|
||||||
export * from "./Database";
|
export * from "./Database";
|
||||||
export * from "./email/index";
|
export * from "./email";
|
||||||
export * from "./Event";
|
export * from "./Event";
|
||||||
export * from "./FieldError";
|
export * from "./FieldError";
|
||||||
export * from "./Intents";
|
export * from "./Intents";
|
||||||
|
Loading…
Reference in New Issue
Block a user