Merged private changes
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
.git*
|
||||||
|
|
||||||
|
tools*
|
||||||
|
mysql*
|
||||||
|
letsencrypt*
|
||||||
|
test*
|
||||||
|
|
||||||
|
.env*
|
||||||
|
.github*
|
||||||
|
LICENSE*
|
||||||
+1
-1
@@ -2,8 +2,8 @@
|
|||||||
FROM node:15
|
FROM node:15
|
||||||
WORKDIR "/app"
|
WORKDIR "/app"
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm install --production
|
|
||||||
COPY . /app
|
COPY . /app
|
||||||
|
RUN npm install --production
|
||||||
EXPOSE 3300
|
EXPOSE 3300
|
||||||
USER node
|
USER node
|
||||||
ENTRYPOINT ["bash", "-c"]
|
ENTRYPOINT ["bash", "-c"]
|
||||||
|
|||||||
Generated
-4085
File diff suppressed because it is too large
Load Diff
+6
-7
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "chat-server",
|
"name": "chat-server",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "An API centric chat server. Uses Sequelize and mariaDB by default.",
|
"description": "An API centric chat server. Uses Sequelize and mariaDB by default.",
|
||||||
"main": "server/server.js",
|
"main": "server/server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -19,16 +19,15 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/krgamestudios/chat-server#readme",
|
"homepage": "https://github.com/krgamestudios/chat-server#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "^1.19.0",
|
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.6.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"mariadb": "^2.5.2",
|
"mariadb": "^2.5.4",
|
||||||
"sequelize": "^6.5.0",
|
"sequelize": "^6.6.5",
|
||||||
"socket.io": "^4.0.0"
|
"socket.io": "^4.1.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"nodemon": "^2.0.7"
|
"nodemon": "^2.0.12"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const { chatlog, reports } = require('../database/models');
|
|||||||
const route = async (req, res) => {
|
const route = async (req, res) => {
|
||||||
const reps = await reports.destroy({
|
const reps = await reports.destroy({
|
||||||
where: {
|
where: {
|
||||||
chatlogId: req.body.chatlogId
|
chatlogIndex: req.body.chatlogIndex
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ const route = async (req, res) => {
|
|||||||
model: chatlog,
|
model: chatlog,
|
||||||
required: true
|
required: true
|
||||||
}],
|
}],
|
||||||
order: ['chatlogId']
|
order: ['chatlogIndex']
|
||||||
});
|
});
|
||||||
|
|
||||||
//collate
|
//collate
|
||||||
const response = [];
|
const response = [];
|
||||||
for(let i = 0; i < reps.length; i++) {
|
for(let i = 0; i < reps.length; i++) {
|
||||||
//new chatlog
|
//new chatlog
|
||||||
if (response.length == 0 || response[response.length - 1].chatlogId != reps[i].chatlogId) {
|
if (response.length == 0 || response[response.length - 1].chatlogIndex != reps[i].chatlogIndex) {
|
||||||
response.push(reps[i]);
|
response.push(reps[i]);
|
||||||
response[response.length - 1].reporter = [response[response.length - 1].reporter]; //reporters in an array
|
response[response.length - 1].reporter = [response[response.length - 1].reporter]; //reporters in an array
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ const chat = io => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
order: [
|
order: [
|
||||||
['id', 'DESC']
|
['index', 'DESC']
|
||||||
],
|
],
|
||||||
limit: 50
|
limit: 50
|
||||||
})
|
})
|
||||||
@@ -140,14 +140,14 @@ const chat = io => {
|
|||||||
|
|
||||||
socket.on('report', info => {
|
socket.on('report', info => {
|
||||||
//handle reports of malicious content
|
//handle reports of malicious content
|
||||||
if (!info.id) {
|
if (!info.index) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//report
|
//report
|
||||||
reports.create({
|
reports.create({
|
||||||
reporter: socket.user.username,
|
reporter: socket.user.username,
|
||||||
chatlogId: info.id
|
chatlogIndex: info.index
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const Sequelize = require('sequelize');
|
|||||||
const sequelize = require('..');
|
const sequelize = require('..');
|
||||||
|
|
||||||
module.exports = sequelize.define('chatlog', {
|
module.exports = sequelize.define('chatlog', {
|
||||||
id: {
|
index: {
|
||||||
type: Sequelize.INTEGER(11),
|
type: Sequelize.INTEGER(11),
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
autoIncrement: true,
|
autoIncrement: true,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const sequelize = require('..');
|
|||||||
const chatlog = require('./chatlog');
|
const chatlog = require('./chatlog');
|
||||||
|
|
||||||
const reports = sequelize.define('reports', {
|
const reports = sequelize.define('reports', {
|
||||||
id: {
|
index: {
|
||||||
type: Sequelize.INTEGER(11),
|
type: Sequelize.INTEGER(11),
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
autoIncrement: true,
|
autoIncrement: true,
|
||||||
@@ -18,7 +18,9 @@ const reports = sequelize.define('reports', {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
chatlog.hasMany(reports, { foreignKey: 'chatlogId', foreignKeyConstraint: true });
|
chatlog.hasMany(reports, { foreignKey: 'chatlogIndex', foreignKeyConstraint: true });
|
||||||
reports.belongsTo(chatlog, { foreignKey: 'chatlogId' });
|
reports.belongsTo(chatlog, { foreignKey: 'chatlogIndex' });
|
||||||
|
|
||||||
|
sequelize.sync();
|
||||||
|
|
||||||
module.exports = reports;
|
module.exports = reports;
|
||||||
+1
-2
@@ -10,11 +10,10 @@ const io = require('socket.io')(server, {
|
|||||||
origin: '*'
|
origin: '*'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const bodyParser = require('body-parser');
|
|
||||||
const cors = require('cors');
|
const cors = require('cors');
|
||||||
|
|
||||||
//config
|
//config
|
||||||
app.use(bodyParser.json());
|
app.use(express.json());
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
|
|
||||||
//database connection
|
//database connection
|
||||||
|
|||||||
Reference in New Issue
Block a user