Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e0d6260d1a | |||
| 53ea726c89 | |||
| c44ed79e6d | |||
| 518f5dbee7 | |||
| be57dbe51c | |||
| 8309c3b832 | |||
| 95d229c561 | |||
| 0b1456ebde | |||
| bd5b6e8233 | |||
| 05eecf8bdd | |||
| 2aedb6e938 | |||
| ab73d05471 | |||
| f72b0e5522 | |||
| 900312752b | |||
| 1b2868d68f | |||
| 33157d48d3 |
@@ -0,0 +1,5 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
patreon: krgamestudios
|
||||
ko_fi: krgamestudios
|
||||
custom: ["https://www.paypal.com/donate/?hosted_button_id=73Q82T2ZHV8AA"]
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
An API centric chat server. Uses Sequelize and mariaDB by default.
|
||||
|
||||
This server is available via docker hub at krgamestudios/chat-server.
|
||||
|
||||
# Setup
|
||||
|
||||
There are multiple ways to run this app - it can run on it's own via `npm start` (for production) or `npm run dev` (for development). it can also run inside docker using `docker-compose up --build` - run `node configure-script.js` to generate docker-compose.yml and startup.sql.
|
||||
@@ -13,7 +15,7 @@ POST https://dev-auth.krgamestudios.com/auth/login HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"email": "kayneruse@gmail.com",
|
||||
"email": "example@example.com",
|
||||
"password": "helloworld"
|
||||
}
|
||||
```
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ const question = (prompt, def = null) => {
|
||||
const appPort = await question('App Port', '3300');
|
||||
|
||||
const appDBUser = await question('DB User', appName);
|
||||
const appDBPass = await question('DB Pass', uuid());
|
||||
const appDBPass = await question('DB Pass', 'blastoise');
|
||||
const dbRootPass = await question('DB Root Pass');
|
||||
|
||||
const appSecretAccess = await question('Access Token Secret', uuid(32));
|
||||
|
||||
Generated
+769
-2083
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "chat-server",
|
||||
"version": "1.2.3",
|
||||
"version": "1.2.8",
|
||||
"description": "An API centric chat server. Uses Sequelize and mariaDB by default.",
|
||||
"main": "server/server.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -35,7 +35,7 @@ const chat = io => {
|
||||
});
|
||||
|
||||
//from here, handles all normal messages
|
||||
socket.on('open chat', message => {
|
||||
socket.on('open chat', async message => {
|
||||
//handle rooms - only in a room if you've opened chat
|
||||
const newlyOpened = !socket.user.room;
|
||||
socket.user.room = socket.user.room || 'general'; //default to general
|
||||
@@ -46,11 +46,8 @@ const chat = io => {
|
||||
|
||||
socket.join(socket.user.room);
|
||||
|
||||
//broadcast to this room
|
||||
socket.broadcast.to(socket.user.room).emit('message', { emphasis: true, text: `${socket.user.username} entered chat` });
|
||||
|
||||
//log
|
||||
chatlog.create({
|
||||
const log = await chatlog.create({
|
||||
notification: true,
|
||||
username: socket.user.username,
|
||||
text: `${socket.user.username} entered chat`,
|
||||
@@ -58,6 +55,9 @@ const chat = io => {
|
||||
emphasis: true
|
||||
});
|
||||
|
||||
//broadcast to this room
|
||||
socket.broadcast.to(socket.user.room).emit('message', {timestamp: log.createdAt, emphasis: true, text: `${socket.user.username} entered chat` });
|
||||
|
||||
//send backlog to the user
|
||||
chatlog.findAll({
|
||||
where: {
|
||||
@@ -120,7 +120,7 @@ const chat = io => {
|
||||
socket.broadcast.to(socket.user.room).emit('message', log);
|
||||
});
|
||||
|
||||
socket.on('disconnect', reason => {
|
||||
socket.on('disconnect', async reason => {
|
||||
//broadcast to this room
|
||||
if (!socket.user) {
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
const chatlog = require('./chatlog');
|
||||
const mute = require('./mute');
|
||||
const reports = require('./reports');
|
||||
|
||||
//relationships
|
||||
reports.belongsTo(chatlog);
|
||||
|
||||
module.exports = {
|
||||
chatlog: require('./chatlog'),
|
||||
mute: require('./mute'),
|
||||
reports: require('./reports')
|
||||
};
|
||||
chatlog,
|
||||
mute,
|
||||
reports,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#use this while debugging
|
||||
CREATE DATABASE IF NOT EXISTS chat;
|
||||
CREATE USER IF NOT EXISTS 'chat'@'%' IDENTIFIED BY 'blastoise';
|
||||
GRANT ALL PRIVILEGES ON chat.* TO 'chat'@'%';
|
||||
Reference in New Issue
Block a user