Skip to content

Commit 00566e6

Browse files
Merge pull request #220 from dannya/code-formatting
chore: fix inconsistent code formatting / indentation in `apiv1.ts`
2 parents 364e50a + cf996c8 commit 00566e6

1 file changed

Lines changed: 11 additions & 18 deletions

File tree

src/nightscout/apiv1.ts

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import axios, { RawAxiosRequestHeaders } from "axios";
2-
import { Entry, NightscoutAPI, NightscoutConfig } from "./interface";
3-
import { logger } from "..";
1+
import axios, {RawAxiosRequestHeaders} from "axios";
2+
import {Entry, NightscoutAPI, NightscoutConfig} from "./interface";
43

54
interface NightscoutApiV1HttpHeaders extends RawAxiosRequestHeaders {
65
"api-secret": string | undefined;
@@ -11,8 +10,7 @@ export class Client implements NightscoutAPI {
1110
readonly headers: NightscoutApiV1HttpHeaders;
1211
readonly device: string;
1312

14-
constructor(config: NightscoutConfig)
15-
{
13+
constructor(config: NightscoutConfig) {
1614
this.baseUrl = config.nightscoutBaseUrl;
1715
this.headers = {
1816
"api-secret": config.nightscoutApiToken,
@@ -22,25 +20,21 @@ export class Client implements NightscoutAPI {
2220
this.device = config.nightscoutDevice;
2321
}
2422

25-
async lastEntry(): Promise<Entry | null>
26-
{
23+
async lastEntry(): Promise<Entry | null> {
2724
const url = new URL("/api/v1/entries?count=1", this.baseUrl).toString();
28-
const resp = await axios.get(url, {headers: this.headers});
25+
const resp = await axios.get(url, {headers: this.headers});
2926

30-
if (resp.status !== 200)
31-
{
27+
if (resp.status !== 200) {
3228
throw Error(`failed to get last entry: ${resp.statusText}`);
3329
}
3430

35-
if (!resp.data || resp.data.length === 0)
36-
{
31+
if (!resp.data || resp.data.length === 0) {
3732
return null;
3833
}
3934
return resp.data.pop();
4035
}
4136

42-
async uploadEntries(entries: Entry[]): Promise<void>
43-
{
37+
async uploadEntries(entries: Entry[]): Promise<void> {
4438
const url = new URL("/api/v1/entries", this.baseUrl).toString();
4539
const entriesV1 = entries.map((e) => ({
4640
type: "sgv",
@@ -51,11 +45,10 @@ export class Client implements NightscoutAPI {
5145
dateString: e.date.toISOString(),
5246
}));
5347

54-
const resp = await axios.post(url, entriesV1, {headers: this.headers});
48+
const resp = await axios.post(url, entriesV1, {headers: this.headers});
5549

56-
if (resp.status !== 200)
57-
{
58-
throw Error(`failed to post new entries: ${resp.statusText} ${resp.status}`);
50+
if (resp.status !== 200) {
51+
throw Error(`failed to post new entries: ${resp.statusText} ${resp.status}`);
5952
}
6053

6154
return;

0 commit comments

Comments
 (0)