tangled
alpha
login
or
join now
ptr.pet
/
barometer
1
fork
atom
service status on atproto
1
fork
atom
overview
issues
pulls
pipelines
refactor(proxy): move config stuff into its own file
ptr.pet
8 months ago
92c567b1
982d5ceb
verified
This commit was signed with the committer's
known signature
.
ptr.pet
SSH Key Fingerprint:
SHA256:Abmvag+juovVufZTxyWY8KcVgrznxvBjQpJesv071Aw=
+28
-26
2 changed files
expand all
collapse all
unified
split
proxy
src
config.ts
index.ts
+27
proxy/src/config.ts
···
1
1
+
import { isDid, type AtprotoDid } from "@atcute/lexicons/syntax";
2
2
+
import { env } from "process";
3
3
+
4
4
+
interface Config {
5
5
+
repoDid: AtprotoDid;
6
6
+
appPass: string;
7
7
+
}
8
8
+
9
9
+
const getConfig = (prefix: string): Config => {
10
10
+
const get = <Value>(
11
11
+
name: string,
12
12
+
check: (value: unknown) => boolean = (value) =>
13
13
+
typeof value !== "undefined",
14
14
+
): Value => {
15
15
+
const value = env[`${prefix}${name}`];
16
16
+
if (check(value)) {
17
17
+
return value as Value;
18
18
+
}
19
19
+
throw `config key ${name} is invalid`;
20
20
+
};
21
21
+
return {
22
22
+
repoDid: get("REPO_DID", isDid),
23
23
+
appPass: get("APP_PASSWORD"),
24
24
+
};
25
25
+
};
26
26
+
27
27
+
export const config = getConfig("BAROMETER_");
+1
-26
proxy/src/index.ts
···
11
11
WebDidDocumentResolver,
12
12
} from "@atcute/identity-resolver";
13
13
import { isDid, type AtprotoDid } from "@atcute/lexicons/syntax";
14
14
-
import { env } from "process";
14
14
+
import { config } from "./config";
15
15
import type {} from "@atcute/atproto";
16
16
import {} from "barometer-lexicon";
17
17
import { SystemsGazeBarometerState } from "barometer-lexicon";
18
18
import { now as generateTid } from "@atcute/tid";
19
19
import { is, safeParse } from "@atcute/lexicons";
20
20
-
21
21
-
interface Config {
22
22
-
repoDid: AtprotoDid;
23
23
-
appPass: string;
24
24
-
}
25
25
-
26
26
-
const getConfig = (prefix: string): Config => {
27
27
-
const get = <Value>(
28
28
-
name: string,
29
29
-
check: (value: unknown) => boolean = (value) =>
30
30
-
typeof value !== "undefined",
31
31
-
): Value => {
32
32
-
const value = env[`${prefix}${name}`];
33
33
-
if (check(value)) {
34
34
-
return value as Value;
35
35
-
}
36
36
-
throw `config key ${name} is invalid`;
37
37
-
};
38
38
-
return {
39
39
-
repoDid: get("REPO_DID", isDid),
40
40
-
appPass: get("APP_PASSWORD"),
41
41
-
};
42
42
-
};
43
43
-
44
44
-
const config = getConfig("BAROMETER_");
45
20
46
21
const docResolver = new CompositeDidDocumentResolver({
47
22
methods: {