forked from awslabs/fhir-works-on-aws-deployment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.ts
101 lines (94 loc) · 3.47 KB
/
config.ts
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import { FhirConfig, FhirVersion, stubs, BASE_R4_RESOURCES, BASE_STU3_RESOURCES } from 'fhir-works-on-aws-interface';
import { ElasticSearchService } from 'fhir-works-on-aws-search-es';
import { RBACHandler } from 'fhir-works-on-aws-authz-rbac';
import {
DynamoDb,
DynamoDbDataService,
DynamoDbBundleService,
S3DataService,
DynamoDbUtil,
} from 'fhir-works-on-aws-persistence-ddb';
import RBACRules from './RBACRules';
const { IS_OFFLINE } = process.env;
const fhirVersion: FhirVersion = '4.0.1';
const baseResources = fhirVersion === '4.0.1' ? BASE_R4_RESOURCES : BASE_STU3_RESOURCES;
const authService = IS_OFFLINE ? stubs.passThroughAuthz : new RBACHandler(RBACRules(baseResources), fhirVersion);
const dynamoDbDataService = new DynamoDbDataService(DynamoDb);
const dynamoDbBundleService = new DynamoDbBundleService(DynamoDb);
const esSearch = new ElasticSearchService(
[
{
key: 'documentStatus',
value: ['AVAILABLE'],
comparisonOperator: '==',
logicalOperator: 'AND',
},
],
DynamoDbUtil.cleanItem,
fhirVersion,
);
const s3DataService = new S3DataService(dynamoDbDataService, fhirVersion);
const OAuthUrl =
process.env.OAUTH2_DOMAIN_ENDPOINT === '[object Object]' || process.env.OAUTH2_DOMAIN_ENDPOINT === undefined
? 'https://OAUTH2.com'
: process.env.OAUTH2_DOMAIN_ENDPOINT;
export const fhirConfig: FhirConfig = {
configVersion: 1.0,
productInfo: {
orgName: 'Organization Name',
},
auth: {
authorization: authService,
// Used in Capability Statement Generation only
strategy: {
service: 'OAuth',
oauthPolicy: {
authorizationEndpoint: `${OAuthUrl}/authorize`,
tokenEndpoint: `${OAuthUrl}/token`,
},
},
},
server: {
// When running serverless offline, env vars are expressed as '[object Object]'
// https://github.com/serverless/serverless/issues/7087
// As of May 14, 2020, this bug has not been fixed and merged in
// https://github.com/serverless/serverless/pull/7147
url:
process.env.API_URL === '[object Object]' || process.env.API_URL === undefined
? 'https://API_URL.com'
: process.env.API_URL,
},
logging: {
// Unused at this point
level: 'error',
},
profile: {
systemOperations: ['transaction'],
bundle: dynamoDbBundleService,
systemHistory: stubs.history,
systemSearch: stubs.search,
bulkDataAccess: dynamoDbDataService,
fhirVersion,
genericResource: {
operations: ['create', 'read', 'update', 'delete', 'vread', 'search-type'],
fhirVersions: [fhirVersion],
persistence: dynamoDbDataService,
typeSearch: esSearch,
typeHistory: stubs.history,
},
resources: {
Binary: {
operations: ['create', 'read', 'update', 'delete', 'vread'],
fhirVersions: [fhirVersion],
persistence: s3DataService,
typeSearch: stubs.search,
typeHistory: stubs.history,
},
},
},
};
export const genericResources = baseResources;