Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!
openssl genrsa -des3 -out rootCA.key 4096| { | |
| "compilerOptions": { | |
| "esModuleInterop": true, | |
| "skipLibCheck": true, | |
| "target": "ESNext", | |
| "lib": ["ESNext", "DOM", "ES2024"], | |
| "strict": true, | |
| "noUncheckedIndexedAccess": true, | |
| "noFallthroughCasesInSwitch": true, |
| #!/usr/bin/env node | |
| /** | |
| * This script: | |
| * - Accepts a file or directory path as its first argument. | |
| * - Recursively collects files with code-related extensions. | |
| * - Ignores specified directories and files, and also obeys .gitignore rules | |
| * on a per-branch basis: if a .gitignore file is encountered in a folder, | |
| * its rules apply for that folder and its descendants. | |
| * - Concatenates the contents of all found files into a Markdown-formatted string. |
| export type ILeft<L> = { | |
| tag: 'left'; | |
| value: L; | |
| }; | |
| export type IRight<R> = { | |
| tag: 'right'; | |
| value: R; | |
| }; |
| export type ServiceDefinition = Record<string, (...args: any[]) => Promise<any>> | |
| export interface Client<T extends ServiceDefinition> { | |
| api: T; | |
| handler: (e: MessageEvent) => void; | |
| } | |
| export type Send = (payload: any) => void; | |
| export function Bridge<T extends ServiceDefinition>(serviceDefinition: T) { |
| export type IEventListener<P> = (payload: P) => void; | |
| export class Events<T1 extends Record<string, any>> { | |
| private listeners: Map<string, IEventListener<any>[]> = new Map(); | |
| readonly addListener = <T2 extends keyof T1>( | |
| eventType: T2, | |
| listener: IEventListener<T1[T2]> | |
| ) => { | |
| let arr = this.listeners.get(eventType as string); |
| import {promises as fs} from 'fs'; | |
| import path from 'path'; | |
| const JsonStore = <T>(filename: string, initial: T) => { | |
| const filePath = path.resolve(__dirname, filename); | |
| const api = { | |
| read: async (): Promise<T> => { | |
| if((await fs.stat(filePath)).isFile()) { | |
| return JSON.parse(await fs.readFile(filePath, 'utf8')); |
| import { NextApiRequest, NextApiResponse } from "next"; | |
| import { StatusCodes, getReasonPhrase } from "http-status-codes"; | |
| type NextHandler<R> = (req: NextApiRequest, res: NextApiResponse<R>) => void; | |
| type ResponseEnhanced<R> = { | |
| status?: StatusCodes | number; | |
| headers?: Record<string, string>; | |
| body?: R; | |
| }; |
| import React, { Dispatch, createContext, useMemo, useContext } from "react"; | |
| type ProviderProps<S, A> = React.PropsWithChildren<{ | |
| state: S; | |
| dispatch: Dispatch<A>; | |
| }>; | |
| type MakeStateContextReturn<S, A> = [ | |
| ContextProvider: ({ state, dispatch }: ProviderProps<S, A>) => JSX.Element, | |
| useContext: () => [S, Dispatch<A>] |