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