2023-08-31 19:28:35 +08:00
|
|
|
import dayjs from "dayjs";
|
|
|
|
import "dayjs/locale/zh-tw";
|
2023-09-01 18:02:06 +08:00
|
|
|
import dotenv from "dotenv";
|
2023-08-31 19:28:35 +08:00
|
|
|
import * as path from "path";
|
|
|
|
import { WsServer } from "tsrpc";
|
|
|
|
import { BaseEnumerator } from "./Engine/CatanEngine/CoroutineV2/Core/BaseEnumerator";
|
|
|
|
import "./Engine/CatanEngine/CSharp/String";
|
|
|
|
import "./Engine/Utils/CCExtensions/ArrayExtension";
|
|
|
|
import "./Engine/Utils/CCExtensions/NumberExtension";
|
|
|
|
import { serviceProto } from './shared/protocols/serviceProto';
|
|
|
|
|
|
|
|
BaseEnumerator.Init();
|
|
|
|
dayjs.locale("zh-tw")
|
2023-09-01 18:02:06 +08:00
|
|
|
dotenv.config();
|
2023-08-31 19:28:35 +08:00
|
|
|
|
|
|
|
// Create the Server
|
2023-09-01 18:02:06 +08:00
|
|
|
const port: number = +process.env.PORT || 3000
|
2023-08-31 19:28:35 +08:00
|
|
|
export const server = new WsServer(serviceProto, {
|
2023-09-01 18:02:06 +08:00
|
|
|
port: port,
|
2023-08-31 19:28:35 +08:00
|
|
|
// Remove this to use binary mode (remove from the client too)
|
|
|
|
json: true
|
|
|
|
});
|
|
|
|
|
|
|
|
// Initialize before server start
|
|
|
|
async function init() {
|
|
|
|
await server.autoImplementApi(path.resolve(__dirname, 'api'));
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
// Prepare something... (e.g. connect the db)
|
|
|
|
};
|
|
|
|
|
|
|
|
// Entry function
|
|
|
|
async function main() {
|
|
|
|
await init();
|
|
|
|
await server.start();
|
|
|
|
}
|
|
|
|
main();
|