Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

fix: Gets cursors from headers for getEntities. #13

Merged
merged 2 commits into from
Mar 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ jobs:
- run:
name: Compiling Code
command: npm run build
- run:
name: Running tests
command: npm run cover
- run:
name: Linting Code
command: npm run lint
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"devDependencies": {
"@ht2-labs/semantic-release": "1.0.31",
"@ht2-labs/typescript-project": "1.0.9",
"@js-entity-repos/express": "1.0.0",
"@js-entity-repos/express": "1.1.0",
"@js-entity-repos/memory": "3.0.1",
"@types/body-parser": "1.16.8",
"@types/dotenv": "4.0.2",
Expand Down
17 changes: 4 additions & 13 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
1. Install it with `npm i @js-entity-repos/axios`.
1. For each entity you will need to do the following.
1. [Create an Entity interface](#entity-interface).
1. [Create a factory config](#factory-config).
1. [Construct the facade](#construct-the-facade).
1. [Use the facade](https://github.com/js-entity-repos/core/blob/master/docs/facade.md).

Expand All @@ -22,13 +21,13 @@ export interface TodoEntity extends Entity {
}
```

### Factory Config
### Construct the Facade

```ts
import FactoryConfig from '@js-entity-repos/axios/dist/FactoryConfig';
import factory from '@js-entity-repos/axios/dist/factory';
import axios from 'axios';

const todoFactoryConfig: FactoryConfig<TodoEntity> = {
const todosFacade = factory<TodoEntity>({
axios: axios.create({
baseURL: `http://localhost:80/api/todos`,
}),
Expand All @@ -50,13 +49,5 @@ const todoFactoryConfig: FactoryConfig<TodoEntity> = {
},
defaultPaginationLimit: 100, // Optional property.
entityName: 'todo',
};
```

### Construct the Facade

```ts
import factory from '@js-entity-repos/axios/dist/factory';

const todosFacade = factory(todoFactoryConfig);
});
```
2 changes: 1 addition & 1 deletion src/factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ sourceMapSupport.install();

import facadeTest from '@js-entity-repos/core/dist/tests';
import { TestEntity } from '@js-entity-repos/core/dist/tests/utils/testEntity';
import createTestServer from '@js-entity-repos/express/dist/utils/createTestServer';
import axios from 'axios';
import { config } from 'dotenv';
import 'mocha'; // tslint:disable-line:no-import-side-effect
import factory from './factory';
import createTestServer from './utils/createTestServer';
config();

const defaultServerPort = 1337;
Expand Down
6 changes: 3 additions & 3 deletions src/functions/getEntities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export default <E extends Entity>(config: FacadeConfig<E>): GetEntities<E> => {
};
const response = await Promise.resolve(config.axios.get('', { params }));

const entities = response.data.entities.map(config.constructEntity);
const nextCursor = response.data.nextCursor;
const previousCursor = response.data.previousCursor;
const entities = response.data.map(config.constructEntity);
const nextCursor = response.headers['x-entities-next-cursor'];
const previousCursor = response.headers['x-entities-previous-cursor'];

return { entities, nextCursor, previousCursor };
};
Expand Down
24 changes: 0 additions & 24 deletions src/utils/createTestServer.ts

This file was deleted.

18 changes: 0 additions & 18 deletions src/utils/memoryRepo/index.ts

This file was deleted.