Skip to content

Commit 9f00b7a

Browse files
committed
hotfix of ExceptionGuard
1 parent c5e2736 commit 9f00b7a

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import { Config } from "./Config";
2-
require('dotenv').config()
3-
4-
export const CONFIG: Config = {
5-
appPort: parseInt(process.env.PORT || "8080"),
6-
7-
databaseHost: process.env.DATABASE_HOST || "localhost",
8-
databasePort: parseInt(process.env.DATABASE_PORT || "5432"),
9-
databaseName: process.env.DATABASE_NAME || "postgres",
10-
databaseUser: process.env.DATABASE_USER || "postgres",
11-
databasePassword: process.env.DATABASE_PASSWORD || "postgres",
12-
13-
get databaseConnectionString(): string {
14-
return `postgres://${this.databaseUser}:${this.databasePassword}@${this.databaseHost}:${this.databasePort}/${this.databaseName}`
15-
},
16-
17-
redisConnectionString: process.env.REDIS_CONNECTION_STRING || "redis://127.0.0.1:6379/0",
18-
19-
jwtSecret: process.env.JWT_SECRET || "SECRET",
20-
jwtExpiration: process.env.JWT_EXPIRATION || "24h",
21-
22-
log: function (): void {
23-
console.log(`[INFO] Webapp loaded with config:\nPORT: ${this.appPort}\nDATABASE CONNECTION: ${this.databaseConnectionString}\nJWT SECRET: ${this.jwtSecret}\nJWT EXPIRATION: ${this.jwtExpiration}\n`)
24-
}
1+
import { Config } from "./Config";
2+
require('dotenv').config()
3+
4+
export const CONFIG: Config = {
5+
appPort: parseInt(process.env.PORT || "8080"),
6+
7+
databaseHost: process.env.DATABASE_HOST || "localhost",
8+
databasePort: parseInt(process.env.DATABASE_PORT || "5432"),
9+
databaseName: process.env.DATABASE_NAME || "postgres",
10+
databaseUser: process.env.DATABASE_USER || "postgres",
11+
databasePassword: process.env.DATABASE_PASSWORD || "postgres",
12+
13+
get databaseConnectionString(): string {
14+
return `postgres://${this.databaseUser}:${this.databasePassword}@${this.databaseHost}:${this.databasePort}/${this.databaseName}`
15+
},
16+
17+
redisConnectionString: process.env.REDIS_CONNECTION_STRING || "redis://127.0.0.1:6379/0",
18+
19+
jwtSecret: process.env.JWT_SECRET || "SECRET",
20+
jwtExpiration: process.env.JWT_EXPIRATION || "24h",
21+
22+
log: function (): void {
23+
console.log(`[INFO] Webapp loaded with config:\nPORT: ${this.appPort}\nDATABASE CONNECTION: ${this.databaseConnectionString}\nJWT SECRET: ${this.jwtSecret}\nJWT EXPIRATION: ${this.jwtExpiration}\n`)
24+
}
2525
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { generateGuard } from "typing-assets";
22
import { Exception } from "../typing/Exception";
33

4-
export const isException = generateGuard<Exception>("message", "string")
4+
// before generateGuard function was used to create guard
5+
// but now guard generated by library function has got bug (https://github.com/LCcodder/typing-assets/issues/2)
6+
// so for now it is manually created type guard
7+
export const isException = (target: unknown): target is Exception => {
8+
return target && typeof (target as Exception)["message"] === 'string'
9+
}

0 commit comments

Comments
 (0)