Skip to content

Commit

Permalink
refactor: migrate to TS & add UT (#6)
Browse files Browse the repository at this point in the history
chore: complete docs

ci: setup Node.js GA workflow

chore: finalize TS & UT

Update package.json

Co-authored-by: PierreDemailly <[email protected]>
  • Loading branch information
fraxken and PierreDemailly committed Mar 27, 2024
1 parent 7076257 commit 88147d9
Show file tree
Hide file tree
Showing 16 changed files with 1,765 additions and 160 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Node.js CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit

- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Under the hood it use Grafana `/api/auth/keys` API to validate the token and the
$ git clone https://github.com/MyUnisoft/loki-reverse-proxy.git
$ cd loki-reverse-proxy
$ npm ci
$ npm run build
```

### Environment Variables
Expand All @@ -21,7 +22,10 @@ To configure the project you have to register (set) environment variables on you
```ini
GRAFANA_URL=""
LOKI_URL=""
SERVER_PORT=3000
SERVER_PORT=4000
SERVER_SSL_ENABLED=false
# Enable if behind a proxy like Nginx or Haproxy
TRUST_PROXY=false
```

### Let's go baby 🔥
Expand All @@ -35,15 +39,15 @@ $ npm start
Here is the full Zod schema for envs:

```js
const kEnvSchema = z.object({
const envSchema = z.object({
GRAFANA_URL: z.string().url().trim(),
LOKI_URL: z.string().url().trim(),
TOKEN_CACHE_MS: z.coerce.number().default(1_000 * 60 * 5),
SERVER_PORT: z.coerce.number().default(0),
TOKEN_CACHE_MS: z.coerce.number().optional().default(1_000 * 60 * 5),
SERVER_PORT: z.coerce.number().optional().default(0),
SERVER_SSL_ENABLED: z.boolean().optional().default(false),
SERVER_SSL_CERT: z.string().optional(),
SERVER_SSL_KEY: z.string().optional(),
TRUST_PROXY: z.boolean().default(false)
TRUST_PROXY: z.boolean().optional().default(false)
});
```

Expand Down
Loading

0 comments on commit 88147d9

Please sign in to comment.