1.0.12 • Published 4 years ago

simple-http-hook v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Simepl Http Hook

Description

Provide a simple tool to create and trigge the http hook.

trigging the hook in browser based on axios, and the server based on koa.

Install

npm install simple-http-hook
# or
yarn add simple-http-hook

Example

server

import { serverHooks } from "simple-http-hook";
const server = serverHooks.createHookServer();
server.registerHook("/message", ["GET", "post"], async (ctx) => {
  const body = (ctx.request as any).body;
  console.log(body);
  ctx.response.body = body;
});
server.listen(8888).then(() => {
  console.log("server started at 8888");
});

browser

import { browserHooks } from "simple-http-hook";
export const trigger = browserHooks.createHookTrigger({
  baseURL: "http://localhost:8888",
});

export const postMessageTrigge = () =>
  trigger.triggePost("/message", {
      foo: 'bar
  });

Features

  • support typescript
  • backend cors and bodyparser
  • authorization control
  • decorator
1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago