Skip to content

Commit cfdee44

Browse files
committed
feat: implement round-robin and refactor code
1 parent 2ff2337 commit cfdee44

23 files changed

+1512
-1796
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.json]
12+
insert_final_newline = ignore
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.github/FUNDING.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
ko_fi: sooluh
2-
custom: ["https://saweria.co/sooluh", "https://trakteer.id/sooluh"]
2+
custom: ['https://saweria.co/sooluh', 'https://trakteer.id/sooluh']

.gitignore

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
node_modules/
2-
*.js
3-
.vercel/
1+
dist
2+
node_modules
3+
.vercel
4+
.yarn
5+
.vscode
6+
7+
*.log

.gitpod.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ tasks:
33
command: yarn dev
44

55
ports:
6-
- port: 5000
6+
- port: 3000
77
onOpen: ignore

.yarnrc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
175175

176176
END OF TERMS AND CONDITIONS
177177

178-
Copyright 2019 Suluh Sulistiawan
178+
Copyright 2019 Abu Masyail
179179

180180
Licensed under the Apache License, Version 2.0 (the "License");
181181
you may not use this file except in compliance with the License.

README.md

+43-28
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
![kodepos](https://socialify.git.ci/sooluh/kodepos/image?description=1&descriptionEditable=Indonesian%20postal%20code%20search%20API%20by%20place%20name%2C%20village%20or%20city.&font=Raleway&forks=1&issues=1&logo=https%3A%2F%2Fraw.githubusercontent.com%2Ftwitter%2Ftwemoji%2Fmaster%2Fassets%2Fsvg%2F1f4ee.svg&name=1&owner=1&pattern=Charlie%20Brown&pulls=1&stargazers=1&theme=Dark)
1+
![@sooluh/kodepos](https://socialify.git.ci/sooluh/kodepos/image?description=1&descriptionEditable=Indonesian%20postal%20code%20search%20API%20by%20place%20name%2C%20village%20or%20city.&font=Raleway&forks=1&issues=1&logo=https%3A%2F%2Fraw.githubusercontent.com%2Ftwitter%2Ftwemoji%2Fmaster%2Fassets%2Fsvg%2F1f4ee.svg&name=1&owner=1&pattern=Charlie%20Brown&pulls=1&stargazers=1&theme=Dark)
2+
3+
## Requirements
4+
5+
- Node.js `>= 16.20.1`
6+
- Yarn `>= 1.22.0`
27

38
## Getting Started
49

@@ -8,7 +13,7 @@
813
git clone https://github.com/sooluh/kodepos.git
914
```
1015

11-
2. Change the current directory to this repository folder
16+
2. Move to the repository directory
1217

1318
```bash
1419
cd kodepos
@@ -20,7 +25,7 @@
2025
yarn install
2126
```
2227

23-
4. Run the app! (locally)
28+
4. Run locally
2429

2530
- Development mode
2631

@@ -46,12 +51,19 @@
4651

4752
The fastest way to use it privately on PaaS available
4853

49-
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fsooluh%2Fkodepos%2Ftree%2Fmain)
50-
[![Deploy with Cyclic](https://ik.imagekit.io/sooluh/cyclic.svg)](https://app.cyclic.sh/#/join/sooluh)
54+
<a href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fsooluh%2Fkodepos%2Ftree%2Fmain">
55+
<img alt="Deploy with Vercel" src="https://vercel.com/button" height="32" />
56+
</a>
57+
<a href="https://app.koyeb.com/deploy?type=git&repository=github.com/sooluh/kodepos&branch=main&name=kodepos">
58+
<img alt="Deploy with Koyeb" src="https://www.koyeb.com/static/images/deploy/button.svg" height="32" />
59+
</a>
60+
<a href="https://render.com/deploy">
61+
<img alt="Deploy with Render" src="https://render.com/images/deploy-to-render-button.svg" height="32" />
62+
</a>
5163

5264
## Basic Usage
5365

54-
Base URL : [`http://localhost:5000`](https://kodepos.vercel.app)
66+
Base URL : [`http://localhost:3000`](https://kodepos.vercel.app)
5567

5668
| Endpoint | Description | Parameter | Method |
5769
| ---------------------------------------------- | ------------------------------- | --------- | ------ |
@@ -62,43 +74,43 @@ Base URL : [`http://localhost:5000`](https://kodepos.vercel.app)
6274
#### Request
6375

6476
<pre>
65-
curl -XGET '<a href="https://kodepos.vercel.app/search/?q=danasari">http://localhost:5000/search/?q=danasari</a>'
77+
curl -XGET '<a href="https://kodepos.vercel.app/?q=danasari">http://localhost:3000/search/?q=danasari</a>'
6678
</pre>
6779

6880
#### Response
6981

7082
```json
7183
{
72-
"success": true,
73-
"message": "Data search successfully parsed.",
84+
"statusCode": 200,
85+
"code": "OK",
7486
"data": [
7587
{
7688
"province": "Jawa Tengah",
77-
"city": "Purbalingga",
78-
"subdistrict": "Karangjambu",
79-
"urban": "Danasari",
80-
"postalcode": "53357"
89+
"regency": "Purbalingga",
90+
"district": "Karangjambu",
91+
"village": "Danasari",
92+
"code": "53357"
8193
},
8294
{
8395
"province": "Jawa Tengah",
84-
"city": "Tegal",
85-
"subdistrict": "Bojong",
86-
"urban": "Danasari",
87-
"postalcode": "52465"
96+
"regency": "Tegal",
97+
"district": "Bojong",
98+
"village": "Danasari",
99+
"code": "52465"
88100
},
89101
{
90102
"province": "Jawa Tengah",
91-
"city": "Pemalang",
92-
"subdistrict": "Pemalang",
93-
"urban": "Danasari",
94-
"postalcode": "52314"
103+
"regency": "Pemalang",
104+
"district": "Pemalang",
105+
"village": "Danasari",
106+
"code": "52314"
95107
},
96108
{
97109
"province": "Jawa Barat",
98-
"city": "Ciamis",
99-
"subdistrict": "Cisaga",
100-
"urban": "Danasari",
101-
"postalcode": "46386"
110+
"regency": "Ciamis",
111+
"district": "Cisaga",
112+
"village": "Danasari",
113+
"code": "46386"
102114
}
103115
]
104116
}
@@ -110,16 +122,19 @@ List of awesome projects powered by this API
110122

111123
- [**kodepos-web**](https://github.com/dotslashf/kodepos-web)<br>
112124
Simple web-app for postcode search by [dotslashf](https://github.com/dotslashf)
125+
113126
- [**Kode POS**](https://github.com/AzharRivaldi/Kode-POS-Indonesia)<br>
114127
Indonesia postal code search application (kotlin) by [AzharRivaldi](https://github.com/AzharRivaldi)
115128

116129
### Ready to use!
117130

118131
List of server APIs ready to use publicly
119132

120-
- [https://kodepos.vercel.app](https://kodepos.vercel.app/?json=true)
121-
- [https://kodepos.cyclic.app](https://kodepos.cyclic.app/?json=true)
133+
- [https://kodepos.vercel.app](https://kodepos.vercel.app/?q=danasari) <sup><sub>`latest`</sub></sup>
134+
- [https://kodepos.cyclic.app](https://kodepos.cyclic.app/?q=danasari) <sup><sub>`latest`</sub></sup>
135+
- [https://kodepos.onrender.com](https://kodepos.onrender.com/?q=danasari) <sup><sub>`latest`</sub></sup>
136+
- [https://kodepos-82o09pkha-sooluh.vercel.app](https://kodepos-82o09pkha-sooluh.vercel.app/?q=danasari) <sup><sub>`v2.2.0`</sub></sup>
122137

123138
### License
124139

125-
Code licensed under [Apache 2.0 License](https://github.com/sooluh/kodepos/blob/main/LICENSE).
140+
This project is licensed under [Apache 2.0 License](https://github.com/sooluh/kodepos/blob/main/LICENSE).

nodemon.json

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
{
22
"restartable": "rs",
3-
"ignore": [
4-
".git",
5-
"node_modules/**/node_modules"
6-
],
7-
"verbose": "true",
8-
"watch": [
9-
"src/"
10-
],
3+
"ignore": [".git", "node_modules/**/node_modules"],
4+
"verbose": true,
5+
"watch": ["src"],
116
"env": {
127
"NODE_ENV": "development"
138
},
14-
"legacyWatch": true,
159
"ext": "ts,json",
16-
"exec": "yarn ts-node"
10+
"exec": "ts-node ./src/app.ts"
1711
}

package.json

+48-25
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "@sooluh/kodepos",
3-
"version": "2.2.0",
3+
"version": "3.0.0",
44
"description": "Indonesian postal code search API by place name, village or city",
5-
"main": "src/app.js",
5+
"main": "dist/app.js",
66
"scripts": {
7-
"prebuild": "del-cli \"./src/*.js\"",
8-
"build": "tsc",
9-
"start": "node ./src/app.js",
10-
"ts-node": "ts-node ./src/app.ts",
7+
"build": "tsc -p tsconfig.json",
8+
"start": "node ./dist/app.js",
119
"dev": "nodemon",
12-
"postinstall": "yarn build"
10+
"postinstall": "yarn build",
11+
"format": "prettier --write .",
12+
"commit": "git-cz"
1313
},
1414
"keywords": [
1515
"carikodepos",
@@ -21,13 +21,34 @@
2121
"code",
2222
"kode-pos"
2323
],
24+
"prettier": {
25+
"trailingComma": "es5",
26+
"semi": false,
27+
"singleQuote": true,
28+
"useTabs": false,
29+
"quoteProps": "consistent",
30+
"bracketSpacing": true,
31+
"arrowParens": "always",
32+
"printWidth": 100
33+
},
34+
"config": {
35+
"commitizen": {
36+
"path": "cz-conventional-changelog"
37+
}
38+
},
39+
"husky": {
40+
"hooks": {
41+
"pre-commit": "yarn format && git add --all",
42+
"prepare-commit-msg": "exec < /dev/tty && npx cz --hook || true"
43+
}
44+
},
2445
"repository": {
2546
"type": "git",
2647
"url": "git+https://github.com/sooluh/kodepos.git"
2748
},
2849
"author": {
29-
"name": "Suluh Sulistiawan",
30-
"email": "suluh.webdevelopers@hotmail.com",
50+
"name": "Abu Masyail",
51+
"email": "suluhs@aol.com",
3152
"url": "https://suluh.my.id"
3253
},
3354
"license": "Apache-2.0",
@@ -36,23 +57,25 @@
3657
},
3758
"homepage": "https://github.com/sooluh/kodepos",
3859
"dependencies": {
39-
"axios": "^0.21.1",
40-
"cheerio": "^1.0.0-rc.10",
41-
"fastify": "^3.19.0",
42-
"fastify-compress": "^3.6.0",
43-
"fastify-cors": "^6.0.2",
44-
"fastify-prettier": "^1.1.9",
45-
"header-generator": "^1.0.0",
46-
"qs": "^6.10.1"
60+
"@fastify/compress": "^6.4.0",
61+
"@fastify/cors": "^8.3.0",
62+
"@fastify/etag": "^4.2.0",
63+
"@fastify/rate-limit": "^8.0.3",
64+
"axios": "^1.5.0",
65+
"cheerio": "^1.0.0-rc.12",
66+
"fastify": "^4.22.2",
67+
"header-generator": "^2.1.39",
68+
"round-robin-js": "^3.0.5"
4769
},
4870
"devDependencies": {
49-
"@types/cheerio": "^0.22.30",
50-
"@types/node": "^16.3.1",
51-
"@types/qs": "^6.9.7",
52-
"del-cli": "^4.0.1",
53-
"minify-all-js": "github:sProDev/minify-all-js",
54-
"nodemon": "^2.0.12",
55-
"ts-node": "^10.4.0",
56-
"typescript": "^4.5.4"
71+
"@types/cheerio": "^0.22.32",
72+
"@types/node": "^20.5.9",
73+
"commitizen": "^4.3.0",
74+
"cz-conventional-changelog": "^3.3.0",
75+
"husky": "^8.0.3",
76+
"nodemon": "^3.0.1",
77+
"prettier": "^3.0.3",
78+
"ts-node": "^10.9.1",
79+
"typescript": "^5.2.2"
5780
}
5881
}

0 commit comments

Comments
 (0)