Skip to content

Commit 36a8ac5

Browse files
committed
chore: cleanup
1 parent 57d16b5 commit 36a8ac5

15 files changed

+4659
-34
lines changed

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
.vscode
2-
package-lock.json
3-
yarn.lock
42
.envrc
53
/lib
64
/tmp

docker-compose.development.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ services:
88

99
bot:
1010
build: .
11-
command: node ./lib/server.js
11+
command: yarn dev
1212
ports:
1313
- "3000:3000"
1414
volumes:
15-
- ./lib:/app/lib
15+
- ./src:/app/src
1616
env_file: .env
1717
environment:
1818
MONGODB_URL: mongodb://mongo:27017/shipid

docker-compose.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ services:
1010
bot:
1111
build: .
1212
restart: unless-stopped
13-
command: yarn start
13+
command: node .
1414
env_file: .env
1515
environment:
1616
MONGODB_URL: mongodb://mongo:27017/shipid
17-
DEBUG: shipid
18-
VIRTUAL_HOST: shipid.holodata.org
19-
VIRTUAL_PORT: 3000
20-
LETSENCRYPT_HOST: shipid.holodata.org
17+
NODE_ENV: production
18+
networks:
19+
- default
20+
- webproxy
21+
22+
networks:
23+
webproxy:
24+
external: true

package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
"scripts": {
77
"build": "tsc",
88
"clean": "shx rm -rf lib",
9-
"dev": "tsc -w",
9+
"dev": "run-p dev:*",
10+
"dev:server": "nodemon -w lib ./lib/server.js",
11+
"dev:tsc": "tsc -w",
12+
"devcontainer": "docker-compose -f docker-compose.development.yml up",
1013
"prepare": "husky install",
14+
"start": "node ./lib/server.js",
1115
"test": "jest"
1216
},
13-
"main": "lib/server.js",
17+
"main": "./lib/server.js",
1418
"files": [
1519
"lib"
1620
],

src/modules/discord/commands/pair.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { PREFIX } from "../../../constants";
2-
import { findOrCreateGuild } from "../../../db";
31
import { HandlerOptions } from "../interfaces";
42
import { checkModPermission } from "../util";
3+
import { PREFIX } from "/@/constants";
4+
import { findOrCreateGuild } from "/@/db";
55

66
export const pair = {
77
// !sid pair <channelId> <role name>

src/modules/discord/commands/verify.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { getUserByDiscordId } from "../../../db";
21
import { HandlerOptions } from "../interfaces";
32
import { applyRolesPhase } from "../phases/applyRolesPhase";
43
import { onboardingPhase } from "../phases/onboardingPhase";
54
import { verificationPhase } from "../phases/verificationPhase";
5+
import { getUserByDiscordId } from "/@/db";
66

77
export const verify = {
88
// !sid verify

src/modules/discord/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Discord from "discord.js";
2-
import { HB_MONGO_URI } from "../../constants";
3-
import { log } from "../../util";
4-
import { Honeybee } from "../honeybee";
52
import { commands } from "./commands";
3+
import { HB_MONGO_URI } from "/@/constants";
4+
import { Honeybee } from "/@/modules/honeybee";
5+
import { log } from "/@/util";
66

77
export function createBot({ prefix }: { prefix: string }) {
88
const hb = new Honeybee(HB_MONGO_URI);
@@ -17,7 +17,7 @@ export function createBot({ prefix }: { prefix: string }) {
1717
const args = payload;
1818

1919
if (!commandName) return;
20-
console.log(`command: ${commandName}`, payload);
20+
log(`command: ${commandName}`, payload);
2121

2222
const command = commands.find(
2323
(command) => command.command === commandName

src/modules/discord/interfaces.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Discord from "discord.js";
2-
import { Honeybee } from "../honeybee";
2+
import { Honeybee } from "/@/modules/honeybee";
33

44
export interface HandlerOptions {
55
message: Discord.Message;

src/modules/discord/phases/onboardingPhase.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import jwt from "jsonwebtoken";
2-
import { HOST, JWT_SECRET } from "../../../constants";
3-
import { JwtToken } from "../../../auth";
41
import { Message } from "discord.js";
2+
import jwt from "jsonwebtoken";
3+
import { JwtToken } from "/@/auth";
4+
import { HOST, JWT_SECRET } from "/@/constants";
5+
import { log } from "/@/util";
56

67
export function onboardingPhase(message: Message) {
7-
console.log("onboardingPhase");
8+
log("onboardingPhase");
89
const payload: JwtToken = {
910
discordId: message.author.id,
1011
iat: Date.now(),

src/modules/discord/phases/verificationPhase.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { getRoleMapsForGuild } from "../../../db";
21
import { Message } from "discord.js";
3-
import { User } from "../../../models/user";
4-
import { Honeybee } from "../../honeybee";
52
import { RoleChangeset } from "../interfaces";
3+
import { getRoleMapsForGuild } from "/@/db";
4+
import { User } from "/@/models/user";
5+
import { Honeybee } from "/@/modules/honeybee";
66

77
export async function verificationPhase(
88
message: Message,

src/modules/honeybee/db.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { getModelForClass, ReturnModelType } from "@typegoose/typegoose";
2-
import { BeAnObject } from "@typegoose/typegoose/lib/types";
1+
import { getModelForClass } from "@typegoose/typegoose";
32
import mongoose from "mongoose";
43
import { Chat } from "./chat";
54

src/modules/youtube/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Request, Response, Router } from "express";
22
import { Auth, google, youtube_v3 } from "googleapis";
33
import jwt from "jsonwebtoken";
4-
import { JWT_SECRET } from "../../constants";
5-
import { JwtToken } from "../../auth";
6-
import UserModel from "../../models/user";
4+
import { JwtToken } from "/@/auth";
5+
import { JWT_SECRET } from "/@/constants";
6+
import UserModel from "/@/models/user";
77

88
export function createYouTubeHandler({
99
clientId,

src/server.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
GOOGLE_CLIENT_ID,
77
GOOGLE_CLIENT_SECRET,
88
HOST,
9+
isDev,
910
MONGODB_URL,
1011
PORT,
1112
PREFIX,
@@ -33,6 +34,6 @@ app.use(youtubeHandler);
3334
const server = http.createServer(app);
3435

3536
server.listen(PORT, () => {
36-
console.log("http://localhost:" + PORT);
37+
console.log(`Listening ${PREFIX} at ${HOST} (${isDev ? "dev" : "prod"})`);
3738
bot.login(DISCORD_TOKEN);
3839
});

tsconfig.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@
4646

4747
/* Module Resolution Options */
4848
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
49-
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
50-
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
49+
"baseUrl": "./" /* Base directory to resolve non-absolute module names. */,
50+
"paths": {
51+
"/@/*": ["./src/*"]
52+
} /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */,
5153
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
5254
// "typeRoots": [], /* List of folders to include type definitions from. */
5355
// "types": [], /* Type declaration files to be included in compilation. */

0 commit comments

Comments
 (0)