1
0
mirror of synced 2024-09-23 18:58:22 +02:00

Merge pull request #84 from leezhiwei/master

Re-Adding commit of letting Bayshore run on newer node.js
This commit is contained in:
Sylvie Nightshade 2024-09-15 01:02:09 +01:00 committed by GitHub
commit 16d499be58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 32 additions and 28 deletions

View File

@ -1,7 +1,7 @@
POSTGRES_URL=postgresql://user:password@your-host:5432/database
ALLNET_PORT=20080
ALLNET_PORT=80
MUCHA_PORT=10082
SERVICE_PORT=9002
API_PORT=9003
OPENTELEMETRY_ENABLED=false
OPENTELEMETRY_OTLP_URI=disregard-this
OPENTELEMETRY_OTLP_URI=disregard-this

3
.gitignore vendored
View File

@ -9,4 +9,5 @@ key.pem
config.json
ecosystem.config.js
static/*
screenshot/*
screenshot/*
yarn.lock

View File

@ -15,6 +15,7 @@
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/long": "4.0.0",
"@types/node": "^18.0.3",
"prisma": "^4.13.0",
"protobufjs-cli": "^1.0.0",
@ -23,11 +24,11 @@
},
"dependencies": {
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/auto-instrumentations-node": "^0.35.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "^0.34.0",
"@opentelemetry/exporter-trace-otlp-grpc": "^0.34.0",
"@opentelemetry/auto-instrumentations-node": "^0.50.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "^0.53.0",
"@opentelemetry/exporter-trace-otlp-grpc": "^0.53.0",
"@opentelemetry/sdk-metrics": "^1.8.0",
"@opentelemetry/sdk-node": "^0.34.0",
"@opentelemetry/sdk-node": "^0.53.0",
"@opentelemetry/semantic-conventions": "^1.8.0",
"@prisma/client": "^4.13.0",
"@sentry/node": "^7.7.0",

View File

@ -118,10 +118,10 @@ let dirs = fs.readdirSync(path.join(path.dirname(__filename), 'modules'));
for (let i of dirs)
{
// If the file is a .js file
if (i.endsWith('.js'))
if (i.endsWith('.js') || i.endsWith('.ts')) // if running directly from ts files
{
// Require the module file
let mod = require(`./modules/${i.substring(0, i.length - 3)}`); // .js extension
let mod = require(`./modules/${i.substring(0, i.length - 3)}`);
// Create an instance of the module
let inst = new mod.default();
@ -135,7 +135,7 @@ for (let i of dirs)
app.use('/', appRouter);
app.use('/wmmt6/', appRouter);
app.all('*', (req, res) => {
app.all('*', (req, res) => {
common.writeLog(`[ MAIN] ${req.method} ${req.url} is unhandled`);
res.status(200).end();
})
@ -181,4 +181,4 @@ https.createServer({key, cert}, muchaApp).listen(PORT_MUCHA, '0.0.0.0', 511, ()
// Create the game server
https.createServer({key, cert}, app).listen(PORT_BNGI, '0.0.0.0', 511, () => {
console.log(`Game server listening on port ${PORT_BNGI}!`);
})
})

View File

@ -12,7 +12,7 @@ import * as carFunctions from "./cars/functions";
import * as terminal from "./terminal/check_car";
export default class CarModule extends Module {
export default class CarModule {
register(app: Application): void {
// Load Car

View File

@ -16,7 +16,7 @@ import * as ghost from "./game/ghost";
import * as versus from "./game/versus";
export default class GameModule extends Module {
export default class GameModule {
register(app: Application): void {
// Saving the game result on mileage screen

View File

@ -42,10 +42,10 @@ export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, c
}
// If the lose bits are set, and are long data
if (Long.isLong(storyResult.stLoseBits))
if (Long.isLong(storyResult.stLoseBits) && storyResult && storyResult.stLoseBits)
{
// Convert them to BigInt and add to the data
data.stLoseBits = common.getBigIntFromLong(storyResult.stLoseBits);
data.stLoseBits = common.getBigIntFromLong(storyResult.stLoseBits as Long);
stLoseBits = data.stLoseBits
// If a loss has been recorded

View File

@ -16,7 +16,7 @@ import * as ghost_trail from "./ghost/ghost_util/ghost_trail";
import * as ghost_area from "./ghost/ghost_util/ghost_area";
export default class GhostModule extends Module {
export default class GhostModule {
register(app: Application): void {
// Load Ghost Battle Info
@ -307,10 +307,10 @@ export default class GhostModule extends Module {
let actualSessionId: number = 0;
// If the session are set, and are long data
if(Long.isLong(body.ghostSessionId))
if(Long.isLong(body.ghostSessionId) && body && body.ghostSessionId)
{
// Convert them to BigInt and add to the data
actualSessionId = common.getBigIntFromLong(body.ghostSessionId);
actualSessionId = common.getBigIntFromLong(body.ghostSessionId as Long);
}
// -----------------------------------------------------------------------------------------

View File

@ -12,7 +12,7 @@ import * as ghost_ocm from "./ghost/ghost_ocm";
import * as ghost_ocm_area from "./ghost/ghost_util/ghost_ocm_area";
export default class GhostModule extends Module {
export default class GhostModule {
register(app: Application): void {
// Get OCM Battle event info

View File

@ -14,7 +14,7 @@ import * as crown_list from "./resource/crown_list";
import * as ranking from "./resource/ranking";
export default class ResourceModule extends Module {
export default class ResourceModule {
register(app: Application): void {
// Place List
@ -74,7 +74,6 @@ export default class ResourceModule extends Module {
// Encode the response
let message = wm.wm.protobuf.PlaceList.encode({places});
// Send the response to the client
common.sendResponse(message, res, req.rawHeaders);
})

View File

@ -9,7 +9,7 @@ import * as common from "./util/common";
import * as startupFunctions from "./startup/functions";
export default class StartupModule extends Module {
export default class StartupModule {
register(app: Application): void {
// Register system info upon booting

View File

@ -12,7 +12,7 @@ import * as scratch from "./terminal/scratch";
import * as common from "./util/common";
export default class TerminalModule extends Module {
export default class TerminalModule {
register(app: Application): void {
// Load upon enter terminal

View File

@ -9,7 +9,7 @@ import * as wm from "../wmmt/wm.proto";
import * as common from "./util/common";
export default class TimeAttackModule extends Module {
export default class TimeAttackModule {
register(app: Application): void {
// Load time Attack Record

View File

@ -11,7 +11,7 @@ import * as scratch from "./terminal/scratch";
import * as common from "./util/common";
export default class UserModule extends Module {
export default class UserModule {
register(app: Application): void {
// Load user data when entering the game or after tapping the bannapass card

View File

@ -88,7 +88,7 @@ export function sendResponse(message: Writer, res: Response, headers: string[])
// Send the response to the client
r.send(Buffer.from(end));
}
}
catch (e) // Failed to send response
{
writeLog(`Failed to send response: ${String(e)}`);
@ -156,4 +156,4 @@ export async function writeLog(message: string) {
catch {
// Failed
}
}
}

View File

@ -5,7 +5,10 @@
"strict": true,
"lib": ["esnext"],
"esModuleInterop": true,
"allowJs": true
"allowJs": true,
"types":[
"long"
]
},
"include": ["src/**/*"],
"exclude": ["src/wmmt/**/*"]