This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const PORT = 8000; | |
app.listen(PORT, () => console.log(`Express server started at PORT:${PORT}`)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Subscriber<T> = (val: T) => void; | |
type Unsubscribe = () => void; | |
export class Observable<T> { | |
private _val: T; | |
private _listners: Array<Subscriber<T>>; | |
constructor() { | |
this._listners = []; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const sayHello = () => console.log(`Hello There!`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const cron = require('node-cron') | |
const app = express(); | |
cron.schedule('0 0 1 * *', () => { | |
console.log('running every 1st of the month'); | |
}); | |
app.get('/', (req, res) => { | |
res.json('Welcome to my API'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const cron = require('node-cron') | |
const app = express(); | |
cron.schedule('* * * January,September Sunday', () => { | |
console.log('running on Sundays of January and September'); | |
}); | |
app.get('/', (req, res) => { | |
res.json('Welcome to my API'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
app.get('/', (req, res) => { | |
res.json('Welcome to my API'); | |
}) | |
app.listen(9000, () => console.log(`Server Started at PORT: 9000`)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const form = document.getElementById('chat-form'); | |
const messageBox = document.getElementById('messageBox'); | |
const chatBox = document.getElementById('chat-box') | |
const socket = io('localhost:8080'); | |
socket.on('message', (msg) => { | |
const liTag = document.createElement('li'); | |
liTag.classList.add('list-group-item') | |
liTag.innerText = msg; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Chat App</title> | |
<style> | |
.chat-container{ | |
border: 2px solid; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const socket = require('socket.io'); | |
const server = http.createServer(); | |
const io = socket(server); | |
io.on('connection', socket => { | |
console.log('A new user has joined the chat') | |
socket.emit('message', 'You have successfully joined the chat') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const socket = require('socket.io'); | |
const server = http.createServer(); | |
const io = socket(server); | |
io.on('connection', socket => { | |
console.log('A new user has joined the chat') | |
socket.emit('message', 'You have successfully joined the chat') |