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

nodejs rewrite #13

Merged
merged 42 commits into from
May 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
313d051
first draft
StarpTech Apr 28, 2021
7b362fd
fix test suite, add tests
StarpTech Apr 28, 2021
5cc063e
pass database url as arg to prisma client
StarpTech Apr 28, 2021
f2a3a67
create db per test, update ci script
StarpTech Apr 29, 2021
e44b3fc
fix tests
StarpTech Apr 30, 2021
53a5bea
clean after test
StarpTech Apr 30, 2021
67b5acf
move to json schema, clean readme
StarpTech May 1, 2021
ee209cd
time safe password comparison, public and private route scopes
StarpTech May 1, 2021
3a61085
rename
StarpTech May 1, 2021
b40a4ed
fix typo
StarpTech May 1, 2021
e73405c
register missing routes, add dockerfile
StarpTech May 1, 2021
50192c0
restructure
StarpTech May 1, 2021
f1f505c
fix benchmark, run on 0.0.0.0 for better k8s, compose support
StarpTech May 1, 2021
3368ce8
..
StarpTech May 1, 2021
b999606
add more tests
StarpTech May 1, 2021
31ac063
add tests
StarpTech May 1, 2021
e88d203
format, create db schema in ci
StarpTech May 1, 2021
b48adcd
delete unused code
StarpTech May 1, 2021
73fa0fb
implement authorization based on jwt
StarpTech May 1, 2021
b783e19
remove auth for bench
StarpTech May 1, 2021
d7982ce
test
StarpTech May 1, 2021
557daf3
test
StarpTech May 1, 2021
4c9fe40
..
StarpTech May 1, 2021
1e4a549
..
StarpTech May 1, 2021
a20caba
add benchmark workflow
StarpTech May 1, 2021
2d903ee
create schema
StarpTech May 1, 2021
788df86
..
StarpTech May 1, 2021
633b48f
..
StarpTech May 1, 2021
5c40338
test
StarpTech May 1, 2021
8826d20
...
StarpTech May 1, 2021
9e6b18e
consistent error responses
StarpTech May 1, 2021
9d26bba
add response schema to register endpoint, use 120 printwidth
StarpTech May 1, 2021
1b9db47
validate env
StarpTech May 1, 2021
dfa36df
validate env only
StarpTech May 1, 2021
6f453da
remove import
StarpTech May 1, 2021
b502367
rename schem version to tag, check if schema tag already exists
StarpTech May 2, 2021
31b1c22
add indexes, introduce custom error types
StarpTech May 2, 2021
24fd8fc
move hook to seperate file, add more response schemas
StarpTech May 2, 2021
606d750
add pecommit hook
StarpTech May 2, 2021
de9a36b
test
StarpTech May 2, 2021
db7932d
test
StarpTech May 2, 2021
0d90702
test
StarpTech May 2, 2021
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
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
npm-debug.log
coverage
.env
/.github
/.vscode
/build
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATABASE_URL="postgresql://postgres:changeme@localhost:5440/graphql-registry?schema=public"
BASIC_AUTH=123,456
JWT_SECRET=secret
61 changes: 61 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: BENCH

on:
push:
paths:
- '!**.md'
- '!*.md'
branches:
- '**'
tags-ignore:
- '**'

pull_request:
branches:
- '**'

jobs:
test:
name: Node.js v${{ matrix.nodejs }}
runs-on: ubuntu-latest
strategy:
matrix:
nodejs: [14]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.nodejs }}

- name: (env) cache
uses: actions/cache@v2
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Start services
run: |
docker-compose up -d
./scripts/wait-for-healthy-container.sh postgres 30

- name: Install
run: npm ci --prefer-offline --no-audit

- name: Create db schema
run: DATABASE_URL="postgresql://postgres:changeme@localhost:5440/graphql-registry?schema=public" npx prisma db push --preview-feature

- name: Build app image
run: docker-compose up -d app

- name: Bench
run: |
docker-compose run k6 run /benchmark/composed-schema.js

- name: Clean services
if: always()
run: docker-compose down
62 changes: 34 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,38 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
nodejs: [14, 16]
nodejs: [14]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.nodejs }}

- name: (env) cache
uses: actions/cache@v2
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Install
run: npm install

- name: Run Tests
run: npm test

- name: Check Types
run: npm run types

- name: Compiles
run: npm run build
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.nodejs }}

- name: Start services
run: |
docker-compose up -d
./scripts/wait-for-healthy-container.sh postgres 30

- name: (env) cache
uses: actions/cache@v2
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Install
run: npm ci --prefer-offline --no-audit

- name: Run Tests
run: npm test

- name: Compiles
run: npm run build

- name: Clean services
if: always()
run: docker-compose down
49 changes: 0 additions & 49 deletions .github/workflows/deploy.yml

This file was deleted.

10 changes: 1 addition & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
/target
/dist
**/*.rs.bk
Cargo.lock
pkg/
/build
wasm-pack.log
worker/
node_modules/
.cargo-ok
/.nyc_output
coverage
wrangler.toml
.env
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
6 changes: 6 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm test

npx --yes pretty-quick
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"semi": false,
"trailingComma": "all",
"tabWidth": 2,
"printWidth": 80
"printWidth": 120
}
5 changes: 1 addition & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ava",
"runtimeArgs": ["--serial", "${file}"],
"outputCapture": "std",
"skipFiles": [
"<node_internals>/**/*.js",
"${workspaceFolder}/node_modules/**/*.js"
]
"skipFiles": ["<node_internals>/**/*.js", "${workspaceFolder}/node_modules/**/*.js"]
}
]
}
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:14-alpine as builder

WORKDIR /usr/src/app

COPY package*.json ./

COPY prisma ./

RUN npm ci

COPY . .

RUN npm run build

RUN npm prune --production

FROM node:14-alpine as runner

COPY --from=builder /usr/src/app/node_modules node_modules
COPY --from=builder /usr/src/app/build build
COPY --from=builder /usr/src/app/package.json .

EXPOSE 3000

CMD [ "node", "build/index.js" ]

Loading