Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Documentation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
wtrocki committed Aug 15, 2017
1 parent d9b6524 commit 6127654
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
29 changes: 26 additions & 3 deletions cloud/wfm-rest-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,27 @@ See demo application integration or [example application](./example) for more de

### Custom database integrations

Custom database integrations are possible thanks to `CrudRepository` interface.
See Api documentation for more details.
Custom database integrations are possible thanks to `PagingDataRepository` interface.

## Rest API

Module provides a way to dynamically create API for different business objects.
Created api will use simplified implementations for typical create, read, delete and update operations. It's not recomended to use `wfm-rest-api` outside the WFM framework. Please use database driver or ORM framework or your choice.

## Rest API structure

API produces and expects JSON objects.
Structure of payload will vary depending on the interface passed as generic parameter to `PagingDataRepository`
For example:

```typescript
interface MyData{
name:string
fieldNumber:1
}
const repository = new PagingDataRepository<MyData>();
```

## Rest API definitions

Definitions apply to every object exposed by this API. Placeholder `{object}` can be replaced by `workflow`, `workorder` and `result`.
Expand Down Expand Up @@ -76,28 +89,38 @@ Retrieve specific object by id

Example `/workorders/B1r71fOBr`

Return 204

### Save object

> POST {object}/
Paylod should contain at least `id` field that will be used as object id.

### Update object

> PUT {object}/:objectId
Where `:objectId` is an `id` field of the object.

### Delete object

> DELETE {object}/:objectId
Where `:objectId` is an `id` field of the object.

### Error handling

In case of error express `next` callback is being called with `ApiError` instance.
Users should build their own middleware for global error handling in their application.

Api returns non 200 status in case of error.
Api will returns non 200 status in case of error.

`400` - For user input error (missing required field etc.)
`500` - For internal server errors

Api will return `204` status code if content is missing (for example invalid id was provided)

For every error `ApiError` object is being returned.
For example:

Expand Down
1 change: 1 addition & 0 deletions cloud/wfm-rest-api/src/data-api/PagingDataRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { PageResponse } from '../data-api/PageResponse';
* Interface is being used internally to perform database operations for WFM models
* It's not recomended to use it for other application business logic.
*
* T - interface with fields that are expected to be returned by this repository
*/
export interface PagingDataRepository<T> {

Expand Down

0 comments on commit 6127654

Please sign in to comment.