Schema Definition
export const Customer = Type.Object({
firstName: Type.String(),
lastName: Type.String(),
age: Type.Number(),
dob: Type.Date(),
address: Type.Object({
streetAddress: Type.String(),
city: Type.String(),
export const Customer = Type.Object({
firstName: Type.String(),
lastName: Type.String(),
age: Type.Number(),
dob: Type.Date(),
address: Type.Object({
streetAddress: Type.String(),
city: Type.String(),
import { performance } from 'perf_hooks' | |
export type Timer = ReturnType<typeof createTimer> | |
/** | |
* High resolution timer. Note that Number.MAX_SAFE_INTEGER | |
* limits the total duration to ~104 hours. | |
*/ | |
export const createTimer = () => { | |
const times: number[] = [] |
/* eslint-disable @typescript-eslint/no-misused-promises */ | |
import { Readable, Transform, Writable } from 'node:stream' | |
import { pipeline } from 'node:stream/promises' | |
export const asyncHandler = (handle: (value: any) => Promise<void>) => { | |
return new Writable({ | |
objectMode: true, | |
write: async (value, _, next) => { | |
try { | |
await handle(value) |
These launch configs will allow you to debug typescript files directly from VSCode. It will honor the tsconfig
and resolve node modules properly. You do not need to install ts-node
or nodemon
, as everything is run using npx
. The first
{
"configurations": [
{
"type": "node",
"request": "launch",
{ | |
"root": true, | |
"ignorePatterns": ["**/*"], | |
"plugins": ["@nrwl/nx"], | |
"overrides": [ | |
{ | |
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | |
"rules": { | |
"@nrwl/nx/enforce-module-boundaries": [ | |
"error", |
# kill anything running
docker kill $(docker ps -q)
docker system prune -af --volumes # aka --all --force --volumes
docker exec -it /bin/bash
// Debug the currently-opened file in watch mode | |
// | |
// Sets `cwd` to the directory contianing the file, | |
// which makes it work correctly with monorepos. | |
// | |
// E.g. if the currently opened file is /path/to/some-file.ts, this is equivalent to | |
// running in the shell like: | |
// cd /path/to && npx -y nodemon some-file.ts | |
{ | |
"version": "0.2.0", |
Originally introduced by yarn
, starting with version 7 npm
also provides support for this.
Workspaces are first-class support in the package manager for monorepo structures in npm packages. A monorepo is simply a collection of related packages, and having them share a single git repo can help eliminate a lot of redundancy in the project setup, as well as make it easier to work with interdependencies during development.
They're relatively simple. They consist of:
package.json
contains a list (or wildcard pattern) defining subprojectstype Semaphore = { | |
acquire: () => Promise<void>; | |
release: () => void; | |
}; | |
export const simpleSemaphore = (size: number): Semaphore => { | |
const waiting: (() => void)[] = []; | |
let available = size; | |
const acquire = async (): Promise<void> => { |