-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from cowprotocol/release/2024-04-24
Release/2024 05 24
- Loading branch information
Showing
177 changed files
with
15,541 additions
and
4,916 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,5 @@ | ||
.tmp/ | ||
.cache/ | ||
.git/ | ||
node_modules/ | ||
.env |
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,38 @@ | ||
# Port | ||
PORT=8080 | ||
|
||
# Database | ||
DATABASE_USERNAME=bff-db-user | ||
DATABASE_PASSWORD=bff-db-password | ||
DATABASE_NAME=bff-db | ||
DATABASE_PORT=5432 | ||
|
||
# Rabbit MQ | ||
QUEUE_USER=rabbit | ||
QUEUE_PASSWORD=my-rabbit-password | ||
QUEUE_HOST=localhost | ||
QUEUE_PORT=5672 | ||
|
||
# Telegram | ||
TELEGRAM_SECRET= | ||
|
||
# Orderbook | ||
ORDERBOOK_DATABASE_HOST= | ||
ORDERBOOK_DATABASE_PORT= | ||
ORDERBOOK_DATABASE_USERNAME= | ||
ORDERBOOK_DATABASE_PASSWORD= | ||
|
||
# CMS | ||
CMS_API_KEY= | ||
CMS_BASE_URL=https://cms.cow.fi | ||
|
||
# Infura | ||
INFURA_KEY=infura-key | ||
INFURA_JWT_ID=infura-jwt-id | ||
|
||
# Proxy | ||
PROXY_UPSTREAM=proxy-upstream | ||
PROXY_ORIGIN=proxy-origin | ||
|
||
# JWT | ||
JWT_CERT_PASSPHRASE=secret |
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 @@ | ||
node_modules |
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,42 @@ | ||
{ | ||
"root": true, | ||
"ignorePatterns": ["**/*"], | ||
"plugins": ["@nx"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": { | ||
"@nx/enforce-module-boundaries": [ | ||
"error", | ||
{ | ||
"enforceBuildableLibDependency": true, | ||
"allow": [], | ||
"depConstraints": [ | ||
{ | ||
"sourceTag": "*", | ||
"onlyDependOnLibsWithTags": ["*"] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"extends": ["plugin:@nx/typescript"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"extends": ["plugin:@nx/javascript"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"], | ||
"env": { | ||
"jest": true | ||
}, | ||
"rules": {} | ||
} | ||
] | ||
} |
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,57 @@ | ||
name: Publish Docker image | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
tags: [v*] | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
package: | ||
- apps/api | ||
- apps/twap | ||
- apps/notification-producer | ||
- apps/telegram | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: yarn install | ||
- run: yarn build | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/#-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract package name | ||
run: echo "PACKAGE_NAME=$(basename ${{ matrix.package }})" >> $GITHUB_ENV | ||
|
||
- name: 'Image metadata for ${{ env.PACKAGE_NAME }}' | ||
id: image_meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/${{ github.repository }}/${{ env.PACKAGE_NAME }} | ||
|
||
- name: 'BFF: Build and push ${{ env.PACKAGE_NAME }}' | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ${{ matrix.package }}/Dockerfile | ||
push: true | ||
tags: ${{ steps.image_meta.outputs.tags }} | ||
labels: ${{ steps.image_meta.outputs.labels }} | ||
builder: ${{ steps.setup-buildx.outputs.name }} | ||
platforms: linux/amd64 |
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,5 @@ | ||
tmp | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
@@ -65,4 +67,5 @@ test/types/index.js | |
dist | ||
|
||
# env file | ||
.env | ||
.env* | ||
!.env.examples |
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,3 @@ | ||
# Add files here to ignore them from prettier formatting | ||
/dist | ||
/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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"singleQuote": true | ||
} |
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,73 @@ | ||
# Cow Web Services | ||
# BFF (Backend For Frontend) | ||
|
||
Backend for frontend is a series of backend services and libraries that enhance user experience for the frontend. | ||
|
||
## Getting Started | ||
|
||
Install dependencies: | ||
|
||
```bash | ||
yarn | ||
``` | ||
|
||
Create the `.env` file: | ||
|
||
```bash | ||
# If you are not using docker | ||
cp .env.example .env | ||
|
||
# If you are using docker (handy to launch a service directly using NX) | ||
cp .env.example .env.docker | ||
``` | ||
|
||
Start docker: | ||
```bash | ||
yarn compose:up | ||
``` | ||
|
||
# Develop | ||
## Notification Producer | ||
Make sure your `.env` file is defined, if not create one using `.env.example` as a template. | ||
|
||
```bash | ||
# Start RabbitMQ | ||
docker-compose up -d queue | ||
|
||
# Start the notification producer | ||
yarn producer | ||
``` | ||
## Create a new service or library | ||
|
||
To add a new app or library, you can run the following command; | ||
|
||
```bash | ||
# New API | ||
yarn new:fastify | ||
|
||
# New Library | ||
yarn new:lib | ||
|
||
# New Node app | ||
yarn new:node | ||
``` | ||
|
||
For APIs and apps, it will create a Dockerfile. Please, remember to update: | ||
- The `docker-compose.yml` file to include the new service. | ||
- The github actions to include the new service (`.github/workflows/ci.yml`) | ||
|
||
For more info, see: | ||
- [@nx/node:application](https://nx.dev/packages/node/generators/application): Generator for Applications | ||
- [@nx/node:application (Fastify)](https://nx.dev/showcase/example-repos/add-fastify): Generator for API Applications using Fastify | ||
- [@nx/node:setup-docker](https://nx.dev/nx-api/node/generators/library): Generator for NodeJS Libraries | ||
- [@nx/node:setup-docker](https://nx.dev/nx-api/node/generators/setup-docker): Docker Generator | ||
|
||
|
||
# Build | ||
## Docker | ||
|
||
Build docker containers and publish to a local registry: | ||
|
||
```bash | ||
yarn docker-build:affected | ||
``` | ||
|
||
Collection of typescript based services, mainly for the use of CoW Swap. |
This file was deleted.
Oops, something went wrong.
Empty file.
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 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
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,19 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'api-e2e', | ||
preset: '../../jest.preset.js', | ||
globalSetup: '<rootDir>/src/support/global-setup.ts', | ||
globalTeardown: '<rootDir>/src/support/global-teardown.ts', | ||
setupFiles: ['<rootDir>/src/support/test-setup.ts'], | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.[tj]s$': [ | ||
'ts-jest', | ||
{ | ||
tsconfig: '<rootDir>/tsconfig.spec.json', | ||
}, | ||
], | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: '../../coverage/api-e2e', | ||
}; |
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,30 @@ | ||
{ | ||
"name": "api-e2e", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"implicitDependencies": [ | ||
"api" | ||
], | ||
"targets": { | ||
"e2e": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": [ | ||
"{workspaceRoot}/coverage/{e2eProjectRoot}" | ||
], | ||
"options": { | ||
"jestConfig": "packages/api-e2e/jest.config.ts", | ||
"passWithNoTests": true | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/linter:eslint", | ||
"outputs": [ | ||
"{options.outputFile}" | ||
], | ||
"options": { | ||
"lintFilePatterns": [ | ||
"packages/api-e2e/**/*.{js,ts}" | ||
] | ||
} | ||
} | ||
} | ||
} |
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,7 @@ | ||
import axios from 'axios'; | ||
|
||
test('GET /example', async () => { | ||
const res = await axios.get('/example'); | ||
|
||
expect(res.data).toEqual('this is an example'); | ||
}); |
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 @@ | ||
/* eslint-disable */ | ||
var __TEARDOWN_MESSAGE__: string; | ||
|
||
module.exports = async function () { | ||
// Start services that that the app needs to run (e.g. database, docker-compose, etc.). | ||
console.log('\nSetting up...\n'); | ||
|
||
// Hint: Use `globalThis` to pass variables to global teardown. | ||
globalThis.__TEARDOWN_MESSAGE__ = '\nTearing down...\n'; | ||
}; |
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,7 @@ | ||
/* eslint-disable */ | ||
|
||
module.exports = async function () { | ||
// Put clean up logic here (e.g. stopping services, docker-compose, etc.). | ||
// Hint: `globalThis` is shared between setup and teardown. | ||
console.log(globalThis.__TEARDOWN_MESSAGE__); | ||
}; |
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 @@ | ||
/* eslint-disable */ | ||
|
||
import axios from 'axios'; | ||
|
||
module.exports = async function () { | ||
// Configure axios for tests to use. | ||
const host = process.env.HOST ?? 'localhost'; | ||
const port = process.env.PORT ?? '3000'; | ||
axios.defaults.baseURL = `http://${host}:${port}`; | ||
}; |
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,13 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
], | ||
"compilerOptions": { | ||
"esModuleInterop": true | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"] | ||
}, | ||
"include": ["jest.config.ts", "src/**/*.ts"] | ||
} |
Oops, something went wrong.