blob: dc3889a27cd7e6ceb02a6526684fcbd7dbb20c48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
import dotenv from "dotenv";
if (!process.env.SKIP_DOTENV) {
dotenv.config();
}
class ConfigError extends Error {
constructor(message: string) {
super(message);
this.name = "ConfigError";
}
}
const tgWebhookUrl = process.env.TELEGRAM_WEBHOOK_URL || null;
if (!tgWebhookUrl) {
throw new ConfigError("Missing env var TELEGRAM_WEBHOOK_URL");
}
const tgBotToken = process.env.TELEGRAM_BOT_TOKEN || null;
if (!tgBotToken) {
throw new ConfigError("Missing env var TELEGRAM_BOT_TOKEN");
}
const tgUserIds = process.env.TELEGRAM_USER_IDS
? process.env.TELEGRAM_USER_IDS?.split(",")
.map(Number.parseInt)
: null;
if (!tgUserIds) {
throw new ConfigError("Missing env var TELEGRAM_USER_IDS");
}
const sheetsSpreadsheetId = process.env.SHEETS_SPREADSHEET_ID || null;
if (!sheetsSpreadsheetId) {
throw new ConfigError("Missing env var SHEETS_SPREADSHEET_ID");
}
const sheetsRange = process.env.SHEETS_RANGE || null;
if (!sheetsRange) {
throw new ConfigError("Missing env var SHEETS_RANGE");
}
const config = {
port: process.env.PORT ? Number(process.env.PORT) : 3000,
tgWebhookUrl,
tgBotToken,
tgUserIds,
sheetsSpreadsheetId,
sheetsRange,
};
export default config;
|