forked from aws-solutions/research-service-workbench-on-aws
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbackendAPI.ts
77 lines (71 loc) · 2.58 KB
/
backendAPI.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
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import { generateRouter, ApiRouteConfig } from '@aws/swb-app';
import { AuditService, BaseAuditPlugin } from '@aws/workbench-core-audit';
import { AwsService, AuditLogger } from '@aws/workbench-core-base';
import {
DataSetService,
S3DataSetStoragePlugin,
DdbDataSetMetadataPlugin
} from '@aws/workbench-core-datasets';
import {
HostingAccountService,
EnvironmentService,
EnvironmentTypeService,
EnvironmentTypeConfigService,
ProjectService
} from '@aws/workbench-core-environments';
import { LoggingService } from '@aws/workbench-core-logging';
import { Express } from 'express';
import SagemakerNotebookEnvironmentConnectionService from './environment/sagemakerNotebook/sagemakerNotebookEnvironmentConnectionService';
import SagemakerNotebookEnvironmentLifecycleService from './environment/sagemakerNotebook/sagemakerNotebookEnvironmentLifecycleService';
const logger: LoggingService = new LoggingService();
const aws: AwsService = new AwsService({
region: process.env.AWS_REGION!,
ddbTableName: process.env.STACK_NAME!
});
const apiRouteConfig: ApiRouteConfig = {
routes: [
{
path: '/foo',
serviceAction: 'launch',
httpMethod: 'post',
service: new SagemakerNotebookEnvironmentLifecycleService()
}
],
environments: {
sagemakerNotebook: {
lifecycle: new SagemakerNotebookEnvironmentLifecycleService(),
connection: new SagemakerNotebookEnvironmentConnectionService()
}
// Add your environment types here as follows:
// <newEnvTypeName>: {
// lifecycle: new <newEnvTypeName>EnvironmentLifecycleService(),
// connection: new <newEnvTypeName>EnvironmentConnectionService()
// }
},
account: new HostingAccountService(),
environmentService: new EnvironmentService({
TABLE_NAME: process.env.STACK_NAME!
}),
dataSetService: new DataSetService(
new AuditService(new BaseAuditPlugin(new AuditLogger(logger))),
logger,
new DdbDataSetMetadataPlugin(aws, 'DATASET', 'ENDPOINT')
),
dataSetsStoragePlugin: new S3DataSetStoragePlugin(aws),
allowedOrigins: JSON.parse(process.env.ALLOWED_ORIGINS || '[]'),
environmentTypeService: new EnvironmentTypeService({
TABLE_NAME: process.env.STACK_NAME!
}),
environmentTypeConfigService: new EnvironmentTypeConfigService({
TABLE_NAME: process.env.STACK_NAME!
}),
projectService: new ProjectService({
TABLE_NAME: process.env.STACK_NAME!
})
};
const backendAPIApp: Express = generateRouter(apiRouteConfig);
export default backendAPIApp;