Skip to content

Library to write servers in madlib - based on express

Notifications You must be signed in to change notification settings

madlib-lang/madserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MadServer

Minimal server library for madlib.

Example

import { Header } from "Http"
import { create, post, get, run } from "MadServer"

pipe(
  create,
  post("/", (req) =>
    of({
      body: `post data: ${getBody(req.body)}`,
      headers: [Header("Content-Type", "text/html")],
      status: 402
    })
  ),
  get("/", (req) =>
    of({
      body: "<h1>Hello</h1>",
      headers: [Header("Content-Type", "text/html")],
      status: 200
    })
  ),
  run(3000)
)({ verbose: true })