-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
138 additions
and
1 deletion.
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 @@ | ||
@9r3i:registry=https://npm.pkg.github.com |
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 @@ | ||
const { WilayahClient } = require(__dirname+'/wilayah'), | ||
path=process.argv[2]?process.argv[2]:'index', | ||
host=process.argv[3]?process.argv[3] | ||
:'https://9r3i.github.io/wilayah/api/2022/'; | ||
|
||
(async function(){ | ||
wilayah=new WilayahClient(host), | ||
result=await wilayah.fetch(path); | ||
console.log(result); | ||
})(); |
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,29 @@ | ||
{ | ||
"name": "wilayah", | ||
"version": "1.3.0", | ||
"description": "Module wilayah as client and server", | ||
"main": "wilayah.js", | ||
"scripts": { | ||
"start": "node start.js", | ||
"client": "node client.js", | ||
"test": "node test.js" | ||
}, | ||
"keywords": [ | ||
"wilayah", | ||
"daerah", | ||
"database", | ||
"server", | ||
"client", | ||
"json" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/9r3i/wilayah.git" | ||
}, | ||
"publishConfig": { | ||
"registry": "https://npm.pkg.github.com", | ||
"access": "public" | ||
}, | ||
"author": "9r3i", | ||
"license": "MIT" | ||
} |
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
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 @@ | ||
const { WilayahServer } = require(__dirname+'/wilayah'), | ||
port=process.argv[2]&&process.argv[2].match(/^\d+$/) | ||
?process.argv[2]:3000, | ||
host='localhost', | ||
wilserv=new WilayahServer(port,host); |
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,8 @@ | ||
const { WilayahClient } = require(__dirname+'/wilayah'); | ||
|
||
(async function(){ | ||
const host='https://9r3i.github.io/wilayah/api/2022/', | ||
wilayah=new WilayahClient(host), | ||
result=await wilayah.fetch('index'); | ||
console.log(result); | ||
})(); |
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 @@ | ||
/* WilayahClient */ | ||
function WilayahClient(host){ | ||
this.version='1.0.1'; | ||
this.host=host?host:'https://9r3i.github.io/wilayah/api/2022/'; | ||
this.fetch=function(path){ | ||
const _WilayahClient=this; | ||
return new Promise(resolve=>{ | ||
return _WilayahClient.fetchCB(path,r=>{ | ||
return resolve(r); | ||
}); | ||
}); | ||
}; | ||
this.fetchCB=function(path,cb){ | ||
cb=typeof cb==='function'?cb:function(){}; | ||
if(typeof path!=='string'){return cb(false);} | ||
let url=this.host+path+'.json'; | ||
return fetch(url).then(r=>r.json()).then(cb); | ||
}; | ||
} |
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