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

init account and crypto managment #21

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ jobs:
timeout_minutes: 15
retry_on: error
command: pnpm install --frozen-lockfile
- name: Run DB migration
run: cd packages/api-gateway && pnpm migration:run
- name: Run linter
run: cd packages/api-gateway && pnpm lint
- name: Run test suite
run: cd packages/api-gateway && pnpm test:ci
- name: Clean DB
run: cd packages/api-gateway && pnpm typeorm:drop
- name: Upload coverage reports to Codecov
if: ${{ matrix.node-version == 20 }}
uses: codecov/codecov-action@v3
Expand Down
15 changes: 4 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@ pids
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage/
*.lcov

# nyc test coverage
.nyc_output
# tap test and coverage
.tap

# Compiled Javascript files
dist/
Expand Down Expand Up @@ -57,5 +50,5 @@ node_modules/
.env*
!.env.template

# Turbo
.turbo
# NX
.nx/cache
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
engine-strict=true
enable-pre-post-scripts=true
package-lock=true
auto-install-peers=true
strict-peer-dependencies=false
Expand Down
22 changes: 22 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"targetDefaults": {
"format": {
"cache": true
},
"format:fix": {
"cache": true
},
"build": {
"cache": true
},
"lint": {
"cache": true
},
"lint:fix": {
"cache": true
}
},
"affected": {
"defaultBase": "main"
}
}
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
"ci:publish": "pnpm publish -r",
"cleanall": "rm -rf pnpm-lock.yaml node_modules */**/node_modules && pnpm workspace -- clean",
"clean": "pnpm workspace -- clean",
"format": "turbo --concurrency=1 format",
"format:fix": "turbo --concurrency=1 format:fix",
"lint": "turbo --concurrency=1 lint",
"lint:fix": "turbo --concurrency=1 lint:fix",
"format": "npx nx run-many -t format",
"format:fix": "pnpm clean && npx nx run-many -t format:fix",
"lint": "pnpm clean && npx nx run-many -t lint",
"lint:fix": "pnpm clean && npx nx run-many -t lint:fix",
"prepare": "husky install",
"release": "turbo release --concurrency=1",
"test": "pnpm workspace -- test",
"test:dev": "pnpm workspace -- test:dev",
"release": "npx nx run-many -t release",
"test": "npx nx test @bitify/api-gateway",
"test:dev": "npx nx test:dev @bitify/api-gateway",
"test:ci": "npx nx test:ci @bitify/api-gateway",
"test:cov": "npx nx test:cov @bitify/api-gateway",
"start": "pnpm workspace -- start",
"start:dev": "pnpm workspace -- start:dev",
"workspace": "pnpm -r --workspace-concurrency=1"
Expand All @@ -29,7 +31,7 @@
"@tsconfig/strictest": "^2.0.1",
"husky": "^8.0.0",
"lint-staged": "^14.0.1",
"turbo": "^1.10.14"
"nx": "17.2.8"
},
"keywords": [
"trading",
Expand Down
5 changes: 5 additions & 0 deletions packages/api-gateway/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ POSTGRES_USERNAME="postgres"
POSTGRES_PASSWORD="mysecretpassword"
POSTGRES_DATABASE="my_database"

# Migration and synchronization cannot be enabled at the same time
POSTGRES_MIGRATIONS_RUN="true"
# Make sure you don't turn on synchronization on production
POSTGRES_SYNCHRONIZE="false"

### EMAIL
EMAIL_TRANSPORT="smtps://username:[email protected]"
EMAIL_FROM="no-reply <[email protected]>"
Expand Down
6 changes: 3 additions & 3 deletions packages/api-gateway/.taprc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
timeout: 300
coverage: false
check-coverage: false
# vim: set filetype=yaml :
allow-incomplete-coverage: true
timeout: 0
34 changes: 34 additions & 0 deletions packages/api-gateway/database/data-seed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { DataSource, DataSourceOptions } from 'typeorm';
import 'dotenv/config';
import path from 'path';

const migrationsRun = process.env['POSTGRES_MIGRATIONS_RUN'] === 'true';
const synchronize = process.env['POSTGRES_SYNCHRONIZE'] === 'true';

if (synchronize) {
console.warn(
"Please make sure you don't turn on synchronization on production. Set 'POSTGRES_SYNCHRONIZE=false' in your .env file to disable synchronization.",
);
}

if (migrationsRun && synchronize)
throw new Error(
"Synchronization and migration cannot be enabled at the same time. Set 'POSTGRES_SYNCHRONIZE=false' or 'POSTGRES_MIGRATIONS_RUN=false' in your .env file.",
);

const dataSeedOptions: DataSourceOptions = {
type: 'postgres',
host: process.env['POSTGRES_HOST'] ?? '127.0.0.1',
port: parseInt(process.env['POSTGRES_PORT'] ?? '5432', 10),
username: process.env['POSTGRES_USERNAME'] ?? 'postgres',
password: process.env['POSTGRES_PASSWORD'] ?? 'postgres',
database: process.env['POSTGRES_DATABASE'] ?? 'postgres',
migrations: [path.join(__dirname, './seeds/**/*{.ts,.js}')],
migrationsTableName: 'migrations_seed',
migrationsRun,
synchronize,
entities: [path.join(__dirname, './../src/**/*.entity{.ts,.js}')],
};

const dataSeed = new DataSource(dataSeedOptions);
export default dataSeed;
33 changes: 33 additions & 0 deletions packages/api-gateway/database/data-source.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { DataSource, DataSourceOptions } from 'typeorm';
import 'dotenv/config';
import path from 'path';

const migrationsRun = process.env['POSTGRES_MIGRATIONS_RUN'] === 'true';
const synchronize = process.env['POSTGRES_SYNCHRONIZE'] === 'true';

if (synchronize) {
console.warn(
"Please make sure you don't turn on synchronization on production. Set 'POSTGRES_SYNCHRONIZE=false' in your .env file to disable synchronization.",
);
}

if (migrationsRun && synchronize)
throw new Error(
"Synchronization and migration cannot be enabled at the same time. Set 'POSTGRES_SYNCHRONIZE=false' or 'POSTGRES_MIGRATIONS_RUN=false' in your .env file.",
);

export const dataSourceOptions: DataSourceOptions = {
type: 'postgres',
host: process.env['POSTGRES_HOST'] ?? '127.0.0.1',
port: parseInt(process.env['POSTGRES_PORT'] ?? '5432', 10),
username: process.env['POSTGRES_USERNAME'] ?? 'postgres',
password: process.env['POSTGRES_PASSWORD'] ?? 'postgres',
database: process.env['POSTGRES_DATABASE'] ?? 'postgres',
migrations: [path.join(__dirname, './migrations/**/*{.ts,.js}')],
migrationsRun,
synchronize,
entities: [path.join(__dirname, './../src/**/*.entity{.ts,.js}')],
};

const dataSource = new DataSource(dataSourceOptions);
export default dataSource;
Empty file.
Loading
Loading