Skip to content

Instantly share code, notes, and snippets.

View kenreilly's full-sized avatar
💻
asdf

Ken Reilly kenreilly

💻
asdf
View GitHub Profile
@kenreilly
kenreilly / static-app-router.ts
Last active September 15, 2023 20:30
Static app router class
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 } = {}
@kenreilly
kenreilly / static-app-file.ts
Last active September 15, 2023 20:30
Static app file class
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'
}
@kenreilly
kenreilly / app-server.ts
Last active September 15, 2023 20:14
Application server class
// 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
@kenreilly
kenreilly / app-config.ts
Last active September 15, 2023 20:13
App configuration class
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/',
@kenreilly
kenreilly / main.ts
Last active January 13, 2022 08:59
TypeScript Infinite Scroll main.ts
class App {
static get random_items(): Array<number> {
return Array.from({length: 10}, () => Math.random() * 10 )
}
static content_el: HTMLElement
static init() {
@kenreilly
kenreilly / style.css
Last active January 13, 2022 08:48
TypeScript Infinite Scroll style.css
:root {
--header-height: 8vh;
--item-height: 15vh;
}
body, html {
height: 100vh;
width: 100vw;
overflow: hidden;
margin: 0;
@kenreilly
kenreilly / index.html
Last active January 13, 2022 08:49
TypeScript Infinite Scroll index.html
<!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>
-- SEQUENCE: public.items_id_seq
-- DROP SEQUENCE public.items_id_seq;
CREATE SEQUENCE public.items_id_seq;
ALTER SEQUENCE public.items_id_seq
OWNER TO ts_pg_example_user;
-- Table: public.items
-- DROP TABLE public.items;
import { Net } from './net.js'
export class App {
static name_input: HTMLInputElement
static desc_input: HTMLInputElement
static save_button: HTMLButtonElement
static item_list: HTMLElement
static init() {
import { IsInt, IsString } from 'class-validator';
export class NewItemDto {
@IsString()
readonly name;
@IsString()
readonly description;
}