Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from ChatSift:main #3

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@
"NodeJS": "readonly"
},
"rules": {
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-extraneous-class": "off",
"curly": ["error", "all"],
"eqeqeq": ["error", "always", { "null": "ignore" }],
"no-eq-null": "off",
"no-unused-vars": "off",
"import/extensions": "off",
"no-useless-constructor": "off",
"unicorn/require-post-message-target-origin": "off"
"@typescript-eslint/consistent-type-definitions": ["error", "interface"]
}
}
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Node v16
- name: Install Node
uses: actions/setup-node@v1
with:
node-version: 16
node-version: 20

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Node.js v16
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: 16
node-version: 20
cache: 'yarn'
cache-dependency-path: yarn.lock

Expand Down
546 changes: 0 additions & 546 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

550 changes: 0 additions & 550 deletions .yarn/plugins/@yarnpkg/plugin-version.cjs

This file was deleted.

28 changes: 0 additions & 28 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

This file was deleted.

786 changes: 0 additions & 786 deletions .yarn/releases/yarn-3.2.1.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.1.cjs

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
nodeLinker: node-modules
compressionLevel: mixed

enableGlobalCache: false

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: '@yarnpkg/plugin-version'
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: '@yarnpkg/plugin-interactive-tools'
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.2.1.cjs
yarnPath: .yarn/releases/yarn-4.0.1.cjs
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16-alpine
FROM node:20-alpine
LABEL name "modmail"

WORKDIR /usr/modmail
Expand Down
9 changes: 1 addition & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ services:
- ./logs:/usr/modmail/logs
depends_on:
- postgres
command:
[
'node',
'--es-module-specifier-resolution=node',
'--enable-source-maps',
'--no-warnings',
'./packages/bot/dist/index.js',
]
command: ['node', '--enable-source-maps', '--no-warnings', './packages/bot/dist/index.js']

volumes:
postgres-data:
Expand Down
41 changes: 20 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@chatsift/modmail",
"description": "✉️",
"packageManager": "yarn@3.2.1",
"packageManager": "yarn@4.0.1",
"private": true,
"version": "0.0.0",
"workspaces": [
Expand All @@ -20,33 +20,32 @@
},
"homepage": "https://github.com/chatsift/modmail",
"scripts": {
"lint": "turbo run lint && prettier --check --plugin-search-dir=. .",
"lint": "turbo run lint && prettier --check .",
"build": "turbo run build",
"format": "prettier --write --plugin-search-dir=. .",
"format": "prettier --write .",
"prisma": "dotenv -e .env prisma",
"deploy-commands": "rimraf ./packages/bot/dist && turbo run --no-cache build --filter ./packages/bot && dotenv -e .env -v DEPLOY=true -- node --es-module-specifier-resolution=node --enable-source-maps ./packages/bot/dist/index.js",
"start-bot": "dotenv -e .env -- node --es-module-specifier-resolution=node --enable-source-maps ./packages/bot/dist/index.js",
"start-api": "dotenv -e .env -- node --es-module-specifier-resolution=node --enable-source-maps ./packages/api/dist/index.js",
"deploy-commands": "rimraf ./packages/bot/dist && turbo run --no-cache build --filter ./packages/bot && dotenv -e .env -v DEPLOY=true -- node --enable-source-maps ./packages/bot/dist/index.js",
"start-bot": "dotenv -e .env -- node --enable-source-maps ./packages/bot/dist/index.js",
"start-api": "dotenv -e .env -- node --enable-source-maps ./packages/api/dist/index.js",
"prepare": "is-ci || husky install",
"update": "yarn upgrade-interactive"
},
"devDependencies": {
"@commitlint/cli": "^17.0.3",
"@commitlint/config-angular": "^17.0.3",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"dotenv-cli": "^5.1.0",
"eslint": "^8.21.0",
"eslint-config-neon": "^0.1.33",
"eslint-plugin-typescript-sort-keys": "^2.1.0",
"husky": "^8.0.1",
"@commitlint/cli": "^18.2.0",
"@commitlint/config-angular": "^18.1.0",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"dotenv-cli": "^7.3.0",
"eslint": "^8.52.0",
"eslint-config-neon": "0.1.54",
"husky": "^8.0.3",
"is-ci": "^3.0.1",
"prettier": "^2.7.1",
"prettier-eslint": "^15.0.1",
"prisma": "^4.2.1",
"rimraf": "^3.0.2",
"turbo": "^1.4.3",
"typescript": "^4.8.3"
"prettier": "^3.0.3",
"prettier-eslint": "^16.1.2",
"prisma": "^5.5.2",
"rimraf": "^5.0.5",
"turbo": "^1.10.16",
"typescript": "^5.2.2"
},
"husky": {
"hooks": {
Expand Down
36 changes: 18 additions & 18 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@
"node": ">=16.9.0"
},
"devDependencies": {
"@types/cors": "^2.8.12",
"@types/node": "^16.11.60",
"@types/cors": "^2.8.15",
"@types/node": "^20.8.10",
"@types/pino": "^7.0.5",
"prisma": "^4.2.1",
"typescript": "^4.8.3"
"prisma": "^5.5.2",
"typescript": "^5.2.2"
},
"dependencies": {
"@chatsift/pino-rotate-file": "^0.1.2",
"@chatsift/readdir": "^0.2.0",
"@chatsift/rest-utils": "^0.6.2",
"@discordjs/rest": "^1.2.0",
"@hapi/boom": "^10.0.0",
"@prisma/client": "^4.2.1",
"@sapphire/shapeshift": "^3.4.1",
"@chatsift/pino-rotate-file": "^0.2.0",
"@chatsift/readdir": "^0.3.0",
"@chatsift/rest-utils": "^0.7.0",
"@discordjs/rest": "^2.0.1",
"@hapi/boom": "^10.0.1",
"@prisma/client": "^5.5.2",
"@sapphire/shapeshift": "^3.9.3",
"cors": "^2.8.5",
"discord-api-types": "^0.37.10",
"helmet": "^5.1.1",
"pino": "^8.4.1",
"pino-pretty": "^8.1.0",
"discord-api-types": "^0.37.62",
"helmet": "^7.0.0",
"pino": "^8.16.1",
"pino-pretty": "^10.2.3",
"polka": "^1.0.0-next.22",
"prisma-error-enum": "^0.1.2",
"prisma-error-enum": "^0.1.3",
"reflect-metadata": "^0.1.13",
"tslib": "^2.4.0",
"tsyringe": "^4.7.0"
"tslib": "^2.6.2",
"tsyringe": "^4.8.0"
}
}
6 changes: 3 additions & 3 deletions packages/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import helmet from 'helmet';
import type { Middleware } from 'polka';
import polka from 'polka';
import { container } from 'tsyringe';
import { Env } from './util/env';
import { logger } from './util/logger';
import { Env } from './util/env.js';
import { logger } from './util/logger.js';

const env = container.resolve(Env);
container.register(PrismaClient, { useValue: new PrismaClient() });
Expand Down Expand Up @@ -57,4 +57,4 @@ for await (const file of files) {

app.listen(env.port, () => logger.info(`Listening to requests on port ${env.port}`));

export * from './routeTypes';
export * from './routeTypes.js';
8 changes: 4 additions & 4 deletions packages/api/src/routeTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type * as routes from './routes/index';
type Narrow<T, U> = T extends U ? T : never;
type ConstructorToType<TConstructor> = TConstructor extends new (...args: any[]) => infer T ? T : never;
type RoutesByClassNames = {
[K in keyof typeof routes]: ConstructorToType<typeof routes[K]>;
[K in keyof typeof routes]: ConstructorToType<(typeof routes)[K]>;
};
type RoutesByPaths = {
[Path in InferRoutePath<RoutesByClassNames[keyof RoutesByClassNames]>]: Narrow<
Expand All @@ -19,13 +19,13 @@ type RoutesByPaths = {
>;
};

type RouteMethodMap = {
interface RouteMethodMap {
[RouteMethod.get]: 'get';
[RouteMethod.post]: 'post';
[RouteMethod.put]: 'put';
[RouteMethod.delete]: 'delete';
[RouteMethod.patch]: 'patch';
};
}

export type ModmailRoutes = {
[Path in keyof RoutesByPaths]: {
Expand All @@ -46,4 +46,4 @@ export type InferModmailRouteResult<
TMethod extends keyof ModmailRoutes[TPath],
> = InferRouteResult<ModmailRoutes[TPath][TMethod]>;

export * from './util/models';
export * from './util/models.js';
4 changes: 2 additions & 2 deletions packages/api/src/routes/createSnippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import type {
import { ApplicationCommandOptionType, Routes } from 'discord-api-types/v10';
import type { NextHandler, Response } from 'polka';
import { singleton } from 'tsyringe';
import { Env } from '../util/env';
import { Env } from '../util/env.js';
import type { Snippet } from '../util/models';
import { snowflakeSchema } from '../util/snowflakeSchema';
import { snowflakeSchema } from '../util/snowflakeSchema.js';

const schema = s.object({
name: s.string.lengthGreaterThan(0).lengthLessThanOrEqual(32),
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/routes/deleteSnippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { s } from '@sapphire/shapeshift';
import { Routes } from 'discord-api-types/v10';
import type { NextHandler, Request, Response } from 'polka';
import { singleton } from 'tsyringe';
import { Env } from '../util/env';
import { Env } from '../util/env.js';
import type { Snippet } from '../util/models';
import { snowflakeSchema } from '../util/snowflakeSchema';
import { snowflakeSchema } from '../util/snowflakeSchema.js';

@singleton()
export default class extends Route<Snippet, never> {
Expand Down
14 changes: 7 additions & 7 deletions packages/api/src/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { default as GetSettingsRoute } from './getSettings';
export { default as UpdateSettingsRoute } from './updateSettings';
export { default as GetSnippetsRoute } from './getSnippets';
export { default as GetSnippetRoute } from './getSnippet';
export { default as CreateSnippetRoute } from './createSnippet';
export { default as UpdateSnippetRoute } from './updateSnippet';
export { default as DeleteSnippetRoute } from './deleteSnippet';
export { default as GetSettingsRoute } from './getSettings.js';
export { default as UpdateSettingsRoute } from './updateSettings.js';
export { default as GetSnippetsRoute } from './getSnippets.js';
export { default as GetSnippetRoute } from './getSnippet.js';
export { default as CreateSnippetRoute } from './createSnippet.js';
export { default as UpdateSnippetRoute } from './updateSnippet.js';
export { default as DeleteSnippetRoute } from './deleteSnippet.js';
2 changes: 1 addition & 1 deletion packages/api/src/routes/updateSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { s } from '@sapphire/shapeshift';
import type { Response } from 'polka';
import { singleton } from 'tsyringe';
import type { GuildSettings } from '../util/models';
import { snowflakeSchema } from '../util/snowflakeSchema';
import { snowflakeSchema } from '../util/snowflakeSchema.js';

const schema = s.object({
modmailChannelId: snowflakeSchema.nullish,
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/routes/updateSnippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import type { RESTPatchAPIApplicationGuildCommandJSONBody } from 'discord-api-ty
import { Routes } from 'discord-api-types/v10';
import type { NextHandler, Response } from 'polka';
import { singleton } from 'tsyringe';
import { Env } from '../util/env';
import { Env } from '../util/env.js';
import type { Snippet } from '../util/models';
import { snowflakeSchema } from '../util/snowflakeSchema';
import { snowflakeSchema } from '../util/snowflakeSchema.js';

const schema = s.object({
name: s.string.lengthGreaterThan(0).lengthLessThanOrEqual(32).optional,
Expand Down
36 changes: 18 additions & 18 deletions packages/api/src/util/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
// Because otherwise we would need to somehow share our prisma.schema (and 2 others) with the frontend
// Which would NOT work. Absolutely make sure to use the types below and to cast away any types from @prsisma/client

export type GuildSettings = {
export interface GuildSettings {
alertRoleId: string | null;
farewellMessage: string | null;
greetingMessage: string | null;
guildId: string;
modmailChannelId: string | null;
simpleMode: boolean;
};
}

export type SnippetUpdates = {
export interface SnippetUpdates {
oldContent: string;
snippetId: number;
snippetUpdateId: number;
updatedAt: Date;
updatedBy: string;
};
}

export type Snippet = {
export interface Snippet {
commandId: string;
content: string;
createdAt: Date;
Expand All @@ -32,16 +32,16 @@ export type Snippet = {
name: string;
snippetId: number;
timesUsed: number;
};
}

export type ScheduledThreadClose = {
export interface ScheduledThreadClose {
closeAt: Date;
scheduledById: string;
silent: boolean;
threadId: number;
};
}

export type ThreadMessage = {
export interface ThreadMessage {
anon: boolean;
guildId: string;
guildMessageId: string;
Expand All @@ -51,9 +51,9 @@ export type ThreadMessage = {
threadMessageId: number;
userId: string;
userMessageId: string;
};
}

export type Thread = {
export interface Thread {
channelId: string;
closedAt: Date | null;
closedById: string | null;
Expand All @@ -63,20 +63,20 @@ export type Thread = {
lastLocalThreadMessageId: number;
threadId: number;
userId: string;
};
}

export type Block = {
export interface Block {
expiresAt: Date | null;
guildId: string;
userId: string;
};
}

export type ThreadOpenAlert = {
export interface ThreadOpenAlert {
guildId: string;
userId: string;
};
}

export type ThreadReplyAlert = {
export interface ThreadReplyAlert {
threadId: number;
userId: string;
};
}
Loading