Skip to content
This repository was archived by the owner on Jun 7, 2025. It is now read-only.

Commit 1cce146

Browse files
committed
init files
1 parent 10bc9b0 commit 1cce146

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Logger } from './utils/logger';
2+
import * as Docker from "dockerode";
3+
4+
class App {
5+
6+
private _docker: Docker;
7+
private _logger = new Logger(this);
8+
9+
public async init() {
10+
this._connect();
11+
console.log(await this._docker.getEvents());
12+
}
13+
14+
private _connect() {
15+
try {
16+
this._docker = new Docker({ socketPath: "/var/run/docker.sock" })
17+
} catch (e) {
18+
this._logger.error("Error connecting to Docker", e);
19+
process.exit(1);
20+
}
21+
}
22+
}
23+
24+
new App().init();

src/utils/logger.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export class Logger {
2+
private _name: string
3+
constructor(
4+
_instantiator: object
5+
) {
6+
this._name = Object.getPrototypeOf(_instantiator).constructor.name;
7+
}
8+
9+
log(...params: any[]) {
10+
console.log(`[${this._name}]`, ...params);
11+
}
12+
13+
error(...params: any[]) {
14+
console.error(`[${this._name}]`, ...params);
15+
}
16+
}

0 commit comments

Comments
 (0)