1.0.12 • Published 2 years ago

simple-http-hook v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
2 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

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago