peak-ai / jedlik

DynamoDB ODM for Node
MIT License
106 stars 4 forks source link

Expose ServiceConfig and ModelOptions interfaces at top level #20

Closed harrim91 closed 4 years ago

harrim91 commented 4 years ago

Description

The Model and DynamoDBClient constructors have parameters of type ModelOptions and ServiceConfig. Currently you only get the typing benefits if you define these parameters inline.

This PR exposes these types as part of the main API. Exposing them at the top level API means you can define them as separate variables - especially useful for the ServiceConfig if you're creating more than one model with the same config.

const userModelOps: ModelOptions<UserProps> = {
  table: 'users',
  schema: ...,
};

const orderModelOps: ModelOptions<OrderProps> = {
  table: 'orders',
  schema: ...,
};

const serviceConfig: ServiceConfig = {
  region: 'eu-west-1',
  endpoint: 'https://example.com:8000',
};

const User = new jedlik.Model(userModelOpts, serviceConfig);
const Order = new jedlik.Model(orderModelOpts, serviceConfig);