35 lines
858 B
TypeScript
35 lines
858 B
TypeScript
import dotenv from 'dotenv';
|
|
|
|
dotenv.config();
|
|
|
|
let _raspberryHost = process.env.RASPBERRY_PI_HOST ?? 'http://raspberrypi.local';
|
|
let _raspberryPort = Number(process.env.RASPBERRY_PI_PORT) || 8000;
|
|
let _token = process.env.QUIBOT_TOKEN ?? 'MY_SECRET_TOKEN';
|
|
const APP_PORT = Number(process.env.PORT) || 5000;
|
|
|
|
export const getRaspberryHost = () => _raspberryHost;
|
|
export const getRaspberryPort = () => _raspberryPort;
|
|
export const getToken = () => _token;
|
|
|
|
export function setRaspberryHost(host: string) {
|
|
_raspberryHost = host;
|
|
}
|
|
|
|
export function setRaspberryPort(port: number) {
|
|
_raspberryPort = port;
|
|
}
|
|
|
|
export function setToken(token: string) {
|
|
_token = token;
|
|
}
|
|
|
|
export const getConfig = () => ({
|
|
raspberryPi: {
|
|
host: getRaspberryHost(),
|
|
port: getRaspberryPort(),
|
|
},
|
|
token: getToken(),
|
|
});
|
|
|
|
export const getAppPort = () => APP_PORT;
|