0.0.0 • Published 9 months ago

@lumineer/source v0.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Lumineer

Getting started


Install the packages

Install the package using your favorite package manager:

npm install --save @lumineer/core

Minimal setup

Create the service definition:

@Message()
class CreateUser {
  @PropertyType('string')
  username: string;

  @PropertyType('string')
  email: string;

  @PropertyType('string')
  passoword: string;
}

@Message()
class User {
  @PropertyType('string')
  id: string;

  @PropertyType('string')
  username: string;

  @PropertyType('string')
  email: string;

  @PropertyType('DateTime')
  createdAt: Date;

  @PropertyType('DateTime')
  updatedAt: Date;
}

@Service()
class UserService {
  @RPC()
  @ArgumentType(CreateUser)
  @ReturnType(User)
  private async CreateUser(@BodyParam() requestBody: CreateUser): Promise<User> {
    const user = await this.repository.createUser(requestBody);
    return user;
  }
}

And then start the server:

const PORT = 50051

async function run() {
  const server = new GRPCServer({
    services: [UserService],
    config: {
      logger: true,
      credentials: ServerCredentials.createInsecure(),
      packageName: 'com.ghanizadev.lumineer',
    },
  });

  await server.run('0.0.0.0:' + PORT);
}

run();

The service is now available at localhost:50051.

Documentation

Check the package documentation for a more detailed information

License