typescript-grpc-server
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

Instalation

npm i --save typescript-grpc-server

Usage

export class Identifier {
  @Property()
  type: IdentifierType
 
  @Property()
  value: string
}
 
export default class User {
  @Property()
  _id: string
 
  @Property({ customType: Identifier })
  identifiers: Identifier[]
}
 
...
import { Call, Property, Service } from 'typescript-grpc-server'
import User from '../models/user.model'
 
class GetUserByIdInput {
  @Property()
  userId: string
}
 
@Service
class UserService {
  @Call({ returnType: [User] })
  async getUsers (data: GetUserByIdInput): Promise<User[]> {
    return
  }
 
  @Call({ returnType: User })
  async getUser (params: GetUserByIdInput): Promise<User> {
    const user = new User()
    user._id = 'Test'
 
    return user
  }
}
 
export default UserService

And then start up server.

import { TypescriptGrpcServer } from 'typescript-grpc-server'
 
grpcServer = new TypescriptGrpcServer({
  servicesPath: '/src/grpc/*.service.ts',
  generatedPath: './generated'
})

/typescript-grpc-server/

    Package Sidebar

    Install

    npm i typescript-grpc-server

    Weekly Downloads

    1

    Version

    0.1.0

    License

    none

    Unpacked Size

    21.5 kB

    Total Files

    7

    Last publish

    Collaborators

    • t.voslar