Skip to content

Commit 675c297

Browse files
committed
Fix various bugs
1 parent 0ef4f41 commit 675c297

File tree

7 files changed

+21
-20
lines changed

7 files changed

+21
-20
lines changed

src/configs/config.controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Controller, Headers, Get, Query, Post, Body } from '@nestjs/common';
22
import { FileBasedConfigService } from './config.service';
33
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
44
import { GetConfigsRequestDto } from './dto/get-configs-request.dto';
5-
import { GetConfigsResponsetDto } from './dto/get-configs-response.dto';
5+
import { GetConfigsResponseDto } from './dto/get-configs-response.dto';
66

77
@ApiTags('Configurations')
88
@Controller("configs")
@@ -15,7 +15,7 @@ export class ConfigController {
1515
})
1616
@ApiOkResponse({
1717
description: 'Successfully retrieved configurations.',
18-
type: GetConfigsResponsetDto
18+
type: GetConfigsResponseDto
1919
})
2020
async get(@Body() config : GetConfigsRequestDto): Promise<Record<string, string>> {
2121
let configsParam: string = config.configs ?? "*";

src/configs/config.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export class FileBasedConfigService {
5858
if (!existsSync(filePath)) {
5959
return defaultResult;
6060
}
61-
return readFilePromisified(join(filePath), "utf8");
61+
const content = await readFilePromisified(filePath, "utf8");
62+
return json5.parse(content);
6263
} catch {
6364
return defaultResult;
6465
}

src/configs/dto/get-configs-response.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ApiProperty } from "@nestjs/swagger";
22

3-
export class GetConfigsResponsetDto {
3+
export class GetConfigsResponseDto {
44
@ApiProperty({
55
description: 'Overriding JSON configuration for the `system.json` file of io.Connect Desktop.',
66
})

src/layouts/layouts.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const unlinkFilePromisified = promisify(unlink);
2121
export class FileBasedLayoutsService {
2222

2323

24-
private layoutsFolder = process.env.APPS_FOLDER || "./configuration/layouts";
24+
private layoutsFolder = process.env.LAYOUTS_FOLDER || "./configuration/layouts";
2525
private defaultLayoutType = "default";
2626

2727
async getAll(): Promise<LayoutDto[]> {
@@ -83,9 +83,9 @@ export class FileBasedLayoutsService {
8383
console.error("Error deleting old layout file:", error);
8484
}
8585

86-
layout.name = newName;
87-
this.saveLayout(layout);
88-
}
86+
layout.name = newName;
87+
await this.saveLayout(layout);
88+
}
8989

9090
getLayoutPath(layout: LayoutDto): string {
9191
return join(this.layoutsFolder, this.getLayoutName(layout));

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ async function bootstrap() {
1414
const document = SwaggerModule.createDocument(app, config);
1515
SwaggerModule.setup('api', app, document);
1616

17-
await app.listen(process.env.PORT ?? 8004);
17+
await app.listen(process.env.SERVER_PORT ?? 8004);
1818
}
1919
bootstrap();

src/prefs/prefs.controller.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ export class PrefsController {
5757
})
5858
removeApp(@Body() removeRequest: RemoveAppPrefsRequestDto): Promise<void> {
5959
console.log("Removing prefs", removeRequest);
60-
if (!removeRequest.app) {
61-
return this.service.remove(removeRequest.app);
62-
} else {
63-
return this.service.clear();
64-
}
65-
}
66-
}
60+
if (removeRequest.app) {
61+
return this.service.remove(removeRequest.app);
62+
} else {
63+
return this.service.clear();
64+
}
65+
}
66+
}

src/prefs/prefs.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ export class FileBasedPrefsService {
7171
public async clear(): Promise<void> {
7272
let files = await readDirPromisfied(this.folder);
7373
files = files.filter(f => f.endsWith(".json"));
74-
files.map((f) => {
75-
unlinkFilePromisified(join(this.folder, f));
76-
});
77-
}
74+
await Promise.all(
75+
files.map(f => unlinkFilePromisified(join(this.folder, f)))
76+
);
77+
}
7878

7979
private fullPath(app: string) {
8080
const fileName = `${app}.json`;

0 commit comments

Comments
 (0)