Skip to content

Commit

Permalink
refactor: ts sub projects
Browse files Browse the repository at this point in the history
  • Loading branch information
drazisil committed Nov 16, 2021
1 parent 5e5e73b commit bc65d62
Show file tree
Hide file tree
Showing 90 changed files with 337 additions and 175 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"scripts": {
"audit": "npm audit",
"check:license": "npm licenses audit --summary --config=licenses.config.js",
"start": "ts-node packages/app.ts",
"build": "tsc -p ./packages/tsconfig.json",
"start": "node built/bin/app.js",
"build": "npx tsc -b src/tsconfig.json --verbose",
"build:clean": "rm -rf built && npm run build",
"lint": "eslint packages/**/*.ts && prettier --write packages",
"lint": "eslint src/**/*.ts && prettier --write src",
"test": "npm run lint && npm run test:only && npm run test:coverage",
"test:only": "tap --ts --reporter=spec --no-check-coverage packages/**/*.test.ts",
"test:only": "tap --ts --reporter=spec --no-check-coverage src/**/*.test.ts",
"test:coverage": "tap --coverage-report=html --coverage-report=lcov --no-check-coverage --no-browser"
},
"author": "Drazi Crendraven <drazisil@hey.com>",
Expand Down
25 changes: 0 additions & 25 deletions packages/config/app.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/database/app.ts

This file was deleted.

5 changes: 0 additions & 5 deletions packages/patch/app.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/router/app.ts

This file was deleted.

22 changes: 0 additions & 22 deletions packages/tsconfig.json

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions packages/admin/src/index.ts → src/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
_sslOptions,
AppConfiguration,
ConfigurationManager,
} from "../../config/src/index";
import { IMCServer } from "../../types/src/index";
} from "../config/index";
import { IMCServer } from "../types/index";

const log = P().child({ service: "mcoserver:AdminServer;" });
log.level = process.env["LOG_LEVEL"] || "info";
Expand Down
9 changes: 9 additions & 0 deletions src/admin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig-noncomposite-base",
"compilerOptions": {
"outDir": "../../built",
"types": ["node"]
},
"files": ["index.ts"],
"references": []
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions packages/auth/src/index.ts → src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import P from "pino";
import { IncomingMessage, ServerResponse } from "http";
import { Socket } from "net";
import { SslOptions } from "../../types/src/index";
import { readFileSync } from "fs";
import { EServerConnectionName, RoutingMesh } from "../../router/src/index";
import { IncomingMessage, ServerResponse } from "http";
import { createServer, Server } from "https";
import { AppConfiguration, ConfigurationManager } from "../../config/src/index";
import { Socket } from "net";
import P from "pino";
import { AppConfiguration, ConfigurationManager } from "../config/index";
import { EServerConnectionName, RoutingMesh } from "../router/index";
import { SslOptions } from "../types/index";

const log = P().child({ service: "MCOServer:Auth" });
log.level = process.env["LOG_LEVEL"] || "info";
Expand Down
9 changes: 9 additions & 0 deletions src/auth/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig-noncomposite-base",
"compilerOptions": {
"outDir": "../../built",
"types": ["node"]
},
"files": ["index.ts"],
"references": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import t from "tap";
import { AuthLogin } from "../src/index";
import { AuthLogin } from "./index";

t.test("WebServer", (t) => {
const _ = AuthLogin.getInstance();
Expand Down
14 changes: 7 additions & 7 deletions packages/app.ts → src/bin/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { RoutingServer } from "./router/src/index";
import { PatchServer } from "./patch/src/index";
import { AuthLogin } from "./auth/src/index";
import { ShardServer } from "./shard/src/index";
import { HTTPProxyServer } from "./proxy/src/index";
import { MCServer } from "./core/src/index";
import { AdminServer } from "./admin/src/index";
import { RoutingServer } from "../router/index";
import { PatchServer } from "../patch/index";
import { AuthLogin } from "../auth/index";
import { ShardServer } from "../shard/index";
import { HTTPProxyServer } from "../proxy/index";
import { MCServer } from "../core/index";
import { AdminServer } from "../admin/index";

// What servers do we need?
// * Routing Server
Expand Down
9 changes: 9 additions & 0 deletions src/bin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig-noncomposite-base",
"compilerOptions": {
"outDir": "../../built",
"types": ["node"]
},
"files": ["app.ts"],
"references": []
}
2 changes: 1 addition & 1 deletion packages/config/src/config.ts → src/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppConfiguration } from ".";
import { AppConfiguration } from "./index";

const savedConfig: AppConfiguration = {
certificate: {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import t from "tap";
import { _sslOptions } from "../src/ssl-options";
import { _sslOptions } from "./ssl-options";

const fakeConfig = {
certificate: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import { readFileSync } from "fs";
import P from "pino";
import { SslOptions } from "../../types/src/index";
import { AppConfiguration } from ".";
import { SslOptions } from "../types";
import { AppConfiguration } from "./index";

const log = P().child({ service: "mcoserver:AdminServer;" });
log.level = process.env["LOG_LEVEL"] || "info";
Expand Down
9 changes: 9 additions & 0 deletions src/config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig-noncomposite-base",
"compilerOptions": {
"outDir": "../../built",
"types": ["node"]
},
"files": ["index.ts"],
"references": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import { DatabaseManager } from "../../database/src/index";
import { MessageNode } from "../../message-types/src/index";
import { TCPManager } from "../../transactions/src/index";
import { DatabaseManager } from "../database/index";
import { MessageNode } from "../message-types/index";
import { TCPManager } from "../transactions/index";
import {
EMessageDirection,
IConnectionManager,
IDatabaseManager,
ITCPConnection,
NPS_COMMANDS,
UnprocessedPacket,
} from "../../types/src/index";
} from "../types/index";
import { Socket } from "net";
import { EncryptionManager } from "./encryption-mgr";
import { NPSPacketManager } from "./nps-packet-manager";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import t from "tap";
import { SocketFactory } from "./../../test-helpers/socket-factory";
import { ConnectionManager } from "../src/connection-mgr";
import { EncryptionManager } from "../src/encryption-mgr";
import { TCPConnection } from "../src/tcpConnection";
t.mock("../src/connection-mgr", {});
import { SocketFactory } from "../socket-factory";
import { ConnectionManager } from "./connection-mgr";
import { EncryptionManager } from "./encryption-mgr";
import { TCPConnection } from "./tcpConnection";
t.mock("./connection-mgr", {});

t.test("ConnectionObj", (t) => {
const testConnection = new TCPConnection("abc", SocketFactory.createSocket());
Expand Down
File renamed without changes.
8 changes: 2 additions & 6 deletions packages/core/src/index.ts → src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import P from "pino";
import {
IConnectionManager,
IMCServer,
ITCPConnection,
} from "../../types/src/index";
import { IConnectionManager, IMCServer, ITCPConnection } from "../types/index";
import { ConnectionManager } from "./connection-mgr";
import { AppConfiguration, ConfigurationManager } from "../../config/src/index";
import { AppConfiguration, ConfigurationManager } from "../config/index";
import { ListenerThread } from "./listener-thread";

const log = P().child({ service: "mcoserver:MCServer" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import t from "tap";
import { SocketFactory } from "./../../test-helpers/socket-factory";
import { ConnectionManager } from "../src/connection-mgr";
import { ListenerThread } from "../src/listener-thread";
import { SocketFactory } from "../socket-factory";
import { ConnectionManager } from "./connection-mgr";
import { ListenerThread } from "./listener-thread";

t.test("ListenerThread - _onData", async () => {
const listenerThread = ListenerThread.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ITCPConnection,
IConnectionManager,
IListenerThread,
} from "../../types/src/index";
} from "../types/index";

const log = P().child({ service: "mcoserver:ListenerThread" });
log.level = process.env["LOG_LEVEL"] || "info";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import t from "tap";
import { NPSPacketManager } from "../src/nps-packet-manager";
import { NPSPacketManager } from "./nps-packet-manager";

t.test("NPSPacketManager", (t) => {
t.test("NPSPacketManger", async (t) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import P from "pino";
import { ITCPConnection, UnprocessedPacket } from "../../types/src/index";
import { LobbyServer } from "../../lobby/src/index";
import { LoginServer } from "../../login/src/index";
import { PersonaServer } from "../../persona/src/index";
import { DatabaseManager } from "../../database/src/index";
import { ITCPConnection, UnprocessedPacket } from "../types/index";
import { LobbyServer } from "../lobby/index";
import { LoginServer } from "../login/index";
import { PersonaServer } from "../persona/index";
import { DatabaseManager } from "../database/index";

const log = P().child({ service: "mcoserver:NPSPacketManager" });
log.level = process.env["LOG_LEVEL"] || "info";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ITCPConnection,
UnprocessedPacket,
LobbyCipers,
} from "../../types/src/index";
} from "../types/index";
import { createCipheriv, createDecipheriv } from "crypto";
import { Socket } from "net";
import P from "pino";
Expand Down
9 changes: 9 additions & 0 deletions src/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig-noncomposite-base",
"compilerOptions": {
"outDir": "../../built",
"types": ["node"]
},
"files": ["index.ts"],
"references": []
}
File renamed without changes.
6 changes: 3 additions & 3 deletions packages/database/src/index.ts → src/database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

import * as sqlite3 from "sqlite3";
import { Database, open } from "sqlite";
import { IDatabaseManager, SessionRecord } from "../../types/src/index";
import { IDatabaseManager, SessionRecord } from "../types/index";
import P from "pino";
import { AppConfiguration, ConfigurationManager } from "../../config/src/index";
import { AppConfiguration, ConfigurationManager } from "../config/index";
import { createServer, IncomingMessage, Server, ServerResponse } from "http";
import { EServerConnectionName, RoutingMesh } from "../../router/src/index";
import { EServerConnectionName, RoutingMesh } from "../router/index";

const log = P().child({ service: "mcoserver:DatabaseMgr" });
log.level = process.env["LOG_LEVEL"] || "info";
Expand Down
9 changes: 9 additions & 0 deletions src/database/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig-noncomposite-base",
"compilerOptions": {
"outDir": "../../built",
"types": ["node"]
},
"files": ["index.ts"],
"references": []
}
8 changes: 4 additions & 4 deletions packages/lobby/src/index.ts → src/lobby/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import P from "pino";
import { DatabaseManager } from "../../database/src/index";
import { DatabaseManager } from "../database/index";
import {
EMessageDirection,
ITCPConnection,
UnprocessedPacket,
} from "../../types/src/index";
import { NPSMessage, NPSUserInfo } from "../../message-types/src/index";
import { PersonaServer } from "../../persona/src/index";
} from "../types/index";
import { NPSMessage, NPSUserInfo } from "../message-types/index";
import { PersonaServer } from "../persona/index";

const log = P().child({ service: "mcoserver:LobbyServer" });
log.level = process.env["LOG_LEVEL"] || "info";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import t from "tap";
import { LobbyServer } from "../src/index";
import { LobbyServer } from "./index";

t.test("LobbyServer", (t) => {
const lobbyServer = LobbyServer.getInstance();
Expand Down
9 changes: 9 additions & 0 deletions src/lobby/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig-noncomposite-base",
"compilerOptions": {
"outDir": "../../built",
"types": ["node"]
},
"files": ["index.ts"],
"references": []
}
Loading

0 comments on commit bc65d62

Please sign in to comment.