-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathlib.w
44 lines (40 loc) · 1.02 KB
/
lib.w
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
bring cloud;
bring ui;
bring util;
bring fs;
bring "./types.w" as types;
bring "./sim.w" as sim;
bring "./tfaws.w" as tfaws;
/**
* Starts a new TSOA service.
*/
pub class Service impl types.IService {
inner: types.IService;
pub url: str;
pub specFile: str;
new(props: types.ServiceProps) {
let target = util.env("WING_TARGET");
if target == "sim" {
let service = new sim.Service_sim(props);
this.inner = service;
this.url = service.url;
this.specFile = service.specFile;
} else if target == "tf-aws" {
let service = new tfaws.Service_tfaws(props);
this.inner = service;
this.url = service.url;
this.specFile = service.specFile;
} else {
throw "Unknown target: {target}";
}
new ui.HttpClient("Http Client", inflight () => {
return this.url;
}, inflight () => {
return fs.readFile(this.specFile);
});
new cloud.Endpoint(this.url);
}
pub lift(client: std.Resource, ops: types.LiftOptions) {
this.inner.lift(client, ops);
}
}