npm.io
3.2.0 • Published 8 years ago

crest-client

Licence
MIT
Version
3.2.0
Deps
1
Size
111 kB
Vulns
0
Weekly
0

Crest Client

A starter for creating your own typescript client module for a Crest Compliant Server.

  1. Update package.json => change the package name to a private-scoped module
  2. Update package.json => change the git url
  3. Get the packages: npm install
  4. Build your client npm run down path/to/crest/server
  5. Publish your client: npm login, npm publish

down will add the routes to the module.

Usage:

#In your client project:
npm login #Provide your user credentials.
npm install @myproject/crest-client --save
import { APIClient, MessageCategoryClass } from '@myproject/crest-client';

//TODO show how to implement this as APIService in an Angular project
//TODO provide clarification on httpMechansim and storageMechanism

let apiClient = new APIClient("http://localhost:3000", httpMechanism, storageMechanism);
let resultObservable<GetOutput<MessageCategoryClass.GetOutput>> = await apiClient.do('@/message/category', Method.GET, {

});
resultObservable.subscribe(messageCats => {
    messageCats.list.forEach(cat => {
        console.log(cat.name);
    });
    let idToFind = 10;
    console.log('this is the entire MessageCategoryClass.GetOutput which has id 10', messageCats.index[10]);
})