Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Commit 298dc27

Browse files
authored
Merge pull request #227 from NatiqQuran/dev
Dev to Test Draft
2 parents c73901a + 05c728c commit 298dc27

File tree

45 files changed

+1237
-600
lines changed

Some content is hidden

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

45 files changed

+1237
-600
lines changed

.github/workflows/docker-image.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,29 @@ name: Docker Image CI
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches:
6+
- "main"
7+
- "test"
8+
- "dev"
69
pull_request:
7-
branches: [ "main" ]
10+
branches:
11+
- "main"
12+
- "test"
13+
- "dev"
814

915
jobs:
1016

1117
build:
12-
1318
runs-on: ubuntu-latest
1419

1520
steps:
1621
- uses: actions/checkout@v3
22+
1723
- name: Build the Docker image
18-
run: docker build . --file Dockerfile --tag natiq-api:$(date +%s)
24+
run: |
25+
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
26+
TAG="latest"
27+
else
28+
TAG="${GITHUB_REF##*/}"
29+
fi
30+
docker build . --file Dockerfile --tag natiq-api:$TAG

.github/workflows/docker-publish.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,42 @@ name: docker-publish
22

33
on:
44
push:
5-
branches:
5+
branches:
66
- "main"
7+
- "test"
8+
- "dev"
79

810
jobs:
911
build:
1012
runs-on: ubuntu-latest
13+
1114
steps:
12-
-
13-
name: Checkout
15+
- name: Checkout
1416
uses: actions/checkout@v3
15-
-
16-
name: Login to Docker Hub
17+
18+
- name: Login to Docker Hub
1719
uses: docker/login-action@v2
1820
with:
1921
username: ${{ secrets.DOCKER_HUB_USERNAME }}
2022
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
21-
-
22-
name: Set up Docker Buildx
23+
24+
- name: Set up Docker Buildx
2325
uses: docker/setup-buildx-action@v2
24-
-
25-
name: Build and push
26+
27+
- name: Set Docker tags
28+
id: set_tags
29+
run: |
30+
base_tag="${{ secrets.DOCKER_HUB_USERNAME }}/nq-api"
31+
if [[ "${GITHUB_REF##*/}" == "main" ]]; then
32+
echo "tags=${base_tag}:latest" >> $GITHUB_ENV
33+
else
34+
echo "tags=${base_tag}:${GITHUB_REF##*/}" >> $GITHUB_ENV
35+
fi
36+
37+
- name: Build and push
2638
uses: docker/build-push-action@v3
2739
with:
2840
context: .
2941
file: ./Dockerfile
3042
push: true
31-
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/nq-api:latest
43+
tags: ${{ env.tags }}

.github/workflows/rust.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ name: Rust
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches:
6+
- "main"
7+
- "test"
8+
- "dev"
69
pull_request:
7-
branches: [ "main" ]
10+
branches:
11+
- "main"
12+
- "test"
13+
- "dev"
814

915
env:
1016
CARGO_TERM_COLOR: always

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
# nq-api
2-
[![docker-publish](https://github.com/NatiqQuran/nq-api/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/NatiqQuran/nq-api/actions/workflows/docker-publish.yml)
3-
[![Docker Image CI](https://github.com/NatiqQuran/nq-api/actions/workflows/docker-image.yml/badge.svg)](https://github.com/NatiqQuran/nq-api/actions/workflows/docker-image.yml)
4-
[![Rust](https://github.com/NatiqQuran/nq-api/actions/workflows/rust.yml/badge.svg)](https://github.com/NatiqQuran/nq-api/actions/workflows/rust.yml)
1+
# nq-api-rust
52

6-
Natiq Quran open API
3+
[![docker-publish](https://github.com/NatiqQuran/nq-api-rust/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/NatiqQuran/nq-api-rust/actions/workflows/docker-publish.yml)
4+
[![Docker Image CI](https://github.com/NatiqQuran/nq-api-rust/actions/workflows/docker-image.yml/badge.svg)](https://github.com/NatiqQuran/nq-api-rust/actions/workflows/docker-image.yml)
5+
[![Rust](https://github.com/NatiqQuran/nq-api-rust/actions/workflows/rust.yml/badge.svg)](https://github.com/NatiqQuran/nq-api-rust/actions/workflows/rust.yml)
6+
7+
Natiq Quran open API \
78

89
# Docker
910

10-
Start nq-api with docker-compose
11+
Start nq-api-rust with docker-compose
1112

1213
```bash
1314
sudo docker compose up
@@ -22,7 +23,7 @@ cargo build --release
2223
# Run
2324

2425
```bash
25-
./target/release/nq-api
26+
./target/release/nq-api-rust
2627
```
2728

28-
Api will listen to 0.0.0.0:8080
29+
API will listen to 0.0.0.0:8080

error_codes.json

Lines changed: 88 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,90 @@
11
{
2-
"INTERNAL_ERROR": {
3-
"status_code": 500,
4-
"message": "Internal Error!"
5-
},
6-
"NOT_FOUND": {
7-
"status_code": 404,
8-
"message": "Not found!"
9-
},
10-
"ACTION_NOT_FOUND": {
11-
"status_code": 404,
12-
"message": "Not found!"
13-
},
14-
"SEND_CODE_INTERNAL_ERROR": {
15-
"status_code": 500,
16-
"message": "Internal error when sending verification code!"
17-
},
18-
"VERIFY_CODE_NOT_SENDED": {
19-
"status_code": 410,
20-
"message": "No verification code is sended to this email!"
21-
},
22-
"VERIFY_CODE_NOT_VALID": {
23-
"status_code": 400,
24-
"message": "Verification code is not valid!"
25-
},
26-
"VERIFY_CODE_ALREADY_USED": {
27-
"status_code": 410,
28-
"message": "Verification code is already used!"
29-
},
30-
"VERIFY_CODE_EXPIRED": {
31-
"status_code": 410,
32-
"message": "Verification code is expired!"
33-
},
34-
"CANT_GENERATE_TOKEN": {
35-
"status_code": 500,
36-
"message": "Can't generate token!"
37-
},
38-
"ORGANIZATION_NAME_NOT_AVAILABLE": {
39-
"status_code": 404,
40-
"message": "Organization name is already in use by another account!"
41-
},
42-
"PERMISSION_CONDITION_VALUE_NOT_VALID": {
43-
"status_code": 400,
44-
"message": "Permission condition value is not valid!"
45-
},
46-
"AUTHZ_CONDITION_VALUE_NOT_DEFINED": {
47-
"status_code": 404,
48-
"message": "Authz condition value is not defined!"
49-
},
50-
"MODEL_ATTRIBUTE_NOT_DEFINED": {
51-
"status_code": 404,
52-
"message": "Model attribute value is not defined!"
53-
},
54-
"VALIDATION_ERROR": {
55-
"status_code": 400,
56-
"message": "Request data is not valid"
57-
},
58-
"FILTER_SORT_VALUE_NOT_DEFINED": {
59-
"status_code": 404,
60-
"message": "Filter sort value is not defined!"
61-
},
62-
"AUTHN_TOKEN_NOT_FOUND": {
63-
"status_code": 401,
64-
"message": "Token required!"
65-
},
66-
"AUTHN_TOKEN_INVALID": {
67-
"status_code": 401,
68-
"message": "Token invalid!"
69-
},
70-
"AUTHZ_PERMISSION_DENIED": {
71-
"status_code": 403,
72-
"message": "Permission denied!"
73-
},
74-
"UUID_ERROR": {
75-
"status_code": 400,
76-
"message": "Invalid UUID!"
77-
},
78-
"PHRASE_NOT_FOUND": {
79-
"status_code": 404,
80-
"message": "Phrase not found!"
81-
},
82-
"BAD_PATH": {
83-
"status_code": 400,
84-
"message": "Path format is not correct!"
85-
}
2+
"INTERNAL_ERROR": {
3+
"status_code": 500,
4+
"message": "Internal Error!"
5+
},
6+
"NOT_FOUND": {
7+
"status_code": 404,
8+
"message": "Not found!"
9+
},
10+
"ACTION_NOT_FOUND": {
11+
"status_code": 404,
12+
"message": "Not found!"
13+
},
14+
"SEND_CODE_INTERNAL_ERROR": {
15+
"status_code": 500,
16+
"message": "Internal error when sending verification code!"
17+
},
18+
"VERIFY_CODE_NOT_SENDED": {
19+
"status_code": 410,
20+
"message": "No verification code is sended to this email!"
21+
},
22+
"VERIFY_CODE_NOT_VALID": {
23+
"status_code": 400,
24+
"message": "Verification code is not valid!"
25+
},
26+
"VERIFY_CODE_ALREADY_USED": {
27+
"status_code": 410,
28+
"message": "Verification code is already used!"
29+
},
30+
"VERIFY_CODE_EXPIRED": {
31+
"status_code": 410,
32+
"message": "Verification code is expired!"
33+
},
34+
"CANT_GENERATE_TOKEN": {
35+
"status_code": 500,
36+
"message": "Can't generate token!"
37+
},
38+
"ORGANIZATION_NAME_NOT_AVAILABLE": {
39+
"status_code": 404,
40+
"message": "Organization name is already in use by another account!"
41+
},
42+
"PERMISSION_CONDITION_VALUE_NOT_VALID": {
43+
"status_code": 400,
44+
"message": "Permission condition value is not valid!"
45+
},
46+
"AUTHZ_CONDITION_VALUE_NOT_DEFINED": {
47+
"status_code": 404,
48+
"message": "Authz condition value is not defined!"
49+
},
50+
"MODEL_ATTRIBUTE_NOT_DEFINED": {
51+
"status_code": 404,
52+
"message": "Model attribute value is not defined!"
53+
},
54+
"VALIDATION_ERROR": {
55+
"status_code": 400,
56+
"message": "Request data is not valid"
57+
},
58+
"FILTER_SORT_VALUE_NOT_DEFINED": {
59+
"status_code": 404,
60+
"message": "Filter sort value is not defined!"
61+
},
62+
"AUTHN_TOKEN_NOT_FOUND": {
63+
"status_code": 401,
64+
"message": "Token required!"
65+
},
66+
"AUTHN_TOKEN_INVALID": {
67+
"status_code": 401,
68+
"message": "Token invalid!"
69+
},
70+
"AUTHZ_PERMISSION_DENIED": {
71+
"status_code": 403,
72+
"message": "Permission denied!"
73+
},
74+
"UUID_ERROR": {
75+
"status_code": 400,
76+
"message": "Invalid UUID!"
77+
},
78+
"PHRASE_NOT_FOUND": {
79+
"status_code": 404,
80+
"message": "Phrase not found!"
81+
},
82+
"BAD_PATH": {
83+
"status_code": 400,
84+
"message": "Path format is not correct!"
85+
},
86+
"NO_BISMILLAH": {
87+
"status_code": 400,
88+
"message": "Doesn't have bismillah!"
89+
}
8690
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
CREATE TABLE app_accounts (
2-
id serial NOT NULL,
2+
id serial PRIMARY KEY,
33
uuid uuid DEFAULT uuid_generate_v4 () NOT NULL,
44
username VARCHAR(30) NOT NULL,
55
account_type TEXT NOT NULL,
6-
CONSTRAINT app_accounts_id PRIMARY KEY (id),
7-
UNIQUE(username)
6+
UNIQUE (username)
87
);

migrations/00000000000003_create_mushaf/up.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ CREATE TABLE quran_mushafs (
55
short_name VARCHAR(200),
66
name VARCHAR(400),
77
source VARCHAR(300),
8-
bismillah_text TEXT,
98
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
109
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
1110
CONSTRAINT mushaf_fk_user_id_rel FOREIGN KEY(creator_user_id) REFERENCES app_users(id),

migrations/00000000000005_create_quran_surahs/up.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ CREATE TABLE quran_surahs (
55
name VARCHAR(50) NOT NULL,
66
period VARCHAR(50),
77
number serial NOT NULL,
8-
bismillah_status BOOLEAN NOT NULL,
9-
bismillah_as_first_ayah BOOLEAN NOT NULL,
108
mushaf_id serial NOT NULL,
119
name_pronunciation TEXT,
1210
name_translation_phrase TEXT,
1311
name_transliteration TEXT,
12+
search_terms TEXT ARRAY,
1413
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
1514
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
1615
CONSTRAINT quran_surahs_id PRIMARY KEY (id),

migrations/2023-02-19-100955_create_quran_ayahs/up.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ CREATE TABLE quran_ayahs (
55
surah_id serial NOT NULL,
66
ayah_number serial NOT NULL,
77
sajdah VARCHAR(20),
8+
is_bismillah BOOLEAN NOT NULL,
9+
bismillah_text TEXT,
810
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
911
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
1012
CONSTRAINT quran_ayahs_id PRIMARY KEY (id),

migrations/2023-03-12-100253_create_translation/up.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ CREATE TABLE quran_translations (
88
release_date DATE,
99
source VARCHAR(300),
1010
approved BOOLEAN DEFAULT FALSE NOT NULL,
11-
bismillah TEXT NOT NULL,
1211
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
1312
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
1413
CONSTRAINT translation_fk_user_id_rel FOREIGN KEY(creator_user_id) REFERENCES app_users(id),

0 commit comments

Comments
 (0)