Full Code of dkhd/node-group-chat for AI

master acf68199ff18 cached
4 files
3.5 KB
1.0k tokens
1 requests
Download .txt
Repository: dkhd/node-group-chat
Branch: master
Commit: acf68199ff18
Files: 4
Total size: 3.5 KB

Directory structure:
gitextract_66nfv3wi/

├── README.md
├── index.js
├── package.json
└── views/
    └── index.ejs

================================================
FILE CONTENTS
================================================

================================================
FILE: README.md
================================================
# Build A Group-Chat App in 30 Lines Using Node.js

A simple and (hopefully) to-the-point tutorial to build your first group-chat application using Node.js in less than 30 lines of code.

## Running the program

Run the program by using

```shell
$ node index.js
```


================================================
FILE: index.js
================================================
const express = require('express');
const app = express();
const http = require('http').Server(app);
const io = require('socket.io')(http);

app.get('/', function(req, res) {
    res.render('index.ejs');
});

io.sockets.on('connection', function(socket) {
    socket.on('username', function(username) {
        socket.username = username;
        io.emit('is_online', '🔵 <i>' + socket.username + ' join the chat..</i>');
    });

    socket.on('disconnect', function(username) {
        io.emit('is_online', '🔴 <i>' + socket.username + ' left the chat..</i>');
    })

    socket.on('chat_message', function(message) {
        io.emit('chat_message', '<strong>' + socket.username + '</strong>: ' + message);
    });

});

const server = http.listen(8080, function() {
    console.log('listening on *:8080');
});

================================================
FILE: package.json
================================================
{
  "name": "node-simple-group-chat",
  "version": "1.0.0",
  "description": "A simple group chat built using Node.js and Socket.io",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Diky Hadna",
  "license": "ISC",
  "dependencies": {
    "ejs": "^2.6.1",
    "express": "^4.16.4",
    "socket.io": "^2.2.0"
  }
}


================================================
FILE: views/index.ejs
================================================
<!DOCTYPE html>
<html>
  <head>
    <title>Simple Group Chat on Node.js</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font: 13px Helvetica, Arial; }
        form { background: #fff; padding: 3px; position: fixed; bottom: 0; width: 100%; border-color: #000; border-top-style: solid; border-top-width: 1px;}
        form input { border-style: solid; border-width: 1px; padding: 10px; width: 85%; margin-right: .5%; }
        form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; margin-left: 2%; }
        #messages { list-style-type: none; margin: 0; padding: 0; }
        #messages li { padding: 5px 10px; }
        #messages li:nth-child(odd) { background: #eee; }
    </style>
    <script src="../../socket.io/socket.io.js"></script>
    <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
  </head>
  <body>
    <ul id="messages"></ul>
    <form action="/" method="POST" id="chatForm">
      <input id="txt" autocomplete="off" autofocus="on" oninput="isTyping()" placeholder="type your message here..." /><button>Send</button>
    </form>
    <script>
            var socket = io.connect('http://localhost:8080');

            // submit text message without reload/refresh the page
            $('form').submit(function(e){
                e.preventDefault(); // prevents page reloading
                socket.emit('chat_message', $('#txt').val());
                $('#txt').val('');
                return false;
            });

            // append the chat text message
            socket.on('chat_message', function(msg){
                $('#messages').append($('<li>').html(msg));
            });

            // append text if someone is online
            socket.on('is_online', function(username) {
                $('#messages').append($('<li>').html(username));
            });

            // ask username
            var username = prompt('Please tell me your name');
            socket.emit('username', username);

    </script>
  </body>
</html>
Download .txt
gitextract_66nfv3wi/

├── README.md
├── index.js
├── package.json
└── views/
    └── index.ejs
Condensed preview — 4 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (4K chars).
[
  {
    "path": "README.md",
    "chars": 267,
    "preview": "# Build A Group-Chat App in 30 Lines Using Node.js\n\nA simple and (hopefully) to-the-point tutorial to build your first g"
  },
  {
    "path": "index.js",
    "chars": 838,
    "preview": "const express = require('express');\r\nconst app = express();\r\nconst http = require('http').Server(app);\r\nconst io = requi"
  },
  {
    "path": "package.json",
    "chars": 379,
    "preview": "{\n  \"name\": \"node-simple-group-chat\",\n  \"version\": \"1.0.0\",\n  \"description\": \"A simple group chat built using Node.js an"
  },
  {
    "path": "views/index.ejs",
    "chars": 2111,
    "preview": "<!DOCTYPE html>\r\n<html>\r\n  <head>\r\n    <title>Simple Group Chat on Node.js</title>\r\n    <style>\r\n        * { margin: 0; "
  }
]

About this extraction

This page contains the full source code of the dkhd/node-group-chat GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 4 files (3.5 KB), approximately 1.0k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!