Skip to content

Commit

Permalink
feat(): [App] Initialized the app
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurArakelyan committed Oct 17, 2023
0 parents commit dc95b53
Show file tree
Hide file tree
Showing 28 changed files with 11,231 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.js]
ij_javascript_force_quote_style = true
ij_javascript_use_double_quotes = false
ij_javascript_spaces_within_imports = true

[*.ts]
ij_typescript_force_quote_style = true
ij_typescript_use_double_quotes = false
ij_typescript_spaces_within_imports = true

[*.tsx]
ij_typescript_force_quote_style = true
ij_typescript_use_double_quotes = false
ij_typescript_spaces_within_imports = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
23 changes: 23 additions & 0 deletions chat-server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
37 changes: 37 additions & 0 deletions chat-server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import express from 'express';
import cors from 'cors';
import bodyParser from 'body-parser';
import http from 'http';
import { Server } from 'socket.io';

const app = express();

app.use(cors());

app.use(bodyParser.json());

const server = http.createServer(app);

const io = new Server(server, {
cors: {
origin: '*',
},
});

app.get('/', (req, res) => {
res.send('<h1>Chat Server</h1>');
});

io.on('connection', (socket) => {
socket.on('chat', (message) => {
socket.broadcast.emit('chat', message);
});

socket.on('disconnect', () => {
socket.removeAllListeners();
});
});

server.listen(5000, () => {
console.log('listening on *:5000');
});
22 changes: 22 additions & 0 deletions chat-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "chat-server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"express": "^4.18.2",
"socket.io": "^4.7.2"
},
"devDependencies": {
"nodemon": "^3.0.1"
}
}
Loading

0 comments on commit dc95b53

Please sign in to comment.