Skip to content

Commit 978a695

Browse files
Formatting.
1 parent 85c8869 commit 978a695

File tree

1 file changed

+44
-56
lines changed

1 file changed

+44
-56
lines changed

src/cloudflare-kv/cloudflare-kv.service.ts

Lines changed: 44 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,66 +5,54 @@ import { KvNamespaces } from './models/kv-namespaces.enum';
55

66
@Injectable()
77
export class CloudflareKvService implements OnModuleInit {
8-
private edgeKvUrl: string;
9-
private authorizationToken: string;
8+
private edgeKvUrl: string;
9+
private authorizationToken: string;
1010

11-
constructor(
12-
private readonly configService: ConfigService,
13-
private readonly logService: LogService,
14-
) {}
11+
constructor(
12+
private readonly configService: ConfigService,
13+
private readonly logService: LogService
14+
) {}
1515

16-
onModuleInit() {
17-
this.edgeKvUrl = this.configService.get('EDGE_KV_URL');
18-
this.authorizationToken = this.configService.get(
19-
'EDGE_KV_AUTHORIZATION_TOKEN',
20-
);
21-
}
22-
23-
async createKeyValueForNamespace(
24-
namespace: KvNamespaces,
25-
key: string,
26-
value?: string | object,
27-
) {
28-
try {
29-
const requestOptions = {
30-
method: 'POST',
31-
headers: {
32-
authorizationToken: this.authorizationToken,
33-
},
34-
};
35-
36-
const response = await fetch(
37-
`${this.edgeKvUrl}/${namespace}/${key}`,
38-
requestOptions,
39-
);
40-
41-
return response;
42-
} catch (e) {
43-
this.logService.error('Failed to update workers KV', {
44-
errorMessage: e.message,
45-
});
16+
onModuleInit() {
17+
this.edgeKvUrl = this.configService.get('EDGE_KV_URL');
18+
this.authorizationToken = this.configService.get('EDGE_KV_AUTHORIZATION_TOKEN');
4619
}
47-
}
4820

49-
async deleteKeyForNamespace(namespace: KvNamespaces, key: string) {
50-
try {
51-
const requestOptions = {
52-
method: 'DELETE',
53-
headers: {
54-
authorizationToken: this.authorizationToken,
55-
},
56-
};
57-
58-
const response = await fetch(
59-
`${this.edgeKvUrl}/${namespace}/${key}`,
60-
requestOptions,
61-
);
21+
async createKeyValueForNamespace(namespace: KvNamespaces, key: string, value?: string | object) {
22+
try {
23+
const requestOptions = {
24+
method: 'POST',
25+
headers: {
26+
authorizationToken: this.authorizationToken,
27+
},
28+
};
29+
30+
const response = await fetch(`${this.edgeKvUrl}/${namespace}/${key}`, requestOptions);
31+
32+
return response;
33+
} catch (e) {
34+
this.logService.error('Failed to update workers KV', {
35+
errorMessage: e.message,
36+
});
37+
}
38+
}
6239

63-
return response.json();
64-
} catch (e) {
65-
this.logService.error('Failed to update workers KV', {
66-
errorMessage: e.message,
67-
});
40+
async deleteKeyForNamespace(namespace: KvNamespaces, key: string) {
41+
try {
42+
const requestOptions = {
43+
method: 'DELETE',
44+
headers: {
45+
authorizationToken: this.authorizationToken,
46+
},
47+
};
48+
49+
const response = await fetch(`${this.edgeKvUrl}/${namespace}/${key}`, requestOptions);
50+
51+
return response.json();
52+
} catch (e) {
53+
this.logService.error('Failed to update workers KV', {
54+
errorMessage: e.message,
55+
});
56+
}
6857
}
69-
}
7058
}

0 commit comments

Comments
 (0)