Skip to content

Commit

Permalink
feat: implement round-robin and refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
sooluh committed Sep 6, 2023
1 parent 2ff2337 commit cfdee44
Show file tree
Hide file tree
Showing 23 changed files with 1,512 additions and 1,796 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.json]
insert_final_newline = ignore

[*.md]
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ko_fi: sooluh
custom: ["https://saweria.co/sooluh", "https://trakteer.id/sooluh"]
custom: ['https://saweria.co/sooluh', 'https://trakteer.id/sooluh']
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
node_modules/
*.js
.vercel/
dist
node_modules
.vercel
.yarn
.vscode

*.log
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ tasks:
command: yarn dev

ports:
- port: 5000
- port: 3000
onOpen: ignore
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

END OF TERMS AND CONDITIONS

Copyright 2019 Suluh Sulistiawan
Copyright 2019 Abu Masyail

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
71 changes: 43 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
![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)
![@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)

## Requirements

- Node.js `>= 16.20.1`
- Yarn `>= 1.22.0`

## Getting Started

Expand All @@ -8,7 +13,7 @@
git clone https://github.com/sooluh/kodepos.git
```

2. Change the current directory to this repository folder
2. Move to the repository directory

```bash
cd kodepos
Expand All @@ -20,7 +25,7 @@
yarn install
```

4. Run the app! (locally)
4. Run locally

- Development mode

Expand All @@ -46,12 +51,19 @@

The fastest way to use it privately on PaaS available

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

## Basic Usage

Base URL : [`http://localhost:5000`](https://kodepos.vercel.app)
Base URL : [`http://localhost:3000`](https://kodepos.vercel.app)

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

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

#### Response

```json
{
"success": true,
"message": "Data search successfully parsed.",
"statusCode": 200,
"code": "OK",
"data": [
{
"province": "Jawa Tengah",
"city": "Purbalingga",
"subdistrict": "Karangjambu",
"urban": "Danasari",
"postalcode": "53357"
"regency": "Purbalingga",
"district": "Karangjambu",
"village": "Danasari",
"code": "53357"
},
{
"province": "Jawa Tengah",
"city": "Tegal",
"subdistrict": "Bojong",
"urban": "Danasari",
"postalcode": "52465"
"regency": "Tegal",
"district": "Bojong",
"village": "Danasari",
"code": "52465"
},
{
"province": "Jawa Tengah",
"city": "Pemalang",
"subdistrict": "Pemalang",
"urban": "Danasari",
"postalcode": "52314"
"regency": "Pemalang",
"district": "Pemalang",
"village": "Danasari",
"code": "52314"
},
{
"province": "Jawa Barat",
"city": "Ciamis",
"subdistrict": "Cisaga",
"urban": "Danasari",
"postalcode": "46386"
"regency": "Ciamis",
"district": "Cisaga",
"village": "Danasari",
"code": "46386"
}
]
}
Expand All @@ -110,16 +122,19 @@ List of awesome projects powered by this API

- [**kodepos-web**](https://github.com/dotslashf/kodepos-web)<br>
Simple web-app for postcode search by [dotslashf](https://github.com/dotslashf)

- [**Kode POS**](https://github.com/AzharRivaldi/Kode-POS-Indonesia)<br>
Indonesia postal code search application (kotlin) by [AzharRivaldi](https://github.com/AzharRivaldi)

### Ready to use!

List of server APIs ready to use publicly

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

### License

Code licensed under [Apache 2.0 License](https://github.com/sooluh/kodepos/blob/main/LICENSE).
This project is licensed under [Apache 2.0 License](https://github.com/sooluh/kodepos/blob/main/LICENSE).
14 changes: 4 additions & 10 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
{
"restartable": "rs",
"ignore": [
".git",
"node_modules/**/node_modules"
],
"verbose": "true",
"watch": [
"src/"
],
"ignore": [".git", "node_modules/**/node_modules"],
"verbose": true,
"watch": ["src"],
"env": {
"NODE_ENV": "development"
},
"legacyWatch": true,
"ext": "ts,json",
"exec": "yarn ts-node"
"exec": "ts-node ./src/app.ts"
}
73 changes: 48 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@sooluh/kodepos",
"version": "2.2.0",
"version": "3.0.0",
"description": "Indonesian postal code search API by place name, village or city",
"main": "src/app.js",
"main": "dist/app.js",
"scripts": {
"prebuild": "del-cli \"./src/*.js\"",
"build": "tsc",
"start": "node ./src/app.js",
"ts-node": "ts-node ./src/app.ts",
"build": "tsc -p tsconfig.json",
"start": "node ./dist/app.js",
"dev": "nodemon",
"postinstall": "yarn build"
"postinstall": "yarn build",
"format": "prettier --write .",
"commit": "git-cz"
},
"keywords": [
"carikodepos",
Expand All @@ -21,13 +21,34 @@
"code",
"kode-pos"
],
"prettier": {
"trailingComma": "es5",
"semi": false,
"singleQuote": true,
"useTabs": false,
"quoteProps": "consistent",
"bracketSpacing": true,
"arrowParens": "always",
"printWidth": 100
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"husky": {
"hooks": {
"pre-commit": "yarn format && git add --all",
"prepare-commit-msg": "exec < /dev/tty && npx cz --hook || true"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/sooluh/kodepos.git"
},
"author": {
"name": "Suluh Sulistiawan",
"email": "suluh.webdevelopers@hotmail.com",
"name": "Abu Masyail",
"email": "suluhs@aol.com",
"url": "https://suluh.my.id"
},
"license": "Apache-2.0",
Expand All @@ -36,23 +57,25 @@
},
"homepage": "https://github.com/sooluh/kodepos",
"dependencies": {
"axios": "^0.21.1",
"cheerio": "^1.0.0-rc.10",
"fastify": "^3.19.0",
"fastify-compress": "^3.6.0",
"fastify-cors": "^6.0.2",
"fastify-prettier": "^1.1.9",
"header-generator": "^1.0.0",
"qs": "^6.10.1"
"@fastify/compress": "^6.4.0",
"@fastify/cors": "^8.3.0",
"@fastify/etag": "^4.2.0",
"@fastify/rate-limit": "^8.0.3",
"axios": "^1.5.0",
"cheerio": "^1.0.0-rc.12",
"fastify": "^4.22.2",
"header-generator": "^2.1.39",
"round-robin-js": "^3.0.5"
},
"devDependencies": {
"@types/cheerio": "^0.22.30",
"@types/node": "^16.3.1",
"@types/qs": "^6.9.7",
"del-cli": "^4.0.1",
"minify-all-js": "github:sProDev/minify-all-js",
"nodemon": "^2.0.12",
"ts-node": "^10.4.0",
"typescript": "^4.5.4"
"@types/cheerio": "^0.22.32",
"@types/node": "^20.5.9",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"husky": "^8.0.3",
"nodemon": "^3.0.1",
"prettier": "^3.0.3",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
}
}
Loading

0 comments on commit cfdee44

Please sign in to comment.