Skip to content
This repository has been archived by the owner on Mar 30, 2022. It is now read-only.

Commit

Permalink
refactor: rework data sent in start job request
Browse files Browse the repository at this point in the history
  • Loading branch information
Cory committed Jul 7, 2021
1 parent ba9fbef commit 4031740
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ By default the service should now be available at `http://localhost:4001` and an

The service can be configured through the use of environment variables.

- `ARTICLE_STORE_PATH` - partial path for reaching the `editor-article-store`. This has the requests `articleId` param appended to it to make a HEAD request before starting generation job. (default : `http://localhost:8080/articles/`)
- `GENERATION_RESOURCES_PATH` - partial path used for fetching resources to generate the PDF. (default : `http://localhost:4000/api/v1/articles/`)
- `ARTICLE_STORE_PATH` - partial internal path for reaching the `editor-article-store`. This has the requests `articleId` param appended to it to make a HEAD request before starting generation job. (default : `http://localhost:8080/articles/`)
- `EDITOR_URL` - externally accessible URL for Libero Editor (default : `http://localhost:4000`)
- `GENERATION_START_URL` - POST request is made with relevent urlencoded form data to this URL to start the PDF generation job (default : `http://localhost:80`)
- `GENERATION_STATUS_URL` - POST request is made with relevent urlencoded form data to this URL to check status of PDF generation job (default : `http://localhost:80`)
- `GENERATION_API_KEY` - API key to be sent with start job and status requests (default : `mySuperSecretApiKey`)
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import GenerateService from './services/generate';
const config = {
port: process.env.PORT || 4001,
articleStorePath: process.env.ARTICLE_STORE_PATH || 'http://localhost:8080/articles/',
editorURL: process.env.EDITOR_URL || 'http://localhost:4000',
generationJobStatusURL: process.env.GENERATION_STATUS_URL || 'http://localhost:80',
generationJobResourcesPath: process.env.GENERATION_RESOURCES_PATH || 'http://localhost:3000/api/v1/articles',
generationJobStartURL: process.env.GENERATION_START_URL || 'http://localhost:80',
generaionJobApiKey: process.env.GENERATION_API_KEY || 'mySuperSecretApiKey',
};
Expand Down
4 changes: 2 additions & 2 deletions src/services/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ describe('GenerateService', () => {
});
await GenerateService({
articleStorePath: 'someUrl/',
generationJobResourcesPath: 'generationJobResourcesPath/',
editorURL: 'editorURL',
generaionJobApiKey: 'someApiKey',
}).startJob('11111');
expect((fetch as unknown as jest.Mock).mock.calls[1][1].body).toBeInstanceOf(URLSearchParams);
expect((fetch as unknown as jest.Mock).mock.calls[1][1].body.toString()).toBe(
'client=elife-libero&id=elife.11111&idType=doi&processType=InDesignSetter&project=elife-libero&proof=online&proofingVersion=v2.0&siteName=generationJobResourcesPath%2F11111&proofingEngine=InDesignSetter&apiKey=someApiKey',
'client=elife-libero&id=11111&idType=doi&processType=InDesignSetter&project=elife-libero&proof=online&proofingVersion=v2.0&siteName=editorURL&proofingEngine=InDesignSetter&apiKey=someApiKey',
);
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/services/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ export default (config: Record<string, unknown>): GenerateService => ({
const params = new URLSearchParams();
// TODO: We probably want to make more of these options configurable
params.append('client', 'elife-libero');
params.append('id', `elife.${id}`);
params.append('id', id);
params.append('idType', 'doi');
params.append('processType', 'InDesignSetter');
params.append('project', 'elife-libero');
params.append('proof', 'online');
params.append('proofingVersion', 'v2.0');
params.append('siteName', `${config['generationJobResourcesPath']}${id}`);
params.append('siteName', `${config['editorURL']}`);
params.append('proofingEngine', 'InDesignSetter');
params.append('apiKey', `${config['generaionJobApiKey']}`);
// OPTIONAL - omitting this generates regular pdf
Expand Down

0 comments on commit 4031740

Please sign in to comment.