Skip to content

Instantly share code, notes, and snippets.

View AlexJWayne's full-sized avatar
🌈

Alex Wayne AlexJWayne

🌈
View GitHub Profile
export * from './types'
import { setHost, setApiKey } from './req'
import * as auth from './api/auth'
import * as blocks from './api/blocks'
import * as costCodes from './api/cost-codes'
import * as equipment from './api/equipment'
import * as reporting from './api/reporting'
import * as sites from './api/sites'
// exported types will be available for you to import from compiled files
// to distinguish between objects ({}) and blocks, blocks have a colon before the opening brace (:{})
export type parseRoute = (route: string) => :{
// assign computations to variables like this
let parts = route.split("/"); // -> ["users", "<id:string>", "posts", "<index:number>"]
// last expression is the return value, like in Rust
parts
// method chaining!
.filter((part) => part.startsWith("<")) // -> ["<id:string>", "<index:number>"]