-
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.
Merge pull request #17 from adidoesnt/development
Flatten IDs
- Loading branch information
Showing
23 changed files
with
199 additions
and
288 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM oven/bun | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json . | ||
COPY bun.lockb . | ||
|
||
RUN bun install | ||
|
||
COPY . . | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ["bun", "run", "start"] |
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
Binary file not shown.
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,22 @@ | ||
{ | ||
"name": "ping", | ||
"module": "src/index.ts", | ||
"type": "module", | ||
"scripts": { | ||
"start": "bun run src/index.ts", | ||
"dev": "bun run --hot src/index.ts", | ||
"build": "docker build -t echofinder-health:latest .", | ||
"local": "docker run --env-file .env echofinder-health:latest", | ||
"prod": "docker run echofinder-health:latest" | ||
}, | ||
"devDependencies": { | ||
"@types/bun": "latest" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"axios": "^1.6.7", | ||
"log4js": "^6.9.1" | ||
} | ||
} |
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,23 @@ | ||
import log4js from "log4js"; | ||
|
||
const { | ||
LOG_FILE: logFile = "logs/combined.log", | ||
ERROR_LOG_FILE: errorFile = "logs/error.log", | ||
} = process.env; | ||
|
||
log4js.configure({ | ||
appenders: { | ||
console: { type: "console" }, | ||
file: { type: "file", filename: logFile }, | ||
error: { type: "file", filename: errorFile }, | ||
}, | ||
categories: { | ||
default: { appenders: ["console", "file"], level: "info" }, | ||
error: { appenders: ["console", "error", "file"], level: "error" }, | ||
}, | ||
}); | ||
|
||
export const logger = { | ||
defaultLogger: log4js.getLogger("default"), | ||
errorLogger: log4js.getLogger("error"), | ||
}; |
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,31 @@ | ||
import axios, { AxiosError } from "axios"; | ||
import { logger } from "components/logger"; | ||
|
||
const { SERVER_LIST = "", PING_INTERVAL = "300000" } = process.env; | ||
const { defaultLogger, errorLogger } = logger; | ||
const servers: Array<string> = SERVER_LIST.split(","); | ||
const pingInterval = Number(PING_INTERVAL); | ||
|
||
const pingServers = async () => { | ||
const promises = servers.map(async (server: string) => { | ||
defaultLogger.info(`Checking server health ${server}`); | ||
try { | ||
await axios.get(server); | ||
} catch (error) { | ||
if ((error as AxiosError).response?.status) { | ||
defaultLogger.info(`Server at ${server} is healthy.`); | ||
} else { | ||
errorLogger.error(`Server at ${server} is down.`); | ||
} | ||
} | ||
}); | ||
await Promise.all(promises); | ||
}; | ||
|
||
defaultLogger.info( | ||
`Starting health check for servers ${servers.join(", ")}...` | ||
); | ||
setTimeout( | ||
() => pingServers().then(() => setInterval(pingServers, pingInterval)), | ||
3000 | ||
); |
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,23 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["ESNext"], | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleDetection": "force", | ||
"jsx": "react-jsx", | ||
"allowJs": true, | ||
"baseUrl": "./src", | ||
|
||
/* Bundler mode */ | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"verbatimModuleSyntax": true, | ||
"noEmit": true, | ||
|
||
/* Linting */ | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"forceConsistentCasingInFileNames": true | ||
} | ||
} |
Binary file not shown.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export const ERROR = { | ||
NO_FROM: 'No from field in message', | ||
INVALID_CALLBACK_QUERY: 'Invalid callback query', | ||
}; |
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 was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.