-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
55 lines (52 loc) · 2.35 KB
/
Copy pathapp.js
File metadata and controls
55 lines (52 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const fastify = require('fastify');
const cors = require('@fastify/cors');
const { bulkExport, patientBulkExport, groupBulkExport, collectData } = require('../services/export.service');
const { checkBulkStatus, kickoffImport } = require('../services/bulkstatus.service');
const { returnNDJsonContent } = require('../services/ndjson.service');
const { groupSearchById, groupSearch, groupCreate, groupUpdate, groupRemove } = require('../services/group.service');
const { uploadTransactionOrBatchBundle } = require('../services/bundle.service');
const { generateCapabilityStatement } = require('../services/metadata.service');
const {
patientSearch,
patientSearchById,
patientCreate,
patientUpdate,
patientRemove
} = require('../services/patient.service');
// set bodyLimit to 50mb
function build(opts) {
const app = fastify({ ...opts, bodyLimit: 50 * 1024 * 1024 });
app.addContentTypeParser(
['application/json+fhir', 'application/fhir+json'],
{ parseAs: 'string' },
app.getDefaultJsonParser('ignore', 'ignore')
);
app.register(cors, { exposedHeaders: ['content-location', 'expires', 'x-progress', 'retry-after'] });
app.get('/metadata', generateCapabilityStatement);
app.get('/$export', bulkExport);
app.post('/$export', bulkExport);
app.get('/Patient/$export', patientBulkExport);
app.post('/Patient/$export', patientBulkExport);
app.get('/Group/:groupId/$export', groupBulkExport);
app.post('/Group/:groupId/$export', groupBulkExport);
app.post('/bulkstatus/:clientId/kickoff-import', kickoffImport);
app.get('/bulkstatus/:clientId', checkBulkStatus);
app.get('/:clientId/:fileName', returnNDJsonContent);
app.get('/Group/:groupId', groupSearchById);
app.get('/Group', groupSearch);
app.post('/Group', groupCreate);
app.put('/Group/:groupId', groupUpdate);
app.delete('/Group/:groupId', groupRemove);
app.post('/', uploadTransactionOrBatchBundle);
app.get('/Patient/:patientId', patientSearchById);
app.get('/Patient', patientSearch);
app.post('/Patient', patientCreate);
app.put('/Patient/:patientId', patientUpdate);
app.delete('/Patient/:patientId', patientRemove);
app.get('/Measure/$collect-data', collectData);
app.post('/Measure/$collect-data', collectData);
app.get('/Measure/:measureId/$collect-data', collectData);
app.post('/Measure/:measureId/$collect-data', collectData);
return app;
}
module.exports = build;