Skip to content

Commit 534f6c8

Browse files
Merge pull request #445 from codex-team/master
Update prod
2 parents 9ad0a11 + f49a31a commit 534f6c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+5134
-131
lines changed

.env.sample

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ PLAYGROUND_ENABLE=false
3030
# AMQP URL
3131
AMQP_URL=amqp://guest:guest@rabbitmq
3232

33+
# Billing settings
34+
BILLING_DEBUG=true
35+
BILLING_COMPANY_EMAIL="[email protected]"
36+
37+
### Accounting module ###
38+
# Accounting service URL
39+
# CODEX_ACCOUNTING_URL=http://accounting:3999/graphql
40+
41+
# Files with certs
42+
TLS_CA_CERT=
43+
TLS_CERT=
44+
TLS_KEY=
45+
3346
## GitHub OAuth app client ID
3447
GITHUB_CLIENT_ID=fakedata
3548

@@ -51,6 +64,18 @@ HAWK_CATCHER_TOKEN=
5164
## Telegram bot url to send log messages
5265
TELEGRAM_MAIN_CHAT_URL=
5366

67+
## Telegam bot url for operations with money
68+
TELEGRAM_MONEY_CHAT_URL=
69+
70+
# Cloudpayments public id
71+
CLOUDPAYMENTS_PUBLIC_ID=test_api_00000000000000000000001
72+
73+
# Cloudpayments secret string
74+
CLOUDPAYMENTS_SECRET=
75+
76+
# INN of legal entity for CloudKassir
77+
LEGAL_ENTITY_INN=
78+
5479
# Token for Amplitude analytics
5580
AMPLITUDE_TOKEN=
5681

.env.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ SMTP_SENDER_NAME=
4444
SMTP_SENDER_ADDRESS=
4545

4646
# AMQP URL
47-
AMQP_URL=
47+
AMQP_URL=amqp://guest:guest@rabbitmq:5672/
4848

4949
# Billing settings
5050
BILLING_DEBUG=true
5151
BILLING_COMPANY_EMAIL="[email protected]"
5252

5353
### Accounting module ###
5454
# Accounting service URL
55-
CODEX_ACCOUNTING_URL=
55+
# CODEX_ACCOUNTING_URL=
5656

5757
# Enable or disable tls verify
5858
TLS_VERIFY=true
@@ -100,4 +100,4 @@ AWS_S3_ACCESS_KEY_ID=
100100
AWS_S3_SECRET_ACCESS_KEY=
101101
AWS_S3_BUCKET_NAME=
102102
AWS_S3_BUCKET_BASE_URL=
103-
AWS_S3_BUCKET_ENDPOINT=
103+
AWS_S3_BUCKET_ENDPOINT=

.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,13 @@ module.exports = {
33
env: {
44
'node': true,
55
'jest': true
6+
},
7+
rules: {
8+
'@typescript-eslint/camelcase': 'warn',
9+
'@typescript-eslint/no-unused-vars': 'warn',
10+
'@typescript-eslint/explicit-function-return-type': 'warn',
11+
'require-jsdoc': 'warn',
12+
'no-shadow': 'warn',
13+
'no-unused-expressions': 'warn'
614
}
715
};

.github/workflows/bump-version.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ jobs:
3939
- uses: actions/checkout@v2
4040

4141
# Setup node environment
42-
- uses: actions/setup-node@v1
42+
- uses: actions/setup-node@v3
4343
with:
44-
node-version: 15
44+
node-version-file: '.nvmrc'
4545
registry-url: https://registry.npmjs.org/
4646

4747
# Bump version to the next prerelease (patch) with rc suffix
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Run integration tests on push
2+
3+
on:
4+
- push
5+
6+
jobs:
7+
tests:
8+
name: Run integration tests
9+
runs-on: ubuntu-20.04
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Run tests
14+
run: yarn test:integration

.github/workflows/nodejs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v2
11-
- name: Use Node.js 12.x
12-
uses: actions/setup-node@v1
11+
- name: Use Node.js
12+
uses: actions/setup-node@v3
1313
with:
14-
node-version: 12.x
14+
node-version-file: '.nvmrc'
1515
- run: yarn install
1616
- run: yarn lint-test

docker-compose.test.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
version: "3.4"
2+
services:
3+
api:
4+
build:
5+
dockerfile: "./docker/Dockerfile.dev"
6+
context: .
7+
user: "node"
8+
env_file:
9+
- ./test/integration/api.env
10+
volumes:
11+
- ./:/usr/src/app
12+
- /usr/src/app/node_modules
13+
- ./test/integration/api.env:/usr/src/app/.env
14+
depends_on:
15+
- mongodb
16+
- rabbitmq
17+
# - accounting
18+
stdin_open: true
19+
tty: true
20+
21+
mongodb:
22+
image: mongo:4.2.13
23+
volumes:
24+
- mongodata-test:/data/db
25+
26+
tests:
27+
build:
28+
dockerfile: "./docker/Dockerfile.dev"
29+
context: .
30+
depends_on:
31+
rabbitmq:
32+
condition: service_healthy
33+
api:
34+
condition: service_started
35+
command: dockerize -wait http://api:4000/.well-known/apollo/server-health -timeout 30s yarn jest --config=./test/integration/jest.config.js --runInBand test/integration
36+
volumes:
37+
- ./:/usr/src/app
38+
- /usr/src/app/node_modules
39+
40+
rabbitmq:
41+
image: rabbitmq:3-management
42+
ports:
43+
- 15672:15672
44+
- 5672:5672
45+
volumes:
46+
- ./test/integration/rabbit.definitions.json:/tmp/rabbit.definitions.json:ro
47+
environment:
48+
- RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=-rabbitmq_management load_definitions "/tmp/rabbit.definitions.json"
49+
healthcheck:
50+
test: ["CMD-SHELL", "rabbitmqctl status || exit 1"]
51+
interval: 5s
52+
timeout: 3s
53+
retries: 5
54+
55+
# accounting:
56+
# image: codexteamuser/codex-accounting:prod
57+
# env_file:
58+
# - ./test/integration/accounting.env
59+
# volumes:
60+
# - ./test/integration/accounting.env:/usr/src/app/.env
61+
62+
volumes:
63+
mongodata-test:
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module.exports = {
2+
async up(db, client) {
3+
/**
4+
* Use one transaction for all requests
5+
*/
6+
const session = client.startSession();
7+
8+
try {
9+
await session.withTransaction(async () => {
10+
const plansCollection = db.collection('plans');
11+
12+
await plansCollection.updateMany(
13+
{},
14+
{ $set: { monthlyChargeCurrency: 'RUB' } } // Set the default value for monthlyChargeCurrency
15+
);
16+
});
17+
18+
} finally {
19+
await session.endSession();
20+
}
21+
},
22+
23+
async down(db, client) {
24+
/**
25+
* Use one transaction for all requests
26+
*/
27+
const session = client.startSession();
28+
29+
try {
30+
31+
await session.withTransaction(async () => {
32+
const plansCollection = db.collection('plans');
33+
34+
await plansCollection.updateMany(
35+
{},
36+
{ $unset: { monthlyChargeCurrency: "" } } // Remove the monthlyChargeCurrency field
37+
);
38+
39+
});
40+
41+
} finally {
42+
await session.endSession();
43+
}
44+
}
45+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = {
2+
async up(db, client) {
3+
/**
4+
* Use one transaction for all requests
5+
*/
6+
const session = client.startSession();
7+
8+
try {
9+
await session.withTransaction(async () => {
10+
const businessOperationsCollection = db.collection('businessOperations');
11+
12+
await businessOperationsCollection.updateMany(
13+
{},
14+
{ $set: { 'payload.currency': 'RUB' } } // Set the default value for payload.currency
15+
);
16+
});
17+
18+
} finally {
19+
await session.endSession();
20+
}
21+
},
22+
23+
async down(db, client) {
24+
/**
25+
* Use one transaction for all requests
26+
*/
27+
const session = client.startSession();
28+
29+
try {
30+
31+
await session.withTransaction(async () => {
32+
const businessOperationsCollection = db.collection('businessOperations');
33+
34+
await businessOperationsCollection.updateMany(
35+
{},
36+
{ $unset: { 'payload.businessOperations': "" } } // Remove the businessOperations field
37+
);
38+
});
39+
40+
} finally {
41+
await session.endSession();
42+
}
43+
}
44+
};

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hawk.api",
3-
"version": "1.0.23",
3+
"version": "1.1.1",
44
"main": "index.ts",
55
"license": "UNLICENSED",
66
"scripts": {
@@ -14,14 +14,18 @@
1414
"migrations:create": "docker-compose exec api yarn migrate-mongo create",
1515
"migrations:up": "docker-compose exec api yarn migrate-mongo up",
1616
"migrations:down": "docker-compose exec api yarn migrate-mongo down",
17-
"test": "jest --coverage"
17+
"test": "jest --coverage",
18+
"test:integration": "docker compose -f docker-compose.test.yml up --build --exit-code-from tests tests",
19+
"test:integration:down": "docker compose -f docker-compose.test.yml down --volumes"
1820
},
1921
"devDependencies": {
22+
"@shelf/jest-mongodb": "^1.2.2",
2023
"@types/jest": "^26.0.8",
2124
"eslint": "^6.7.2",
2225
"eslint-config-codex": "1.2.4",
2326
"eslint-plugin-import": "^2.19.1",
2427
"jest": "^26.2.2",
28+
"mongodb-memory-server": "^6.6.1",
2529
"nodemon": "^2.0.2",
2630
"ts-jest": "^26.1.4",
2731
"ts-node": "^10.9.1",
@@ -33,7 +37,7 @@
3337
"@graphql-tools/schema": "^8.5.1",
3438
"@graphql-tools/utils": "^8.9.0",
3539
"@hawk.so/nodejs": "^3.1.1",
36-
"@hawk.so/types": "^0.1.18",
40+
"@hawk.so/types": "^0.1.21",
3741
"@types/amqp-connection-manager": "^2.0.4",
3842
"@types/bson": "^4.0.5",
3943
"@types/debug": "^4.1.5",
@@ -53,6 +57,8 @@
5357
"axios": "^0.27.2",
5458
"body-parser": "^1.19.0",
5559
"bson": "^4.6.5",
60+
"cloudpayments": "^6.0.1",
61+
"codex-accounting-sdk": "https://github.com/codex-team/codex-accounting-sdk.git",
5662
"dataloader": "^2.0.0",
5763
"dotenv": "^16.0.1",
5864
"escape-html": "^1.0.3",

0 commit comments

Comments
 (0)