1.0.1 • Published 2 years ago

@rqft/http v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Kevin

ts server library

heres the example because apparently this world is inhabited by blind idiots

import { Client } from "kevin-http";

// create the client, wont do anything yet
const app = new Client({
  port: 3000
});

// add middleware
app.use((req, res, next) => {
  // you could set content-type manually, but if you don't then res.send() will identify it for you
  res.setHeader("content-type", "plain/text");
  next();
});

// add some endpoints !
app.create("GET /", (req, res) => {
  res.send("hi");
});

app.create("POST /{id}", (req, res) => {
  const id = req.params.get("id");
  if (!id) {
    res.send("no id !!");
  }
  
  res.send(id);
});

// load them in
app.initialize();

// start the server
app.listen((self) => {
  console.log("ok!");
});
1.0.1

2 years ago

1.0.0

2 years ago