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
| import { WebSocketMessage, WebSocketMessageType } from "../../common/ws-message.js" | |
| export class WebSocketAPI { | |
| private static command_table: {[name:string]: Function} = { | |
| 'ping': WebSocketAPI.ping, | |
| 'echo': WebSocketAPI.echo | |
| } | |
| public static handle(message: WebSocketMessage): Promise<WebSocketMessage> { |
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 enum WebSocketOpcode { | |
| CONTINUE = 0x0, | |
| TEXT = 0x1, | |
| BINARY = 0x2, | |
| CLOSE = 0x8 | |
| } | |
| export abstract class WebSocketFrame { |
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
| import * as crypto from 'node:crypto' | |
| import { IncomingMessage } from 'node:http' | |
| import { Duplex } from "node:stream"; | |
| import { AppConfig } from '../app-config.js' | |
| import { WebSocketOpcode, WebSocketFrame } from './ws-frame.js'; | |
| import { WebSocketMessage } from '../../common/ws-message.js'; | |
| import { WebSocketAPI } from './ws-api.js'; | |
| export class WebSocketRouter { |
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
| import * as path from 'node:path' | |
| import * as fs from 'node:fs' | |
| import { Dirent } from 'node:fs' | |
| import { IncomingMessage, ServerResponse } from 'node:http' | |
| import { StaticAppFile } from "./static-app-file.js" | |
| import { AppConfig } from '../app-config.js' | |
| export class StaticAppRouter { | |
| private content: { [url: string]: StaticAppFile } = {} |
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
| import * as fs from 'node:fs' | |
| export enum ContentType { | |
| html = 'text/html', | |
| css = 'text/css', | |
| js = 'application/javascript', | |
| ts = 'application/typescript', | |
| map = 'application/octet-stream' | |
| } |
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
| // import * as http from 'node:https' | |
| import * as http from 'node:http' | |
| import { IncomingMessage, ServerResponse } from 'node:http' | |
| import { StaticAppRouter } from './static-app/static-app-router.js' | |
| import { WebSocketRouter } from './websocket/ws-router.js' | |
| import { AppConfig } from './app-config.js' | |
| class AppServer { | |
| private config: AppConfig |
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
| import * as path from 'node:path' | |
| import * as fs from 'node:fs' | |
| export class AppConfig { | |
| public static readonly ws_rfc_guid: string = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11' | |
| public readonly server_root: string = process.cwd() | |
| public readonly app_dirs: Array<string> = [ | |
| 'css/', |
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
| class App { | |
| static get random_items(): Array<number> { | |
| return Array.from({length: 10}, () => Math.random() * 10 ) | |
| } | |
| static content_el: HTMLElement | |
| static init() { |
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
| :root { | |
| --header-height: 8vh; | |
| --item-height: 15vh; | |
| } | |
| body, html { | |
| height: 100vh; | |
| width: 100vw; | |
| overflow: hidden; | |
| margin: 0; |
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> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <title>TypeScript Infinite Scroll</title> | |
| <meta name="description" content=""> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <link rel="stylesheet" href="css/style.css"> | |
| </head> |