75 Commits

Author SHA1 Message Date
4fdbadd576 chore(deps): update dependency @vercel/style-guide to v6 2024-03-06 00:14:14 +00:00
Lee
edf96e4e64 Merge pull request 'chore(deps): update dependency tsup to v8' (#9) from renovate/tsup-8.x into master
All checks were successful
Publish Docker Images / docker (push) Successful in 2m17s
Reviewed-on: #9
2023-11-19 11:23:27 +00:00
72e3a62236 chore(deps): update dependency tsup to v8 2023-11-19 11:01:09 +00:00
ddfbb60b25 7
All checks were successful
Publish Docker Images / docker (push) Successful in 1m21s
2023-11-17 10:03:09 +00:00
eb116c06cd use boolean field for cached status
All checks were successful
Publish Docker Images / docker (push) Successful in 1m24s
2023-11-17 09:44:07 +00:00
74f5832a8a add cache status to all requests
All checks were successful
Publish Docker Images / docker (push) Successful in 1m22s
2023-11-17 09:31:06 +00:00
bde1fc4572 cleanup
All checks were successful
Publish Docker Images / docker (push) Successful in 1m32s
2023-11-17 09:17:12 +00:00
Lee
c0c0a3d5b0 Merge pull request 'fix(deps): update dependency mongoose to v8' (#8) from renovate/mongoose-8.x into master
All checks were successful
Publish Docker Images / docker (push) Successful in 1m44s
Reviewed-on: #8
2023-11-17 09:06:07 +00:00
Lee
095f13791a Merge pull request 'chore(deps): update docker/login-action action to v3' (#6) from renovate/docker-login-action-3.x into master
Some checks failed
Publish Docker Images / docker (push) Has been cancelled
Reviewed-on: #6
2023-11-17 09:06:00 +00:00
Lee
e8acd3b831 Merge pull request 'chore(deps): update docker/build-push-action action to v5' (#5) from renovate/docker-build-push-action-5.x into master
Some checks are pending
Publish Docker Images / docker (push) Waiting to run
Reviewed-on: #5
2023-11-17 09:05:55 +00:00
Lee
785eb27452 Merge pull request 'chore(deps): update actions/checkout action to v4' (#4) from renovate/actions-checkout-4.x into master
Some checks failed
Publish Docker Images / docker (push) Has been cancelled
Reviewed-on: #4
2023-11-17 09:05:49 +00:00
57d3aa3266 support any requests
All checks were successful
Publish Docker Images / docker (push) Successful in 1m56s
2023-11-17 09:03:05 +00:00
c32b0cfd05 fix
All checks were successful
Publish Docker Images / docker (push) Successful in 1m35s
2023-11-16 19:32:00 +00:00
5f7cdbf8d9 fix
Some checks failed
Publish Docker Images / docker (push) Has been cancelled
2023-11-16 19:31:44 +00:00
cb03d5aa42 forgot to update total reqs
All checks were successful
Publish Docker Images / docker (push) Successful in 1m21s
2023-11-16 19:23:28 +00:00
35cdef1942 load total reqs
All checks were successful
Publish Docker Images / docker (push) Successful in 1m21s
2023-11-16 19:20:05 +00:00
f989feb78b fuck you
All checks were successful
Publish Docker Images / docker (push) Successful in 1m20s
2023-11-16 19:16:12 +00:00
074f025c44 part 2
All checks were successful
Publish Docker Images / docker (push) Successful in 1m20s
2023-11-16 19:07:46 +00:00
8d902a03b9 fuck infisical
Some checks failed
Publish Docker Images / docker (push) Has been cancelled
2023-11-16 19:07:31 +00:00
f946ca2c5d secretssssssssssssss
All checks were successful
Publish Docker Images / docker (push) Successful in 1m22s
2023-11-16 18:36:10 +00:00
1e6ea9d104 fix secrets
All checks were successful
Publish Docker Images / docker (push) Successful in 1m26s
2023-11-16 18:32:28 +00:00
30e7158b7e fix secrets?
All checks were successful
Publish Docker Images / docker (push) Successful in 1m27s
2023-11-16 18:29:16 +00:00
49e97bb415 fix(deps): update dependency mongoose to v8 2023-11-16 18:01:52 +00:00
6003c2436a metrics!!!!!!!!!!!
All checks were successful
Publish Docker Images / docker (push) Successful in 1m52s
2023-11-16 17:52:44 +00:00
6b08b8fc7a add caching of responses (for 5mins)
Some checks failed
Publish Docker Images / docker (push) Failing after 7s
2023-11-16 15:54:59 +00:00
355a76845e headers
All checks were successful
Publish Docker Images / docker (push) Successful in 1m42s
2023-11-16 15:27:15 +00:00
804dc30830 heades
All checks were successful
Publish Docker Images / docker (push) Successful in 1m16s
2023-11-16 15:20:29 +00:00
7134ac0b39 yeet more headers
All checks were successful
Publish Docker Images / docker (push) Successful in 1m20s
2023-11-16 15:14:57 +00:00
b80fff586e yeet cors
All checks were successful
Publish Docker Images / docker (push) Successful in 1m17s
2023-11-16 15:10:06 +00:00
417ea7b84d fix log
All checks were successful
Publish Docker Images / docker (push) Successful in 1m13s
2023-11-16 14:42:34 +00:00
58645ec2b2 log requests
All checks were successful
Publish Docker Images / docker (push) Successful in 1m17s
2023-11-16 14:32:18 +00:00
4a3c26b7fa disable etags
All checks were successful
Publish Docker Images / docker (push) Successful in 1m18s
2023-11-16 14:09:55 +00:00
4402b42756 add error checking
All checks were successful
Publish Docker Images / docker (push) Successful in 1m16s
2023-11-16 14:03:04 +00:00
c9ec7f5912 7
All checks were successful
Publish Docker Images / docker (push) Successful in 1m41s
2023-11-16 13:47:06 +00:00
ea3ad8b898 7
Some checks failed
Publish Docker Images / docker (push) Failing after 28s
2023-11-16 13:42:05 +00:00
b5ba126e7c 7
Some checks failed
Publish Docker Images / docker (push) Failing after 23s
2023-11-16 13:40:06 +00:00
6675dc18f1 7
Some checks failed
Publish Docker Images / docker (push) Failing after 21s
2023-11-16 13:20:30 +00:00
5d63563c01 7
Some checks failed
Publish Docker Images / docker (push) Failing after 26s
2023-11-16 13:19:30 +00:00
45603ec02e 7
Some checks failed
Publish Docker Images / docker (push) Failing after 20s
2023-11-16 13:18:19 +00:00
cb29f2024f 7
Some checks failed
Publish Docker Images / docker (push) Failing after 20s
2023-11-16 13:17:23 +00:00
ebfb12a42d 7
Some checks failed
Publish Docker Images / docker (push) Failing after 21s
2023-11-16 13:11:02 +00:00
9001c161d8 7
Some checks failed
Publish Docker Images / docker (push) Failing after 21s
2023-11-16 13:09:43 +00:00
fe97190fab 7
Some checks failed
Publish Docker Images / docker (push) Failing after 21s
2023-11-16 13:07:42 +00:00
f51d05283d 7
All checks were successful
Publish Docker Images / docker (push) Successful in 46s
2023-11-16 13:03:59 +00:00
39b0a653ed 7
All checks were successful
Publish Docker Images / docker (push) Successful in 1m3s
2023-11-16 13:02:02 +00:00
bca3e284b2 chore(deps): update docker/login-action action to v3 2023-11-16 13:01:20 +00:00
660d23a2a4 7
All checks were successful
Publish Docker Images / docker (push) Successful in 42s
2023-11-16 12:59:24 +00:00
f237a28c27 7
Some checks failed
Publish Docker Images / docker (push) Has been cancelled
2023-11-16 12:58:48 +00:00
fa54ee276f 7
Some checks failed
Publish Docker Images / docker (push) Has been cancelled
2023-11-16 12:58:28 +00:00
074558e084 docker
Some checks failed
Publish Docker Images / docker (push) Has been cancelled
2023-11-16 12:58:15 +00:00
df3e9ee1c9 docker
All checks were successful
Publish Docker Images / docker (push) Successful in 1m6s
2023-11-16 12:54:49 +00:00
f54f381ef6 fix start cmd
All checks were successful
Publish Docker Images / docker (push) Successful in 42s
2023-11-16 12:52:09 +00:00
d47dab453b 7
All checks were successful
Publish Docker Images / docker (push) Successful in 1m15s
2023-11-16 12:49:58 +00:00
743db90a50 7
Some checks failed
Publish Docker Images / docker (push) Failing after 21s
2023-11-16 12:44:49 +00:00
667211d956 7
Some checks failed
Publish Docker Images / docker (push) Failing after 19s
2023-11-16 12:44:21 +00:00
a9f3467a57 7
Some checks failed
Publish Docker Images / docker (push) Failing after 14s
2023-11-16 12:43:26 +00:00
c130cb2be5 7
Some checks failed
Publish Docker Images / docker (push) Failing after 13s
2023-11-16 12:42:47 +00:00
d7a49ca544 7
Some checks failed
Publish Docker Images / docker (push) Failing after 14s
2023-11-16 12:36:55 +00:00
cb99bb2032 docker
Some checks failed
Publish Docker Images / docker (push) Failing after 13s
2023-11-16 12:32:38 +00:00
68a10da2a6 testing the test
Some checks failed
Publish Docker Images / docker (push) Failing after 15s
2023-11-16 12:24:38 +00:00
19b73af89d 7
Some checks failed
Publish Docker Images / docker (push) Failing after 25s
2023-11-16 12:22:37 +00:00
57841ebd74 7
Some checks failed
Publish Docker Images / docker (push) Failing after 25s
2023-11-16 12:22:10 +00:00
805c74ffc4 working that might work
Some checks failed
Publish Docker Images / docker (push) Failing after 13s
2023-11-16 12:21:07 +00:00
805e698668 ples work
All checks were successful
Publish Docker Images / docker (push) Successful in 40s
2023-11-16 12:16:52 +00:00
36d07fa8dd work that flows
Some checks failed
Publish Docker Images / docker (push) Failing after 19s
2023-11-16 12:01:54 +00:00
82c1b85c08 chore(deps): update docker/build-push-action action to v5 2023-11-16 12:01:22 +00:00
b8669f4128 chore(deps): update actions/checkout action to v4 2023-11-16 12:01:19 +00:00
2a8269a5d1 fix workflow
Some checks failed
Publish Docker Images / docker (push) Failing after 10s
2023-11-16 11:57:56 +00:00
d908a0fce5 add docker 2023-11-16 11:56:52 +00:00
1a2e217bbf Merge branch 'master' of https://git.fascinated.cc/Fascinated/proxy 2023-11-14 18:24:44 +00:00
11af27862d update readme 2023-11-14 18:24:43 +00:00
Lee
5ee3443086 Merge pull request 'chore(deps): update pnpm to v8.10.5' (#2) from renovate/pnpm-8.x into master
Reviewed-on: #2
2023-11-14 18:11:07 +00:00
e1f288996c chore(deps): update pnpm to v8.10.5 2023-11-14 18:09:40 +00:00
Lee
ccc8bb5119 Merge pull request 'chore: Configure Renovate' (#1) from renovate/configure into master
Reviewed-on: #1
2023-11-14 18:02:25 +00:00
43919014cc chore(deps): add renovate.json 2023-11-14 18:01:34 +00:00
45 changed files with 2667 additions and 1034 deletions

24
.dockerignore Normal file
View File

@ -0,0 +1,24 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

1
.env-example Normal file
View File

@ -0,0 +1 @@
INFISICAL_TOKEN=example

View File

@ -0,0 +1,42 @@
name: Publish Docker Images
on:
push:
branches:
- "master"
jobs:
docker:
runs-on: ubuntu-22.04
container: fascinated/docker-images:node-pnpm-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Repo
uses: docker/login-action@v3
with:
username: ${{ secrets.REPO_USERNAME }}
password: ${{ secrets.REPO_TOKEN }}
- name: Install dependencies
run: pnpm install
- name: Build Repo
run: pnpm run build
- name: Build and Push (Node)
uses: docker/build-push-action@v5
with:
push: true
context: .
file: ./apps/node/Dockerfile
tags: fascinated/proxy:node-latest
- name: Build and Push (Proxy)
uses: docker/build-push-action@v5
with:
push: true
context: .
file: ./apps/proxy/Dockerfile
tags: fascinated/proxy:proxy-latest

3
.gitignore vendored
View File

@ -34,3 +34,6 @@ yarn-error.log*
# vercel
.vercel
# Typescript compilied files
dist

15
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,15 @@
{
"configurations": [
{
"name": "Docker Node.js Launch",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"platform": "node",
"node": {
"package": "${workspaceFolder}/apps/node/package.json",
"localRoot": "${workspaceFolder}/apps/node"
}
}
]
}

42
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "docker-build",
"label": "docker-build",
"platform": "node",
"dockerBuild": {
"dockerfile": "${workspaceFolder}/apps/node/Dockerfile",
"context": "${workspaceFolder}/apps/node",
"pull": true
},
"node": {
"package": "${workspaceFolder}/apps/node/package.json"
}
},
{
"type": "docker-run",
"label": "docker-run: release",
"dependsOn": ["docker-build"],
"platform": "node",
"node": {
"package": "${workspaceFolder}/apps/node/package.json"
}
},
{
"type": "docker-run",
"label": "docker-run: debug",
"dependsOn": ["docker-build"],
"dockerRun": {
"env": {
"DEBUG": "*",
"NODE_ENV": "development"
}
},
"node": {
"package": "${workspaceFolder}/apps/node/package.json",
"enableDebugging": true
}
}
]
}

View File

@ -8,6 +8,11 @@ Go to <https://proxy.fascinated.cc>
## Development
Prerequisites:
- [pnpm](https://pnpm.io/)
- [Infiscal](https://secrets.fascinated.cc)
1. Create an Infiscal account at <https://secrets.fascinated.cc>
2. Add the the secret `PROXY_SECRET` with a random string
3. Clone this repo

24
apps/node/.dockerignore Normal file
View File

@ -0,0 +1,24 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

View File

@ -1,4 +1,4 @@
NODE_ID=1
API_PORT=3000
API_PORT=3001
INFISICAL_TOKEN=YOUR_TOKEN

42
apps/node/Dockerfile Normal file
View File

@ -0,0 +1,42 @@
FROM fascinated/docker-images:node-pnpm-latest AS base
# The web Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
# Make sure you update this Dockerfile, the Dockerfile in the web workspace and copy that over to Dockerfile in the docs.
FROM base AS builder
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
RUN apk update
# Set working directory
WORKDIR /app
RUN pnpm install -g turbo
COPY . .
RUN turbo prune node --docker
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
# First install dependencies (as they change less often)
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
RUN pnpm install
# Build the project and its dependencies
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
RUN pnpm run build --filter=node...
FROM base AS runner
WORKDIR /app
# Don't run production as root
RUN addgroup --system --gid 1001 expressjs
RUN adduser --system --uid 1001 expressjs
USER expressjs
COPY --from=installer /app .
CMD node apps/node/dist/index.js

View File

@ -1,241 +0,0 @@
{
"name": "node",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "node",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
}
},
"../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript": {
"version": "5.2.2",
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"devDependencies": {
"@esfx/canceltoken": "^1.0.0",
"@octokit/rest": "^19.0.13",
"@types/chai": "^4.3.4",
"@types/fs-extra": "^9.0.13",
"@types/glob": "^8.1.0",
"@types/microsoft__typescript-etw": "^0.1.1",
"@types/minimist": "^1.2.2",
"@types/mocha": "^10.0.1",
"@types/ms": "^0.7.31",
"@types/node": "latest",
"@types/source-map-support": "^0.5.6",
"@types/which": "^2.0.1",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@typescript-eslint/utils": "^6.0.0",
"azure-devops-node-api": "^12.0.0",
"c8": "^7.14.0",
"chai": "^4.3.7",
"chalk": "^4.1.2",
"chokidar": "^3.5.3",
"del": "^6.1.1",
"diff": "^5.1.0",
"esbuild": "^0.18.1",
"eslint": "^8.22.0",
"eslint-formatter-autolinkable-stylish": "^1.2.0",
"eslint-plugin-local": "^1.0.0",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-simple-import-sort": "^10.0.0",
"fast-xml-parser": "^4.0.11",
"fs-extra": "^9.1.0",
"glob": "^8.1.0",
"hereby": "^1.6.4",
"jsonc-parser": "^3.2.0",
"minimist": "^1.2.8",
"mocha": "^10.2.0",
"mocha-fivemat-progress-reporter": "^0.1.0",
"ms": "^2.1.3",
"node-fetch": "^3.2.10",
"source-map-support": "^0.5.21",
"tslib": "^2.5.0",
"typescript": "^5.0.2",
"which": "^2.0.2"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/@cspotcode/source-map-support": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
"integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
"dependencies": {
"@jridgewell/trace-mapping": "0.3.9"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@jridgewell/resolve-uri": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz",
"integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==",
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@jridgewell/sourcemap-codec": {
"version": "1.4.15",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
"integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg=="
},
"node_modules/@jridgewell/trace-mapping": {
"version": "0.3.9",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
"integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
"dependencies": {
"@jridgewell/resolve-uri": "^3.0.3",
"@jridgewell/sourcemap-codec": "^1.4.10"
}
},
"node_modules/@tsconfig/node10": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz",
"integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA=="
},
"node_modules/@tsconfig/node12": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
"integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag=="
},
"node_modules/@tsconfig/node14": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
"integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow=="
},
"node_modules/@tsconfig/node16": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz",
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA=="
},
"node_modules/@types/node": {
"version": "20.9.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz",
"integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==",
"peer": true,
"dependencies": {
"undici-types": "~5.26.4"
}
},
"node_modules/acorn": {
"version": "8.11.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz",
"integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==",
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/acorn-walk": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.0.tgz",
"integrity": "sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA==",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/arg": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA=="
},
"node_modules/create-require": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ=="
},
"node_modules/diff": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
"engines": {
"node": ">=0.3.1"
}
},
"node_modules/make-error": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw=="
},
"node_modules/ts-node": {
"version": "10.9.1",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz",
"integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==",
"dependencies": {
"@cspotcode/source-map-support": "^0.8.0",
"@tsconfig/node10": "^1.0.7",
"@tsconfig/node12": "^1.0.7",
"@tsconfig/node14": "^1.0.0",
"@tsconfig/node16": "^1.0.2",
"acorn": "^8.4.1",
"acorn-walk": "^8.1.1",
"arg": "^4.1.0",
"create-require": "^1.1.0",
"diff": "^4.0.1",
"make-error": "^1.1.1",
"v8-compile-cache-lib": "^3.0.1",
"yn": "3.1.1"
},
"bin": {
"ts-node": "dist/bin.js",
"ts-node-cwd": "dist/bin-cwd.js",
"ts-node-esm": "dist/bin-esm.js",
"ts-node-script": "dist/bin-script.js",
"ts-node-transpile-only": "dist/bin-transpile.js",
"ts-script": "dist/bin-script-deprecated.js"
},
"peerDependencies": {
"@swc/core": ">=1.2.50",
"@swc/wasm": ">=1.2.50",
"@types/node": "*",
"typescript": ">=2.7"
},
"peerDependenciesMeta": {
"@swc/core": {
"optional": true
},
"@swc/wasm": {
"optional": true
}
}
},
"node_modules/typescript": {
"resolved": "../../node_modules/.pnpm/typescript@5.2.2/node_modules/typescript",
"link": true
},
"node_modules/undici-types": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"peer": true
},
"node_modules/v8-compile-cache-lib": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
"integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg=="
},
"node_modules/yn": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
"engines": {
"node": ">=6"
}
}
}
}

View File

@ -6,15 +6,17 @@
"author": "fascinated",
"license": "MIT",
"scripts": {
"build": "tsc",
"build": "tsup src/index.ts --format cjs,esm --dts",
"start": "node dist/index.js",
"dev": "nodemon --exec ts-node src/index.ts"
},
"dependencies": {
"axios": "^1.6.1",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"server": "workspace:*",
"utils": "workspace:*",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
"typescript": "^5.2.2",
"utils": "workspace:*"
}
}

View File

@ -9,6 +9,7 @@ export default class ProxyRoute extends Route {
}
async handle(req: Request, res: Response) {
const before = Date.now();
const json = req.body;
const secret = json.secret;
if (!secret) {
@ -25,31 +26,50 @@ export default class ProxyRoute extends Route {
res.status(400).json(RouteMessages.badRequest("No URL provided"));
return;
}
// TODO: handle rate limiting? and/or caching?
const response = await axios.get(url, {
headers: {
"Content-Type": "application/json",
},
});
const data = response.data;
const headers = response.headers;
try {
const response = await axios.get(url);
const data = response.data;
const headers = response.headers;
// Is delete the best way to do this??
// Remove CORS headers
delete headers["access-control-allow-origin"];
delete headers["access-control-allow-credentials"];
delete headers["access-control-allow-headers"];
delete headers["access-control-allow-methods"];
// Is delete the best way to do this??
// Remove CORS headers
delete headers["access-control-allow-origin"];
delete headers["access-control-allow-credentials"];
delete headers["access-control-allow-headers"];
delete headers["access-control-allow-methods"];
delete headers["access-control-expose-headers"];
delete headers["cross-origin-embedder-policy"];
delete headers["cross-origin-opener-policy"];
delete headers["cross-origin-resource-policy"];
// Cloudflare headers
delete headers["server"];
delete headers["nel"];
delete headers["report-to"];
delete headers["cf-cache-status"];
delete headers["cf-ray"];
delete headers["alt-svc"];
// Cloudflare headers
delete headers["server"];
delete headers["nel"];
delete headers["report-to"];
delete headers["cf-cache-status"];
delete headers["cf-ray"];
delete headers["alt-svc"];
// Return the JSON response
res.status(response.status).set(headers).json(data);
// Misc headers
delete headers["transfer-encoding"];
delete headers["content-security-policy"];
delete headers["strict-transport-security"];
delete headers["referrer-policy"];
// Add node specific headers
headers["x-proxy-node"] = process.env.NODE_ID;
headers["x-proxy-response-time"] = Date.now() - before + "ms";
// Add CORS headers
headers["access-control-allow-origin"] = "*";
headers["access-control-allow-methods"] = "*";
// Return the JSON response
res.status(response.status).set(headers).send(data);
} catch (ex) {
res
.status(500)
.json(RouteMessages.internalServerError("Error fetching URL"));
}
}
}

View File

@ -1,3 +1,4 @@
import { GetOptions } from "infisical-node/lib/types/InfisicalClient";
import { createInfisicalClient } from "utils";
export let PROXY_SECRET: string;
@ -9,7 +10,13 @@ export async function initSecrets(token: string) {
console.log("Initializing secrets...");
const infisicalClient = createInfisicalClient(token);
const proxySecret = (await infisicalClient.getSecret("PROXY_SECRET"))
const options: GetOptions = {
environment: process.env.NODE_ENV === "production" ? "main" : "dev",
path: "/",
type: "shared",
};
const proxySecret = (await infisicalClient.getSecret("PROXY_SECRET", options))
.secretValue;
if (!proxySecret) {

View File

@ -1,7 +1,3 @@
{
"extends": "tsconfig/server.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
}
"extends": "tsconfig/server.json"
}

24
apps/proxy/.dockerignore Normal file
View File

@ -0,0 +1,24 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

2
apps/proxy/.env-example Normal file
View File

@ -0,0 +1,2 @@
API_PORT=3000
INFISICAL_TOKEN=YOUR_TOKEN

39
apps/proxy/Dockerfile Normal file
View File

@ -0,0 +1,39 @@
FROM fascinated/docker-images:node-pnpm-latest AS base
# The web Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
# Make sure you update this Dockerfile, the Dockerfile in the web workspace and copy that over to Dockerfile in the docs.
FROM base AS builder
# Set working directory
WORKDIR /app
RUN pnpm install -g turbo
COPY . .
RUN turbo prune proxy --docker
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
# First install dependencies (as they change less often)
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
RUN pnpm install
# Build the project and its dependencies
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
RUN pnpm run build --filter=proxy...
FROM base AS runner
WORKDIR /app
# Don't run production as root
RUN addgroup --system --gid 1001 expressjs
RUN adduser --system --uid 1001 expressjs
USER expressjs
COPY --from=installer /app .
CMD node apps/proxy/dist/index.js

25
apps/proxy/package.json Normal file
View File

@ -0,0 +1,25 @@
{
"name": "proxy",
"version": "1.0.0",
"description": "The proxy server for the project",
"main": "dist/index.js",
"author": "fascinated",
"license": "MIT",
"scripts": {
"build": "tsup src/index.ts --format cjs,esm --dts",
"start": "node dist/index.js",
"dev": "nodemon --exec ts-node src/index.ts"
},
"dependencies": {
"axios": "^1.6.1",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"server": "workspace:*",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"utils": "workspace:*",
"node-cache": "^5.1.2",
"@influxdata/influxdb-client": "^1.33.2",
"mongoose": "^8.0.0"
}
}

View File

@ -0,0 +1,11 @@
import mongoose, { Model } from "mongoose";
const { Schema } = mongoose;
const metricsSchema = new Schema({
_id: String,
totalRequests: Number,
});
export const MetricsSchema =
(mongoose.models.Metrics as Model<typeof metricsSchema>) ||
mongoose.model("Metrics", metricsSchema);

View File

@ -0,0 +1,18 @@
import mongoose from "mongoose";
/**
* Creates a connection to Mongo
*
* @param uri the URI of the mongo instance
* @returns the mongoose connection
*/
export async function connectMongo(uri: string) {
// Check if mongoose is already connected
if (mongoose.connection.readyState) {
return;
}
return mongoose.connect(uri, {
autoCreate: true,
family: 4,
});
}

69
apps/proxy/src/index.ts Normal file
View File

@ -0,0 +1,69 @@
import { QueryApi, WriteApi } from "@influxdata/influxdb-client";
import dotenv from "dotenv";
import { RouteManager, RouteMessages, createServer } from "server";
import { checkEnvironmentVariables, createInfluxClient } from "utils";
import { connectMongo } from "./db/mongo";
import NodeManager from "./node/nodeManager";
import ProxyRoute from "./routes/proxy";
import {
INFLUXDB_BUCKET,
INFLUXDB_ORG,
INFLUXDB_TOKEN,
INFLUXDB_URL,
MONGO_URI,
initSecrets,
} from "./secrets";
dotenv.config(); // load .env file
// Check environment variables
const envVarsValid = checkEnvironmentVariables("API_PORT", "INFISICAL_TOKEN");
if (!envVarsValid) {
process.exit(1);
}
export let InfluxWriteApi: WriteApi;
export let InfluxQueryApi: QueryApi;
/**
* The node manager for all of the loaded nodes
*/
export const nodeManager = new NodeManager();
(async () => {
await initSecrets(process.env.INFISICAL_TOKEN!); // Load the infisical secrets
// Init MongoDB
await connectMongo(MONGO_URI);
const routeManager = new RouteManager();
routeManager.addRoute(new ProxyRoute());
// Init InfluxDB
const influxClient = createInfluxClient(
INFLUXDB_TOKEN,
INFLUXDB_URL,
INFLUXDB_ORG,
INFLUXDB_BUCKET
);
if (!influxClient) {
console.log("Influx client failed to initialize, exiting...");
process.exit(1);
}
InfluxWriteApi = influxClient.influxWriteClient;
InfluxQueryApi = influxClient.influxQueryClient;
const server = createServer({
port: process.env.API_PORT || 3000,
});
server.all("*", (req, res) => {
// Handle all paths to the proxy route
const routes = routeManager.getRoutes();
if (!routes || routes.length === 0 || !routes[0]) {
res.status(500).json(RouteMessages.internalServerError("No routes"));
return;
}
routes[0].handle(req, res);
});
})();

View File

@ -0,0 +1,48 @@
import axios from "axios";
import { PROXY_SECRET } from "../secrets";
type NodeOptions = {
/**
* The URL to node
*/
url: string;
};
export default class Node {
/**
* The URL to node
*/
private url: string;
constructor({ url }: NodeOptions) {
this.url = url;
// todo: ping node and check status
}
/**
* Get the URL to node
*
* @returns the URL
*/
getUrl() {
return this.url;
}
/**
* Fetch a URL from the node.
* The node will fetch the URL and return the response.
*
* @param url the URL to fetch
*/
async fetch(url: string) {
const response = await axios.get(this.getUrl() + "/proxy", {
data: {
url: url,
secret: PROXY_SECRET,
},
});
return response;
}
}

View File

@ -0,0 +1,28 @@
import Node from "./node";
export default class NodeManager {
/**
* The nodes
*/
private nodes: Node[];
constructor() {
const nodes = process.env.NODES;
if (!nodes) {
throw new Error("No nodes found in environment variable");
}
const nodeUrls = nodes.split(",");
this.nodes = nodeUrls.map((url) => new Node({ url }));
}
/**
* Get a random node
*
* @returns the node
*/
getRandomNode() {
const index = Math.floor(Math.random() * this.nodes.length);
return this.nodes[index];
}
}

View File

@ -0,0 +1,177 @@
import { Point } from "@influxdata/influxdb-client";
import { Request, Response } from "express";
import Cache from "node-cache";
import { Route, RouteMessages } from "server";
import { InfluxWriteApi, nodeManager } from "..";
import { MetricsSchema } from "../db/metrics";
const IGNORED_PATHS = ["/favicon.ico"];
/**
* The total requests that have been made
* TODO: move this to a metrics file
*/
let totalRequests: number | undefined = undefined;
const cache = new Cache({
stdTTL: 300, // 5 minutes
});
type CachedRequest = {
nodeId: string;
status: number;
headers: any;
data: any;
};
/**
* Logs a request
*
* @param nodeId the node ID that handled the request
* @param url the URL of the request
* @param status the status code of the request
* @param time the time it took to handle the request (or true if it was cached)
*/
function log(
nodeId: string,
url: string,
status: number,
time: number | boolean
) {
console.log(
`[node: ${nodeId}] ${url} - ${status} (${
time === true ? "cached" : time + "ms"
})`
);
}
type InfluxLog = {
nodeId: string;
url: string;
status: number;
time?: number;
cached?: boolean;
};
/**
* Creates an InfluxDB point and writes it to the database
*
* @param nodeId the node ID that handled the request
* @param url the URL of the request
* @param status the status code of the request
* @param time the time it took to handle the request (or true if it was cached)
*/
async function logRequestToDatabase({
nodeId,
url,
status,
time,
cached,
}: InfluxLog) {
if (totalRequests === undefined) {
const metrics: any = await MetricsSchema.findOne({ _id: "proxy" }).exec();
if (metrics) {
totalRequests = metrics.totalRequests as number;
} else {
totalRequests = 0;
}
}
totalRequests++;
MetricsSchema.updateOne(
{ _id: "proxy" },
{ $set: { totalRequests: totalRequests } },
{ upsert: true }
).exec();
const point = new Point("proxy")
.tag("type", "request")
.tag("node", nodeId)
.booleanField("cached", cached ? true : false)
.stringField("url", url)
.intField("status", status)
.timestamp(Date.now());
if (time) {
point.intField("time", time);
}
try {
InfluxWriteApi.writePoint(point);
InfluxWriteApi.writePoint(
new Point("proxy")
.intField("totalRequests", totalRequests)
.timestamp(Date.now())
);
} catch (ex) {
console.log("Failed to write to influx");
console.log(ex);
}
}
export default class ProxyRoute extends Route {
constructor() {
super({ path: "/" });
}
async handle(req: Request, res: Response) {
const url = req.url.substring(1);
if (!url) {
res.status(400).json(RouteMessages.badRequest("No URL provided"));
return;
}
if (IGNORED_PATHS.includes(url)) {
res.status(404).send("Not found");
return;
}
try {
const cachedRequest = cache.get<CachedRequest>(url);
if (cachedRequest) {
const { status, headers, data, nodeId } = cachedRequest;
res.status(status).set(headers).json(data);
log(nodeId, url, status, true);
return logRequestToDatabase({
nodeId: nodeId,
url,
status: status,
cached: true,
});
}
const node = nodeManager.getRandomNode();
if (!node) {
res
.status(500)
.json(RouteMessages.internalServerError("No nodes available"));
return;
}
const before = Date.now();
const response = await node.fetch(url);
const nodeId = response.headers["x-proxy-node"];
const { status, headers, data } = response;
if (response.status === 500) {
res.status(500).json(RouteMessages.internalServerError(data));
return;
}
log(nodeId, url, status, Date.now() - before);
logRequestToDatabase({
nodeId,
url,
status: status,
time: Date.now() - before,
cached: false,
});
cache.set(url, {
nodeId: nodeId,
status: status,
headers: headers,
data: data,
} as CachedRequest);
// Send the response to the client
res.status(status).set(headers).send(data);
} catch (ex: any) {
res.status(500).json(RouteMessages.internalServerError(ex.message || ex));
}
}
}

80
apps/proxy/src/secrets.ts Normal file
View File

@ -0,0 +1,80 @@
import { GetOptions } from "infisical-node/lib/types/InfisicalClient";
import { createInfisicalClient } from "utils";
export let PROXY_SECRET: string;
// InfluxDB
export let INFLUXDB_URL: string;
export let INFLUXDB_ORG: string;
export let INFLUXDB_BUCKET: string;
export let INFLUXDB_TOKEN: string;
// MongoDB
export let MONGO_URI: string;
/**
* Initialize the secrets from Infisical
*/
export async function initSecrets(token: string) {
console.log("Initializing secrets...");
const infisicalClient = createInfisicalClient(token);
const options: GetOptions = {
environment: process.env.NODE_ENV === "production" ? "main" : "dev",
path: "/",
type: "shared",
};
const proxySecret = (await infisicalClient.getSecret("PROXY_SECRET", options))
.secretValue;
// InfluxDB
const influxDBUrl = (await infisicalClient.getSecret("INFLUXDB_URL", options))
.secretValue;
const influxDBOrg = (await infisicalClient.getSecret("INFLUXDB_ORG", options))
.secretValue;
const influxDBBucket = (
await infisicalClient.getSecret("INFLUXDB_BUCKET", options)
).secretValue;
const influxDBToken = (
await infisicalClient.getSecret("INFLUXDB_TOKEN", options)
).secretValue;
// Mongo
const mongoUri = (await infisicalClient.getSecret("MONGO_URI", options))
.secretValue;
if (!proxySecret) {
throw new Error("PROXY_SECRET not set in Infisical");
}
// InfluxDB
if (!influxDBUrl) {
throw new Error("INFLUXDB_URL not set in Infisical");
}
if (!influxDBOrg) {
throw new Error("INFLUXDB_ORG not set in Infisical");
}
if (!influxDBBucket) {
throw new Error("INFLUXDB_BUCKET not set in Infisical");
}
if (!influxDBToken) {
throw new Error("INFLUXDB_TOKEN not set in Infisical");
}
// Mongo
if (!mongoUri) {
throw new Error("MONGO_URI not set in Infisical");
}
PROXY_SECRET = proxySecret;
// InfluxDB
INFLUXDB_URL = influxDBUrl;
INFLUXDB_ORG = influxDBOrg;
INFLUXDB_BUCKET = influxDBBucket;
INFLUXDB_TOKEN = influxDBToken;
// Mongo
MONGO_URI = mongoUri;
}

6
apps/proxy/tsconfig.json Normal file
View File

@ -0,0 +1,6 @@
{
"extends": "tsconfig/server.json",
"compilerOptions": {
"esModuleInterop": true
}
}

38
docker-compose.yml Normal file
View File

@ -0,0 +1,38 @@
version: "3.8"
services:
proxy:
image: fascinated/proxy:proxy-latest
container_name: Proxy
restart: always
ports:
- 3000:3000
environment:
API_PORT: 3000
INFISICAL_TOKEN: ${INFISICAL_TOKEN}
# Add your nodes here (eg: http://localhost:3001,http://localhost:3002, etc.)
NODES: http://node-1:3000,http://node-2:3000
node-1:
image: fascinated/proxy:node-latest
container_name: Node_1
restart: always
# Uncomment the ports if you want to access the node directly
#ports:
# - 3000:3000
environment:
API_PORT: 3000
INFISICAL_TOKEN: ${INFISICAL_TOKEN}
NODE_ID: 1
node-2:
image: fascinated/proxy:node-latest
container_name: Node_2
restart: always
# Uncomment the ports if you want to access the node directly
#ports:
# - 3000:3000
environment:
API_PORT: 3000
INFISICAL_TOKEN: ${INFISICAL_TOKEN}
NODE_ID: 1

View File

@ -1,5 +1,7 @@
{
"name": "proxy",
"private": true,
"packageManager": "pnpm@8.10.5",
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev",
@ -7,18 +9,19 @@
"format": "prettier --write \"**/*.{ts,tsx,md}\""
},
"devDependencies": {
"@influxdata/influxdb-client": "^1.33.2",
"dotenv": "^16.3.1",
"eslint": "^8.48.0",
"express": "^4.18.2",
"infisical-node": "^1.5.0",
"node-cache": "^5.1.2",
"nodemon": "^3.0.1",
"prettier": "^3.0.3",
"tsconfig": "workspace:*",
"tsup": "^8.0.0",
"turbo": "latest"
},
"packageManager": "pnpm@8.9.0",
"name": "proxy",
"dependencies": {
"@types/express": "^4.17.21",
"infisical-node": "^1.5.0"
"mongoose": "8.0.1"
}
}

View File

@ -4,7 +4,7 @@
"version": "0.0.0",
"private": true,
"devDependencies": {
"@vercel/style-guide": "^5.0.0",
"@vercel/style-guide": "^6.0.0",
"eslint-config-turbo": "^1.10.12",
"typescript": "^5.2.2"
}

View File

@ -6,6 +6,14 @@
"publishConfig": {
"access": "public"
},
"main": "./src/index.ts",
"types": "./src/index.ts"
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"dependencies": {
"express": "^4.18.2"
},
"scripts": {
"build": "tsup src/index.ts --format cjs,esm --dts",
"dev": "tsup src/index.ts --format cjs,esm --dts --watch"
}
}

View File

@ -1,9 +1,11 @@
import { badRequest } from "./messages/badRequest";
import { internalServerError } from "./messages/internalServerError";
import { unknownRoute } from "./messages/unknownRoute";
export const RouteMessages = {
unknownRoute: unknownRoute,
badRequest: badRequest,
internalServerError: internalServerError,
};
export * from "./route/route";

View File

@ -0,0 +1,10 @@
import { baseMessage } from "./baseMessage";
/**
* Creates a response for an internal server error
*
* @returns the internal server error message
*/
export function internalServerError(message: string) {
return baseMessage(true, message);
}

View File

@ -19,7 +19,7 @@ export class RouteManager {
* @returns the route or undefined if not found
*/
getRoute(path: string) {
return this.routes.find((route) => route.getPath() === path);
return this.routes.find((route) => path.startsWith(route.getPath()));
}
/**

View File

@ -1,4 +1,4 @@
import express from "express";
import express, { Express } from "express";
type ServerType = {
/**
@ -10,7 +10,7 @@ type ServerType = {
onLoaded?: () => void;
};
export function createServer({ port = 3000, onLoaded }: ServerType) {
export function createServer({ port = 3000, onLoaded }: ServerType): Express {
if (typeof port === "string") {
port = Number(port);
if (isNaN(port)) {
@ -25,8 +25,8 @@ export function createServer({ port = 3000, onLoaded }: ServerType) {
// Remove the X-Powered-By header
server.disable("x-powered-by");
// Turn on ETag support (for caching)
server.enable("etag");
// Remove the ETag header (so that the client doesn't cache the response)
server.disable("etag");
// Listen on the specified port
server.listen(port, () => {

View File

@ -1,7 +1,3 @@
{
"extends": "tsconfig/server.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
}
"extends": "tsconfig/server.json"
}

View File

@ -14,5 +14,5 @@
"noEmit": true,
"lib": ["es2022", "dom", "dom.iterable"]
},
"exclude": ["node_modules"]
"exclude": ["node_modules", "dist"]
}

View File

@ -6,6 +6,11 @@
"publishConfig": {
"access": "public"
},
"main": "./src/index.ts",
"types": "./src/index.ts"
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"scripts": {
"build": "tsup src/index.ts --format cjs,esm --dts",
"dev": "tsup src/index.ts --format cjs,esm --dts --watch"
}
}

View File

@ -1,2 +1,3 @@
export * from "./envVariables";
export * from "./secrets";
export * from "./influx/influx";
export * from "./secrets/secrets";

View File

@ -0,0 +1,29 @@
import { InfluxDB } from "@influxdata/influxdb-client";
/**
* Creates an InfluxDB client
*
* @param token the influx token
* @param url the url of the influx instance
* @param org the org of the influx instance
* @param bucket the bucket of the influx instance
* @returns
*/
function createInfluxClient(
token: string,
url: string,
org: string,
bucket: string
) {
const client = new InfluxDB({
url: url,
token: token,
});
return {
influxWriteClient: client.getWriteApi(org, bucket, "ms"),
influxQueryClient: client.getQueryApi(org),
};
}
export { createInfluxClient };

View File

@ -1,7 +1,3 @@
{
"extends": "tsconfig/server.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
}
"extends": "tsconfig/server.json"
}

2494
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

6
renovate.json Normal file
View File

@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>Fascinated/renovate-config"
]
}

View File

@ -3,8 +3,8 @@
"globalDependencies": ["**/.env"],
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": [".next/**", "!.next/cache/**"]
"outputs": ["dist/**"],
"dependsOn": ["^build"]
},
"lint": {},
"dev": {