1.0.6 • Published 2 years ago

nanium-channel-rest v1.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

nanium-channel-rest

A nanium request channel that creates REST-style endpoints for the nanium services

Install

npm install nanium-channel-rest

Usage

import { Nanium } from 'nanium/core';
import { NaniumRestChannel } from 'nanium-channel-rest';

const httpServer = http.createServer((_req, _res) => {});
httpServer.listen(3000);

await Nanium.addManager(new NaniumNodejsProvider({
    servicePath: 'services',
    requestChannels: [
        new NaniumRestChannel({
            apiBasePath: '/api',
            server: httpServer
        })
    ]
}));

This creates an HTTP endpoint for each service based on the service name.

HTTP methods

Which HTTP method is used depends on the name of the contract.ts file;

GET:

  • get.contract.ts
  • query.contract.ts

PUT:

  • update.contract.ts
  • change.contract.ts
  • store.contract.ts
  • put.contract.ts

DELETE:

  • remove.contract.ts
  • delete.contract.ts

POST:

  • create.contract.ts
  • add.contract.ts
  • post.contract.ts
  • everything else

HTTP request deserialization

Properties of HTTP-header will be available in request.head. Properties of HTTP-body and querystring will be available in request.body. The request will have two additional properties:

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