Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 7cf6c5c

Browse files
Merge branch 'master' into utkarsha/language-switcher-component
2 parents 35ec304 + bb56c14 commit 7cf6c5c

File tree

34 files changed

+525
-18670
lines changed

34 files changed

+525
-18670
lines changed

.circleci/config.yml

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
version: 2.1
2+
orbs:
3+
k8s: circleci/kubernetes@0.7.0
4+
slack: circleci/slack@3.4.2
5+
commands:
6+
npm_install_from_cache:
7+
description: "npm install and save cache"
8+
steps:
9+
- restore_cache:
10+
key: v1-deps-{{ checksum "package-lock.json" }}
11+
- run:
12+
name: Install npm dependencies
13+
command: npm install
14+
- save_cache:
15+
key: v1-deps-{{ checksum "package-lock.json" }}
16+
paths:
17+
- node_modules
18+
build:
19+
description: "Build Docusaurus project"
20+
steps:
21+
- run:
22+
name: Building Docusaurus project
23+
command: npm run build
24+
25+
versioning:
26+
description: "Versioning the image"
27+
parameters:
28+
version_name:
29+
type: string
30+
default: "staging"
31+
steps:
32+
- run:
33+
name: Tag build
34+
command: echo "<< parameters.version_name >> $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version
35+
36+
docker_build_push:
37+
description: "Build and push Docker image to Docker Hub"
38+
parameters:
39+
docker_latest_image_tag:
40+
type: string
41+
default: "latest-staging"
42+
docker_image_tag:
43+
type: string
44+
default: ${CIRCLE_SHA1}
45+
steps:
46+
- setup_remote_docker
47+
- run:
48+
name: Building docker image
49+
command: |
50+
docker build -t ${DOCKHUB_ORGANISATION}/deriv-com-api:<< parameters.docker_image_tag >> -t ${DOCKHUB_ORGANISATION}/deriv-com-api:<< parameters.docker_latest_image_tag >> .
51+
- run:
52+
name: Pushing Image to docker hub
53+
command: |
54+
echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin
55+
docker push ${DOCKHUB_ORGANISATION}/deriv-com-api:<< parameters.docker_image_tag >>
56+
docker push ${DOCKHUB_ORGANISATION}/deriv-com-api:<< parameters.docker_latest_image_tag >>
57+
k8s_deploy:
58+
description: "Deploy to k8s cluster"
59+
parameters:
60+
target:
61+
type: string
62+
default: "beta"
63+
k8s_version:
64+
type: string
65+
default: ${CIRCLE_SHA1}
66+
k8s_namespace:
67+
type: string
68+
default: "deriv-com-api-staging"
69+
steps:
70+
- k8s/install-kubectl
71+
- run:
72+
name: Deploying to k8s cluster for service << parameters.k8s_namespace >>
73+
command: |
74+
export NAMESPACE=<< parameters.k8s_namespace >>
75+
git clone https://github.com/binary-com/devops-ci-scripts
76+
cd devops-ci-scripts/k8s-build_tools
77+
echo $CA_CRT | base64 --decode > ca.crt
78+
./release.sh deriv-com-api << parameters.k8s_version >>
79+
notify_slack:
80+
description: "Notify slack"
81+
steps:
82+
- slack/status:
83+
include_project_field: false
84+
failure_message: "Release failed for api.deriv.com with version *$(cat build/version)*"
85+
success_message: "Release succeeded for api.deriv.com with version *$(cat build/version)*"
86+
webhook: ${SLACK_WEBHOOK}
87+
publish_to_pages_staging:
88+
description: "Publish to cloudflare pages"
89+
steps:
90+
- run:
91+
name: "Publish to cloudflare pages (staging)"
92+
command: |
93+
npm i wrangler@2.0.19
94+
cd build
95+
npx wrangler pages publish . --project-name=deriv-developers-portal-pages --branch=staging
96+
echo "New staging website - https://staging-api.deriv.com/"
97+
98+
publish_to_pages_production:
99+
description: "Publish to cloudflare pages"
100+
steps:
101+
- run:
102+
name: "Publish to cloudflare pages (production)"
103+
command: |
104+
npm i wrangler@2.0.19
105+
cd build
106+
npx wrangler pages publish . --project-name=deriv-developers-portal-pages --branch=main
107+
echo "New website - https://api.deriv.com"
108+
109+
jobs:
110+
build:
111+
docker:
112+
- image: cimg/node:18.16.0
113+
steps:
114+
- checkout
115+
- npm_install_from_cache
116+
- build
117+
118+
release_staging:
119+
docker:
120+
- image: cimg/node:18.16.0
121+
steps:
122+
- checkout
123+
- npm_install_from_cache
124+
- build
125+
- versioning
126+
- docker_build_push
127+
- k8s_deploy
128+
- publish_to_pages_staging
129+
- notify_slack
130+
environment:
131+
NODE_ENV: staging
132+
133+
release_production:
134+
docker:
135+
- image: cimg/node:18.16.0
136+
steps:
137+
- checkout
138+
- npm_install_from_cache
139+
- build
140+
- versioning:
141+
version_name: production
142+
- docker_build_push:
143+
docker_latest_image_tag: latest
144+
docker_image_tag: ${CIRCLE_SHA1}
145+
- k8s_deploy:
146+
k8s_namespace: "deriv-com-api-production"
147+
k8s_version: ${CIRCLE_SHA1}
148+
- publish_to_pages_production
149+
- notify_slack
150+
environment:
151+
NODE_ENV: production
152+
153+
workflows:
154+
release_staging:
155+
jobs:
156+
- release_staging:
157+
context: binary-frontend-artifact-upload
158+
filters:
159+
branches:
160+
only: /^master$/
161+
release_production:
162+
jobs:
163+
- release_production:
164+
context: binary-frontend-artifact-upload
165+
filters:
166+
branches:
167+
ignore: /.*/
168+
tags:
169+
only: /^production.*/

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM nginx:alpine
2+
COPY ./build /usr/share/nginx/html
3+
COPY ./developers.deriv.com.conf /etc/nginx/conf.d/default.conf
4+
RUN chown -R nginx:nginx /usr/share/nginx/html

developers.deriv.com.conf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
server {
2+
listen 80;
3+
server_name _;
4+
root /usr/share/nginx/html;
5+
index index.html index.htm;
6+
7+
charset UTF-8;
8+
9+
error_page 404 /404.html;
10+
11+
location @custom_error_503 {
12+
return 503;
13+
}
14+
15+
location ~ /\.git {
16+
return 404;
17+
}
18+
19+
location ~* \.(html)$ {
20+
add_header Cache-Control "public, max-age=0, must-revalidate";
21+
}
22+
23+
location ~ (manifest\.json|robots\.txt|service-worker\.js|sitemap\.xml|favicon\.ico)$ {
24+
add_header Cache-Control "public, max-age=0, must-revalidate";
25+
}
26+
27+
location /playground {
28+
return 301 https://$http_host/api-explorer/;
29+
}
30+
31+
location / {
32+
try_files $uri /index.html;
33+
}
34+
}

docs/core-concepts/authorization-authentication/index.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ keywords:
1212
- deriv-authorization
1313
description: deriv api authentication and authorization
1414
---
15+
1516
Without authentication and authorization you'll only get access to roughly half of our API calls and features. for example in order to buy contracts or utilize the `Copy Trading` features your users must be authenticated and authorized by our **OAuth** provider and **Websocket Server**.
1617

1718
## Before we start
@@ -20,12 +21,12 @@ You have to make sure you have all the requirements mentioned bellow to continue
2021

2122
### Requirements
2223

23-
1. Deriv Account
24+
1. Deriv Account
2425
2. Deriv API Token with the appropriate access level
25-
3. Deriv App ID
26+
3. Deriv App ID
2627

2728
:::note
28-
Please refer to [Setting up a Deriv Application](docs/setting-up-a-deriv-application) for detailed instruction how to create Deriv API token and Applications
29+
Please refer to [Setting up a Deriv Application](/docs/setting-up-a-deriv-application.md) for detailed instruction how to create Deriv API token and Applications
2930
:::
3031

3132
### API Token
@@ -54,15 +55,13 @@ For more information on OAuth2, visit [this guide](https://aaronparecki.com/oau
5455

5556
Here is the visual representation of how the OAuth authorization connection works:
5657

57-
![OAuth flow](/img/how_oauth_works.png "OAuth flow")
58+
![OAuth flow](/img/how_oauth_works.png 'OAuth flow')
5859

5960
## Authentication Process
6061

6162
In order to Authenticate your user, specify the URL that will be used as the OAuth Redirect URL on the [Dashboard](/dashboard) page, **Register application** tab in the **OAuth details** fields and then Add a login button on your website or app and direct users to **`https://oauth.binary.com/oauth2/authorize?app_id=your_app_id`** where your_app_id is the ID of your app.
6263

63-
64-
65-
![Deriv OAuth Login](/img/oauth_login.png "Deriv OAuth Login")
64+
![Deriv OAuth Login](/img/oauth_login.png 'Deriv OAuth Login')
6665

6766
Once a user signs up / signs in, they will be redirected to the URL that you entered as the Redirect URL. This URL will have arguments added to it with the user's session tokens, and will look similar to this:
6867

@@ -71,28 +70,32 @@ Once a user signs up / signs in, they will be redirected to the URL that you ent
7170
## Authorization Process
7271

7372
The query params in the redirect URL are the user's accounts and their related session tokens. you can map the query params to an array like so:
73+
7474
```js
7575
const user_accounts = [
76-
{
77-
account: "cr799393",
78-
token: "a1-f7pnteezo4jzhpxclctizt27hyeot",
79-
currency: "usd"
80-
},
81-
{
82-
account: "vrtc1859315",
83-
token: "a1clwe3vfuuus5kraceykdsoqm4snfq",
84-
currency: "usd"
85-
},
86-
]
76+
{
77+
account: 'cr799393',
78+
token: 'a1-f7pnteezo4jzhpxclctizt27hyeot',
79+
currency: 'usd',
80+
},
81+
{
82+
account: 'vrtc1859315',
83+
token: 'a1clwe3vfuuus5kraceykdsoqm4snfq',
84+
currency: 'usd',
85+
},
86+
];
8787
```
88-
To authorize the user, based on the user's **Selected** account, call the [authorize](https://api.deriv.com/api-explorer#authorize) API call with the user's **Selected** account **Session Token**:
88+
89+
To authorize the user, based on the user's **Selected** account, call the [authorize](https://api.deriv.com/api-explorer#authorize) API call with the user's **Selected** account **Session Token**:
90+
8991
```js
9092
{
9193
"authorize": "a1-f7pnteezo4jzhpxclctizt27hyeot"
9294
}
9395
```
9496

9597
The response for the `authorize` call would be an object like so:
98+
9699
```js
97100
{
98101
"account_list": [
@@ -146,4 +149,5 @@ The response for the `authorize` call would be an object like so:
146149
"user_id": 12345678
147150
}
148151
```
149-
Now user is authorized and you use Deriv API calls on behalf of the account.
152+
153+
Now user is authorized and you use Deriv API calls on behalf of the account.

docusaurus.config.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,21 @@ const config = {
3535
},
3636
},
3737

38-
plugins: ['@docusaurus/theme-live-codeblock', 'docusaurus-plugin-sass'],
38+
plugins: [
39+
'@docusaurus/theme-live-codeblock',
40+
'docusaurus-plugin-sass',
41+
[
42+
'@docusaurus/plugin-client-redirects',
43+
{
44+
redirects: [
45+
{
46+
to: '/docs/intro',
47+
from: '/docs',
48+
},
49+
],
50+
},
51+
],
52+
],
3953

4054
presets: [
4155
[
@@ -118,10 +132,6 @@ const config = {
118132
disableSwitch: true,
119133
respectPrefersColorScheme: false,
120134
},
121-
announcementBar: {
122-
id: 'announcementBar-2', // Increment on change
123-
content: `⭐️ This project is still in progress, we'll add more contents and features everyday, so stay tuned!`,
124-
},
125135
}),
126136
};
127137

0 commit comments

Comments
 (0)