Skip to main content

Posts

Showing posts from September 12, 2021

Creating Chat Applications using NodeJS, Socket.io & Mysql Part 3

Result.ejs  script. This script is to set the display when searching for friends.  <% if(items != 0) {%> <table class="table table-borderless mt-3" style="width: 100%;border-radius:5px;"> <thead class=""> <tr style="border-bottom:1px solid #e3e3e3"> <th style="width:7%;text-align:center" hidden>No</th> <th style="display:none;">Username</th> <th style="width:68%">Name</th> <th style="width:10%"> </th> </tr> </thead> <tbody> <% items.forEach((item, i) => { %> <tr row-id="<%= item.id_user %>" style="border-bottom:1px solid #cdcdcd;"> <td style="text-align:center;vertical-align:middle" hidden><%= Number(i)+1 %></td> <td style="vertical-align:middle;display:non

Creating Chat Applications using NodeJS, Socket.io & Mysql Part 4

Server.js  script. Server.js is the brain of this application. In this file I manage all routing urls, run queries to be able to access, store, update data from database, manage login/registration system and manage private real time chat system. let express = require('express'); let session = require('express-session'); let expressFileupload = require('express-fileupload'); let sharp = require('sharp'); let app = express(); let server = require('http').createServer(app); let io = require('socket.io').listen(server); let flash = require('connect-flash'); const mysql = require('mysql'); const path = require('path'); const jquery = require('jquery'); const fs = require('fs'); const htmlspecialchars = require('htmlspecialchars'); const htmlspecialchars_decode = require('htmlspecialchars_decode'); // prepare server // app.use('/api', api); // redirect API calls app.use('/cu

Ad by Adsterra