mali-decorator
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

example

import {Service, Method, Req, buildMiddleware} from 'mali-decorator'
import {Mali} from 'mali'
import {promises, LookupAddress} from 'dns'

@Service()
export class DNSService {
  @Method()
  public async lookup(@Req('hostname') hostname: string): Promise<LookupAddress> {
    return promises.lookup(hostname)
  }

  @Method('Resolve')
  public async resolve(@Req() data: object): Promise<{addresses: string[]}>{
    return {
      addresses: await promises.resolve(data['hostname'])
    }
  }
}

const mali = new Mali('./index.proto')
const middleware = buildMiddleware(new DNSService())
mali.use(middleware)
mali.start(`0.0.0.0:4000`)
syntax='proto3';

message LookupReq {
    string hostname = 1;
}

message LookupRes {
    string address = 1;
    uint32 family = 2;
}

message ResolveReq {
    string hostname = 1;
}

message ResolveRes {
    repeated string addresses = 1;
}

service DNSService {
    rpc lookup(LookupReq) returns (LookupRes)
    rpc Resolve(ResolveReq) returns (ResolveRes)
}

Readme

Keywords

none

Package Sidebar

Install

npm i mali-decorator

Weekly Downloads

32

Version

0.1.0

License

MIT

Unpacked Size

9.29 kB

Total Files

8

Last publish

Collaborators

  • bangbang93