initial commit & scaffold

This commit is contained in:
Elijah Duffy
2025-12-24 16:59:16 -08:00
commit 7375b4d96f
16 changed files with 167 additions and 0 deletions

17
.eslintrc.cjs Normal file
View File

@@ -0,0 +1,17 @@
module.exports = {
root: true,
env: {
node: true,
es2021: true,
},
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
rules: {
'prettier/prettier': 'error',
},
};

20
.gitignore vendored Normal file
View File

@@ -0,0 +1,20 @@
# Node
node_modules/
packages/*/node_modules/
.pnpm-store/
.pnpm-debug.log
pnpm-lock.yaml
# TypeScript
dist/
**/dist/
**/*.tsbuildinfo
# Go
**/vendor/
**/*.exe
**/*.out
# Misc
.env
.DS_Store

6
.prettierignore Normal file
View File

@@ -0,0 +1,6 @@
node_modules
dist
coverage
.env
**/vendor
**/*.pb.go

8
.prettierrc.cjs Normal file
View File

@@ -0,0 +1,8 @@
module.exports = {
arrowParens: 'always',
singleQuote: true,
trailingComma: 'all',
printWidth: 100,
useTabs: true,
semi: true,
};

19
LICENSE Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2025 Elijah Duffy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

7
README.md Normal file
View File

@@ -0,0 +1,7 @@
# health (monorepo)
This repository contains small helper libraries for liveness and readiness checks for different languages and runtimes.
## Structure
Repository root contains health packages for each different language or runtime, formatted `<technology>-health`.

1
go-health/README.md Normal file
View File

@@ -0,0 +1 @@
# go-health

3
go-health/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module gitea.auvem.com/end/health/go-health
go 1.25

1
go-health/health.go Normal file
View File

@@ -0,0 +1 @@
package health

10
node-health/.eslintrc.cjs Normal file
View File

@@ -0,0 +1,10 @@
module.exports = {
root: true,
extends: ['../../.eslintrc.cjs'],
parserOptions: {
project: './tsconfig.json',
},
rules: {
// package-level overrides
},
};

View File

@@ -0,0 +1 @@
module.exports = require('../.prettierrc.cjs');

1
node-health/README.md Normal file
View File

@@ -0,0 +1 @@
# @health/node

19
node-health/package.json Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "@health/node",
"version": "0.1.0",
"private": true,
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsc -p tsconfig.json",
"lint": "eslint --ext .ts,.js src",
"format": "prettier --write \"src/**/*.{ts,js,json}\"",
"test": "echo \"No tests configured\" && exit 0",
"check": "npm run lint && npm run build"
},
"dependencies": {},
"devDependencies": {}
}

30
node-health/src/index.ts Normal file
View File

@@ -0,0 +1,30 @@
/**
* Simple liveness & readiness helpers
*/
export type ReadinessResult = {
ok: boolean;
details: { name: string; ok: boolean; error?: string }[];
};
export function liveness() {
return {
status: 'ok',
timestamp: Date.now(),
};
}
export async function readiness(
checks: Array<{ name: string; fn: () => Promise<boolean> | boolean }>
): Promise<ReadinessResult> {
const results: ReadinessResult['details'] = [];
for (const c of checks) {
try {
const r = await Promise.resolve(c.fn());
results.push({ name: c.name, ok: !!r });
} catch (err: any) {
results.push({ name: c.name, ok: false, error: err?.message ?? String(err) });
}
}
return { ok: results.every((r) => r.ok), details: results };
}

View File

@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"composite": false
},
"include": ["src/**/*"]
}

15
tsconfig.base.json Normal file
View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES2021",
"module": "ES2020",
"moduleResolution": "node",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
}
}