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
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>] |
#!/usr/bin/env node | |
const readline = require('readline') | |
const colors = require('colors/safe') | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
terminal: false | |
}) |
type ofCst; | |
type unknownCstElement; | |
type cstChildrenDict = Js.Dict.t(list(unknownCstElement)); | |
type cstNode = { | |
name: string, | |
children: cstChildrenDict, | |
}; | |
type token; |