Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: migrate to TS & add UT #6

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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