Compare commits

..

10 Commits
v1.4.7 ... main

3473
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
{ {
"name": "nuke", "name": "nuke",
"version": "1.4.7", "version": "1.5.0",
"description": "APL Esports' Nuke Server", "description": "APL Esports' Nuke Server",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -11,17 +11,19 @@
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"axios": "^0.21.1", "axios": "^1",
"bufferutil": "^4.0.8",
"cors": "^2.8.5", "cors": "^2.8.5",
"dotenv": "^8.2.0", "dotenv": "^8",
"express": "^4.17.1", "express": "^4",
"helmet": "^4.1.0", "helmet": "^7",
"mongoose": "^5.11.19", "mongoose": "^8",
"morgan": "^1.10.0", "morgan": "^1.10",
"uuid": "^8.3.2", "utf-8-validate": "^6.0.3",
"ws": "^7.4.4" "uuid": "^9",
"ws": "^8"
}, },
"devDependencies": { "devDependencies": {
"nodemon": "^2.0.4" "nodemon": "^3.0"
} }
} }

@ -6,11 +6,7 @@ const { get } = require('./uuids')
const handler = require('./ws/handler') const handler = require('./ws/handler')
const { subscribe } = require('./ws/streams') const { subscribe } = require('./ws/streams')
mongoose.connect(process.env.MONGO_URI, { mongoose.connect(process.env.MONGO_URI)
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
})
const db = mongoose.connection const db = mongoose.connection
db.once('open', () => console.log('Connected to mongodb instance!')) db.once('open', () => console.log('Connected to mongodb instance!'))
@ -63,4 +59,4 @@ server.on('upgrade', (req, socket, head) => {
}) })
} }
} }
}) })

@ -5,6 +5,12 @@ const brackets = new Schema({
type: String, type: String,
required: true, required: true,
}, },
name_arabic: {
type: String,
},
name_jpn: {
type: String,
},
event: { event: {
type: Schema.Types.ObjectId, type: Schema.Types.ObjectId,
ref: 'Event', ref: 'Event',
@ -17,4 +23,4 @@ const brackets = new Schema({
const Bracket = model('Brackets', brackets) const Bracket = model('Brackets', brackets)
module.exports = Bracket module.exports = Bracket

@ -9,6 +9,12 @@ const casters = new Schema({
type: String, type: String,
required: true, required: true,
}, },
name_arabic: {
type: String,
},
name_jpn: {
type: String,
},
twitter: { twitter: {
type: String, type: String,
required: true, required: true,
@ -20,4 +26,4 @@ const casters = new Schema({
const Caster = model('Casters', casters) const Caster = model('Casters', casters)
module.exports = Caster module.exports = Caster

@ -5,9 +5,19 @@ const events = new mongoose.Schema({
type: String, type: String,
required: true, required: true,
unique: true, unique: true,
} },
name_arabic: {
type: String,
},
name_jpn: {
type: String,
},
streams: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'Streams',
}]
}); });
const Event = mongoose.model('Event', events) const Event = mongoose.model('Event', events)
module.exports = Event module.exports = Event

@ -42,6 +42,12 @@ const matches = new Schema({
type: String, type: String,
required: true, required: true,
}, },
type_arabic: {
type: String,
},
type_jpn: {
type: String,
},
bestOf: { bestOf: {
type: String, type: String,
required: true, required: true,
@ -73,4 +79,4 @@ const matches = new Schema({
const Match = model('Matches', matches) const Match = model('Matches', matches)
module.exports = Match module.exports = Match

@ -28,6 +28,12 @@ const players = new Schema({
type: String, type: String,
required: true, required: true,
}, },
name_arabic: {
type: String,
},
name_jpn: {
type: String,
},
account: { account: {
type: String, type: String,
required: true, required: true,
@ -39,6 +45,12 @@ const rosters = new Schema({
type: String, type: String,
required: true, required: true,
}, },
name_arabic: {
type: String,
},
name_jpn: {
type: String,
},
logo: { logo: {
type: String, type: String,
required: true, required: true,
@ -53,4 +65,4 @@ const rosters = new Schema({
const Roster = model('Rosters', rosters) const Roster = model('Rosters', rosters)
module.exports = Roster module.exports = Roster

@ -0,0 +1,67 @@
const { Schema, model } = require('mongoose')
const stats = new Schema({
name: {
type: String,
required: true,
},
name_arabic: {
type: String,
},
name_jpn: {
type: String,
},
image: {
type: String,
required: true,
},
image_full: {
type: Boolean,
default: false,
required: true,
},
win_name: {
type: String,
required: true,
},
win: {
type: String,
required: true,
},
goals_name: {
type: String,
required: true,
},
goals: {
type: String,
required: true,
},
shots_name: {
type: String,
required: true,
},
shots: {
type: String,
required: true,
},
saves_name: {
type: String,
required: true,
},
saves: {
type: String,
required: true,
},
assists_name: {
type: String,
required: true,
},
assists: {
type: String,
required: true,
},
})
const Stat = model('Stats', stats)
module.exports = Stat

@ -5,6 +5,12 @@ const streams = new Schema({
type: String, type: String,
required: true, required: true,
}, },
name_arabic: {
type: String,
},
name_jpn: {
type: String,
},
event: { event: {
type: Schema.Types.ObjectId, type: Schema.Types.ObjectId,
ref: 'Event', ref: 'Event',
@ -21,8 +27,12 @@ const streams = new Schema({
type: Schema.Types.ObjectId, type: Schema.Types.ObjectId,
ref: 'Casters', ref: 'Casters',
}], }],
stats: [{
type: Schema.Types.ObjectId,
ref: 'Stats'
}],
}) })
const Stream = model('Streams', streams) const Stream = model('Streams', streams)
module.exports = Stream module.exports = Stream

@ -2,6 +2,7 @@ const channels = [
'rosters', 'rosters',
'matches', 'matches',
'streams', 'streams',
'stats',
'events', 'events',
'casters', 'casters',
'hosts', 'hosts',
@ -29,4 +30,4 @@ module.exports = {
channelEvents, channelEvents,
channels, channels,
events, events,
}; };

@ -1,6 +1,7 @@
const events = require('../models/events') const events = require('../models/events')
const rosters = require('../models/rosters') const rosters = require('../models/rosters')
const matches = require('../models/matches') const matches = require('../models/matches')
const stats = require('../models/stats')
const streams = require('../models/streams') const streams = require('../models/streams')
const casters = require('../models/casters') const casters = require('../models/casters')
const hosts = require('../models/hosts') const hosts = require('../models/hosts')
@ -22,10 +23,7 @@ const eventFns = {
create: async (data) => { create: async (data) => {
try { try {
const ev = new events(data) const ev = new events(data)
ev.save((err) => { await ev.save();
if (err)
console.warn(err)
})
} catch (e) { } catch (e) {
console.warn(e) console.warn(e)
} }
@ -48,10 +46,7 @@ const rosterFns = {
create: async (data) => { create: async (data) => {
try { try {
const ev = new rosters(data) const ev = new rosters(data)
ev.save((err) => { await ev.save();
if (err)
console.warn(err)
})
} catch (e) { } catch (e) {
console.warn(e) console.warn(e)
} }
@ -74,10 +69,30 @@ const matchFns = {
create: async (data) => { create: async (data) => {
try { try {
const ev = new matches(data) const ev = new matches(data)
ev.save((err) => { await ev.save();
if (err) } catch (e) {
console.warn(err) console.warn(e)
}) }
}
}
const statsFns = {
getAll: async () => {
return await stats.find().exec()
},
getById: async (id) => {
return await stats.findById(id).exec()
},
update: async(id, data) => {
return await stats.findByIdAndUpdate(id, data).exec()
},
delete: async (id) => {
return await stats.findByIdAndDelete(id).exec()
},
create: async (data) => {
try {
const ev = new stats(data)
await ev.save();
} catch (e) { } catch (e) {
console.warn(e) console.warn(e)
} }
@ -92,13 +107,13 @@ const streamFns = {
return await streams.find().populate('event').populate({ return await streams.find().populate('event').populate({
path: 'matches', path: 'matches',
populate: [{ path: 'orange' }, { path: 'blue' }], populate: [{ path: 'orange' }, { path: 'blue' }],
}).populate('casters').populate('hosts').lean().exec() }).populate('casters').populate('hosts').populate('stats').lean().exec()
}, },
getById: async (id) => { getById: async (id) => {
return await streams.findById(id).populate('event').populate({ return await streams.findById(id).populate('event').populate({
path: 'matches', path: 'matches',
populate: [{ path: 'orange' }, { path: 'blue' }], populate: [{ path: 'orange' }, { path: 'blue' }],
}).populate('casters').populate('hosts').lean().exec() }).populate('casters').populate('hosts').populate('stats').lean().exec()
}, },
update: async(id, data) => { update: async(id, data) => {
return await streams.findByIdAndUpdate(id, data).exec() return await streams.findByIdAndUpdate(id, data).exec()
@ -109,10 +124,7 @@ const streamFns = {
create: async (data) => { create: async (data) => {
try { try {
const ev = new streams(data) const ev = new streams(data)
ev.save((err) => { await ev.save();
if (err)
console.warn(err)
})
} catch (e) { } catch (e) {
console.warn(e) console.warn(e)
} }
@ -135,10 +147,7 @@ const casterFns = {
create: async (data) => { create: async (data) => {
try { try {
const ev = new casters(data) const ev = new casters(data)
ev.save((err) => { await ev.save();
if (err)
console.warn(err)
})
} catch (e) { } catch (e) {
console.warn(e) console.warn(e)
} }
@ -161,10 +170,7 @@ const hostFns = {
create: async (data) => { create: async (data) => {
try { try {
const ev = new hosts(data) const ev = new hosts(data)
ev.save((err) => { await ev.save();
if (err)
console.warn(err)
})
} catch (e) { } catch (e) {
console.warn(e) console.warn(e)
} }
@ -196,10 +202,7 @@ const bracketFns = {
create: async (data) => { create: async (data) => {
try { try {
const ev = new brackets(data) const ev = new brackets(data)
ev.save((err) => { await ev.save();
if (err)
console.warn(err)
})
} catch (e) { } catch (e) {
console.warn(e) console.warn(e)
} }
@ -210,8 +213,9 @@ module.exports = {
'events': eventFns, 'events': eventFns,
'rosters': rosterFns, 'rosters': rosterFns,
'matches': matchFns, 'matches': matchFns,
'stats': statsFns,
'streams': streamFns, 'streams': streamFns,
'casters': casterFns, 'casters': casterFns,
'hosts': hostFns, 'hosts': hostFns,
'brackets': bracketFns, 'brackets': bracketFns,
} }

Loading…
Cancel
Save