-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
10,993 additions
and
1,855 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE DATABASE test OWNER user123; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
DEXCOM_USERNAME=exampleUsername | ||
DEXCOM_PASSWORD=examplePassword | ||
DEXCOM_APPLICATION_ID=d89443d2-327c-4a6f-89e5-496bbb0317db | ||
DEXCOM_USER_LOCATION=EU | ||
|
||
DATABASE_HOST=exampleHost | ||
DATABASE_PORT=8080 | ||
DATABASE_USER=exampleUser | ||
DATABASE_PASSWORD=examplePassword | ||
DATABASE_NAME=exampleDbName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
DEXCOM_USERNAME=test | ||
DEXCOM_PASSWORD=test | ||
DEXCOM_APPLICATION_ID=d89443d2-327c-4a6f-89e5-496bbb0317db | ||
DEXCOM_USER_LOCATION=EU | ||
|
||
DATABASE_HOST=127.0.0.1 | ||
DATABASE_PORT=5432 | ||
DATABASE_USER=user123 | ||
DATABASE_PASSWORD=root | ||
DATABASE_NAME=test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: App testing | ||
|
||
on: | ||
push: | ||
branches: [ "develop", "master" ] | ||
pull_request: | ||
branches: [ "develop", "master" ] | ||
|
||
jobs: | ||
|
||
test: | ||
services: | ||
postgres: | ||
image: postgres | ||
ports: | ||
- "5432:5432" | ||
env: | ||
POSTGRES_USER: user123 | ||
POSTGRES_PASSWORD: root | ||
POSTGRES_DB: test | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
|
||
- name: Install all dependencies | ||
run: npm ci | ||
|
||
- name: Check typescript types | ||
run: npm run check-types | ||
|
||
- name: Check lint | ||
run: npm run lint | ||
|
||
- name: Run test | ||
run: npm test | ||
|
||
- name: Upload coverage reports | ||
run: | | ||
curl -Os https://uploader.codecov.io/latest/linux/codecov | ||
chmod +x codecov | ||
./codecov | ||
test-build-run: | ||
runs-on: ubuntu-latest | ||
env: | ||
DEXCOM_USERNAME: ${{ secrets.DEXCOM_USERNAME }} | ||
DEXCOM_PASSWORD: ${{ secrets.DEXCOM_PASSWORD }} | ||
DEXCOM_APPLICATION_ID: d89443d2-327c-4a6f-89e5-496bbb0317db | ||
DEXCOM_USER_LOCATION: EU | ||
DATABASE_HOST: localhost | ||
DATABASE_PORT: 5432 | ||
DATABASE_USER: user123 | ||
DATABASE_PASSWORD: root | ||
DATABASE_NAME: glucose_dev | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@v3 | ||
|
||
- name: Install all dependencies | ||
run: npm ci | ||
|
||
- name: Install aws-lambda-runtime-interface-emulator | ||
run: | | ||
mkdir -p ~/.aws-lambda-rie && curl -Lo ~/.aws-lambda-rie/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie && chmod +x ~/.aws-lambda-rie/aws-lambda-rie | ||
- name: Build docker compose | ||
run: | | ||
docker-compose up -d --build | ||
- name: Run migrations for containerised postgres | ||
env: | ||
DATABASE_HOST: localhost | ||
run: | | ||
npm run migrations:latest | ||
- name: Check if image is appropriate for lambda container | ||
run: | | ||
set -e | ||
response=$(curl -i "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"maxCount": 5}') | ||
docker logs cgm-handler-container | ||
echo $response | ||
if echo $response | grep -q "error"; then | ||
echo "Error found in response" | ||
exit 1 | ||
else | ||
echo "No errors found in response" | ||
fi | ||
- name: Clear after pipeline | ||
run: | | ||
docker-compose down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
node_modules | ||
dist/ | ||
.idea | ||
.env | ||
.coverage | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"printWidth": 100, | ||
"printWidth": 90, | ||
"tabWidth": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
[![codecov](https://codecov.io/gh/BartekCK/cgm-handler/branch/develop/graph/badge.svg?token=XZC8ABPXDH)](https://codecov.io/gh/BartekCK/cgm-handler) | ||
|
||
### TODO: | ||
1. Add contract tests | ||
|
||
|
||
### Migrations | ||
- Create new migration | ||
```bash | ||
npm run migrations:create ${migration_name} | ||
``` | ||
|
||
|
||
docker-compose --env-file .env.test up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
version: '3' | ||
|
||
services: | ||
postgres: | ||
image: postgres | ||
environment: | ||
- POSTGRES_USER=${DATABASE_USER} | ||
- POSTGRES_PASSWORD=${DATABASE_PASSWORD} | ||
- POSTGRES_DB=${DATABASE_NAME} | ||
ports: | ||
- "${DATABASE_PORT}:${DATABASE_PORT}" | ||
volumes: | ||
- ./.db/postgres-config.sql:/docker-entrypoint-initdb.d/postgres-config.sql | ||
healthcheck: | ||
test: pg_isready | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
|
||
cgm-handler: | ||
container_name: cgm-handler-container | ||
build: | ||
context: . | ||
args: | ||
- NODE_ENV=production | ||
ports: | ||
- "9000:8080" | ||
environment: | ||
- DEXCOM_USERNAME=${DEXCOM_USERNAME} | ||
- DEXCOM_PASSWORD=${DEXCOM_PASSWORD} | ||
- DEXCOM_APPLICATION_ID=${DEXCOM_APPLICATION_ID} | ||
- DEXCOM_USER_LOCATION=${DEXCOM_USER_LOCATION} | ||
- DATABASE_HOST=postgres | ||
- DATABASE_PORT=5432 | ||
- DATABASE_USER=${DATABASE_USER} | ||
- DATABASE_PASSWORD=${DATABASE_PASSWORD} | ||
- DATABASE_NAME=${DATABASE_NAME} | ||
depends_on: | ||
- postgres | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { Config } from 'jest'; | ||
|
||
const config: Config = { | ||
verbose: true, | ||
preset: 'ts-jest', | ||
testPathIgnorePatterns: ['/node_modules/'], | ||
testMatch: ['**/*.test.ts'], | ||
collectCoverage: true, | ||
coverageDirectory: '.coverage', | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { IDbClientEnvConfig } from './src/infrastructure/database/client/dbClientEnvConfig.inteface'; | ||
import { EnvConfig } from './src/infrastructure/envConfig/envConfig'; | ||
|
||
export default async () => { | ||
const config: IDbClientEnvConfig = await EnvConfig.factory(); | ||
|
||
const [databasePassword, databasePort, databaseHost, databaseName, databaseUser] = [ | ||
config.getDatabasePassword(), | ||
config.getDatabasePort(), | ||
config.getDatabaseHost(), | ||
config.getDatabaseName(), | ||
config.getDatabaseUser(), | ||
]; | ||
|
||
return { | ||
client: 'pg', | ||
connection: { | ||
host: databaseHost, | ||
port: databasePort, | ||
user: databaseUser, | ||
password: databasePassword, | ||
database: databaseName, | ||
}, | ||
migrations: { | ||
directory: './src/infrastructure/database/migrations', | ||
}, | ||
}; | ||
}; |
Oops, something went wrong.