-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better typing and structure + many new features
- better issues priorities (Notion) - better issues assigns (Notion) - emojis in Telegram report - auto-retry on request fail (Notion) - test ignoring feature (Notion) - fixes
- Loading branch information
1 parent
cf99675
commit 1c36cb6
Showing
12 changed files
with
839 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
export default class Logger { | ||
private readonly name: string; | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
} | ||
|
||
private prefix() { | ||
return `[${this.name}]`; | ||
} | ||
|
||
public log(...args: any[]) { | ||
console.log(this.prefix(), ...args); | ||
} | ||
|
||
public error(...args: any[]) { | ||
console.error(this.prefix(), ...args); | ||
} | ||
|
||
public warn(...args: any[]) { | ||
console.warn(this.prefix(), ...args); | ||
} | ||
|
||
public info(...args: any[]) { | ||
console.info(this.prefix(), ...args); | ||
} | ||
|
||
public debug(...args: any[]) { | ||
console.debug(this.prefix(), ...args); | ||
} | ||
|
||
public trace(...args: any[]) { | ||
console.trace(this.prefix(), ...args); | ||
} | ||
|
||
public separator() { | ||
console.log(''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Client } from '@notionhq/client'; | ||
import TestsDatabase from './databases/TestsDatabase'; | ||
import IssuesDatabase from './databases/IssuesDatabase'; | ||
|
||
export type Language = 'EN' | 'FR'; | ||
|
||
interface DatabaseControllerConfig { | ||
auth: string; | ||
dbIDs: { | ||
tests: string; | ||
issues: string; | ||
}; | ||
} | ||
|
||
export default class DatabaseController { | ||
readonly client: Client; | ||
public lang: Language; | ||
public readonly tests: TestsDatabase; | ||
public readonly issues: IssuesDatabase; | ||
|
||
constructor({ auth, dbIDs }: DatabaseControllerConfig) { | ||
this.client = new Client({ | ||
auth, | ||
fetch: async (url: string, init?: RequestInit) => { | ||
try { | ||
const res = await fetch(url, init); | ||
if (!res.ok) throw new Error(); | ||
return res; | ||
} catch (err) { | ||
console.warn('Notion API error, retrying...'); | ||
await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
return fetch(url, init); | ||
} | ||
} | ||
}); | ||
|
||
this.tests = new TestsDatabase({ | ||
controller: this, | ||
id: dbIDs.tests, | ||
}); | ||
|
||
this.issues = new IssuesDatabase({ | ||
controller: this, | ||
id: dbIDs.issues, | ||
}); | ||
} | ||
|
||
public async setup() { | ||
let errored = false; | ||
|
||
for (const db of [ | ||
this.tests, | ||
this.issues, | ||
]) errored = !(await db.setup()) || errored; | ||
|
||
if (errored) { | ||
console.error('Exiting due to wrong database schema.'); | ||
process.exit(1); | ||
} | ||
} | ||
} |
Oops, something went wrong.