/slingshot

A simple promise based module for Deno to handle web requests

Primary LanguageTypeScript

Slingshot, the http server with promises, callbacks or events to suit your needs

Slingshot (WIP)

A module created for Deno by DanCodes

.github/workflows/deno.yml DanCodes Discord GitHub repo size GitHub tag (latest by date)

Usage

Regular

deno run --allow-env --allow-net myFile.ts

Debug

DEBUG=* deno run --allow-env --allow-net myFile.ts

myFile.ts

import { Slingshot, SlingResponse, SlingRequest } from "./mod.ts";

const app = new Slingshot();

app.promises.post("/").then(({ res }) => {
  // promises can only be called once
  return res.code(200).json({ date: new Date() });
});

app.callbacks.get("/callback", (req: SlingRequest, res: SlingResponse) => {
  // callback will be called every time
  res.code(200).json({ date: new Date() });
});

Test

# unit tests
deno test -A

Format code

deno fmt **/*.ts

Resources