create account

[Utopian.js] - Final Release with all features added by ms10398

View this thread on: hive.blogpeakd.comecency.com
· @ms10398 · (edited)
$142.77
[Utopian.js] - Final Release with all features added
## New Features
### What feature(s) did you add?
Now the library has more functions like - 
- getPost() by username and permlink
- getPostURL() by postID
- getPostsByAuthor by username
- getPostsByGithubProject

### How did you implement it/them?
For this functions there was following lines of code-
````js
utopian.getPost = function (username, permlink) {
	return new Promise(function (resolve, reject) {
		$.ajax({
			url: ENDPOINT_POST + '/' + username + '/' + permlink,
			success: function success(data) {
				resolve(data);
			},
			error: function error(xhr, status, _error6) {
				reject(_error6);
			}
		});
	});
};
 utopian.getPostURL = function (postID) {
	return new Promise(function (resolve, reject) {
		$.ajax({
			url: ENDPOINT_POST + '/byid/' + postID,
			success: function success(data) {
				resolve('https://utopian.io' + data.url);
			},
			error: function error(xhr, status, _error7) {
				reject(_error7);
			}
		});
	});
};
utopian.getPostsByAuthor = (username, options={}) => {
  	let ENDPOINT_POSTS = ENDPOINT_POST
 
  if (options.limit > 20 || options.limit < 1) {
    options.limit = 20
  }
 
  if (Object.keys(options).length === 0) {
    options.limit = 20
    options.skip = 0
  }
  options.section = 'author'
  options.author = username
  ENDPOINT_POSTS+= '?';
  for(let x in options)
  {
  	ENDPOINT_POSTS = `${ENDPOINT_POSTS}` + `${x}=${options[x]}&`
  }
  ENDPOINT_POSTS = ENDPOINT_POSTS.slice(0,-1)
  return new Promise((resolve, reject) => {
	$.ajax(
		{
			url: ENDPOINT_POSTS,
			success: function(result) {
		        resolve(result);
		    },
		    error: function(xhr, status, error) {
		    	reject(error)
		    }
		})
	})
}
utopian.getPostsByGithubProject = (repoName, options) => {
  return new Promise((resolve, reject) => {
    return getGithubRepoIdByRepoName(repoName)
      .then(projectId => {
        return utopian.getPosts(Object.assign({
          section: 'project',
          sortBy: 'created',
          platform: 'github',
          projectId,
          type: 'all'
        }, options || {})).then(resolve).catch(reject)
      }).catch(reject)
  })
}
````

### Roadmap
This would be its alpha release and maybe more features would be added if there are more endpoints added to the API or requested by the users.
- How to contribute?
You may contribute to the repository by forking it and making a PR.
PR's are always welcome :)

Thanks for reading.

<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@ms10398/utopian-js-final-release-with-all-features-added">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍  , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorms10398
permlinkutopian-js-final-release-with-all-features-added
categoryutopian-io
json_metadata"{"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":121041333,"name":"utopian.js","full_name":"utopian-io/utopian.js","html_url":"https://github.com/utopian-io/utopian.js","fork":false,"owner":{"login":"utopian-io"}},"pullRequests":[{"url":"https://api.github.com/repos/utopian-io/utopian.js/pulls/2","id":168456243,"html_url":"https://github.com/utopian-io/utopian.js/pull/2","diff_url":"https://github.com/utopian-io/utopian.js/pull/2.diff","patch_url":"https://github.com/utopian-io/utopian.js/pull/2.patch","issue_url":"https://api.github.com/repos/utopian-io/utopian.js/issues/2","number":2,"state":"closed","locked":false,"title":"More features added","user":{"login":"ms10398","id":26259547,"avatar_url":"https://avatars0.githubusercontent.com/u/26259547?v=4","gravatar_id":"","url":"https://api.github.com/users/ms10398","html_url":"https://github.com/ms10398","followers_url":"https://api.github.com/users/ms10398/followers","following_url":"https://api.github.com/users/ms10398/following{/other_user}","gists_url":"https://api.github.com/users/ms10398/gists{/gist_id}","starred_url":"https://api.github.com/users/ms10398/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ms10398/subscriptions","organizations_url":"https://api.github.com/users/ms10398/orgs","repos_url":"https://api.github.com/users/ms10398/repos","events_url":"https://api.github.com/users/ms10398/events{/privacy}","received_events_url":"https://api.github.com/users/ms10398/received_events","type":"User","site_admin":false},"body":"@wehmoen Please review","created_at":"2018-02-11T14:37:50Z","updated_at":"2018-02-11T23:09:19Z","closed_at":"2018-02-11T23:09:19Z","merged_at":"2018-02-11T23:09:19Z","merge_commit_sha":"7ef75bf1e46cb1282cde7d095624b89a7b77dbcc","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/utopian-io/utopian.js/pulls/2/commits","review_comments_url":"https://api.github.com/repos/utopian-io/utopian.js/pulls/2/comments","review_comment_url":"https://api.github.com/repos/utopian-io/utopian.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/utopian-io/utopian.js/issues/2/comments","statuses_url":"https://api.github.com/repos/utopian-io/utopian.js/statuses/194bdd02ba673530722489d953eb8f326437de6c","head":{"label":"ms10398:master","ref":"master","sha":"194bdd02ba673530722489d953eb8f326437de6c","user":{"login":"ms10398","id":26259547,"avatar_url":"https://avatars0.githubusercontent.com/u/26259547?v=4","gravatar_id":"","url":"https://api.github.com/users/ms10398","html_url":"https://github.com/ms10398","followers_url":"https://api.github.com/users/ms10398/followers","following_url":"https://api.github.com/users/ms10398/following{/other_user}","gists_url":"https://api.github.com/users/ms10398/gists{/gist_id}","starred_url":"https://api.github.com/users/ms10398/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ms10398/subscriptions","organizations_url":"https://api.github.com/users/ms10398/orgs","repos_url":"https://api.github.com/users/ms10398/repos","events_url":"https://api.github.com/users/ms10398/events{/privacy}","received_events_url":"https://api.github.com/users/ms10398/received_events","type":"User","site_admin":false},"repo":{"id":121104982,"name":"utopian.js","full_name":"ms10398/utopian.js","owner":{"login":"ms10398","id":26259547,"avatar_url":"https://avatars0.githubusercontent.com/u/26259547?v=4","gravatar_id":"","url":"https://api.github.com/users/ms10398","html_url":"https://github.com/ms10398","followers_url":"https://api.github.com/users/ms10398/followers","following_url":"https://api.github.com/users/ms10398/following{/other_user}","gists_url":"https://api.github.com/users/ms10398/gists{/gist_id}","starred_url":"https://api.github.com/users/ms10398/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ms10398/subscriptions","organizations_url":"https://api.github.com/users/ms10398/orgs","repos_url":"https://api.github.com/users/ms10398/repos","events_url":"https://api.github.com/users/ms10398/events{/privacy}","received_events_url":"https://api.github.com/users/ms10398/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ms10398/utopian.js","description":"Utopian JS - The Utopian API ready for browser usage","fork":true,"url":"https://api.github.com/repos/ms10398/utopian.js","forks_url":"https://api.github.com/repos/ms10398/utopian.js/forks","keys_url":"https://api.github.com/repos/ms10398/utopian.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ms10398/utopian.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ms10398/utopian.js/teams","hooks_url":"https://api.github.com/repos/ms10398/utopian.js/hooks","issue_events_url":"https://api.github.com/repos/ms10398/utopian.js/issues/events{/number}","events_url":"https://api.github.com/repos/ms10398/utopian.js/events","assignees_url":"https://api.github.com/repos/ms10398/utopian.js/assignees{/user}","branches_url":"https://api.github.com/repos/ms10398/utopian.js/branches{/branch}","tags_url":"https://api.github.com/repos/ms10398/utopian.js/tags","blobs_url":"https://api.github.com/repos/ms10398/utopian.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ms10398/utopian.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ms10398/utopian.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/ms10398/utopian.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ms10398/utopian.js/statuses/{sha}","languages_url":"https://api.github.com/repos/ms10398/utopian.js/languages","stargazers_url":"https://api.github.com/repos/ms10398/utopian.js/stargazers","contributors_url":"https://api.github.com/repos/ms10398/utopian.js/contributors","subscribers_url":"https://api.github.com/repos/ms10398/utopian.js/subscribers","subscription_url":"https://api.github.com/repos/ms10398/utopian.js/subscription","commits_url":"https://api.github.com/repos/ms10398/utopian.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/ms10398/utopian.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/ms10398/utopian.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/ms10398/utopian.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/ms10398/utopian.js/contents/{+path}","compare_url":"https://api.github.com/repos/ms10398/utopian.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ms10398/utopian.js/merges","archive_url":"https://api.github.com/repos/ms10398/utopian.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ms10398/utopian.js/downloads","issues_url":"https://api.github.com/repos/ms10398/utopian.js/issues{/number}","pulls_url":"https://api.github.com/repos/ms10398/utopian.js/pulls{/number}","milestones_url":"https://api.github.com/repos/ms10398/utopian.js/milestones{/number}","notifications_url":"https://api.github.com/repos/ms10398/utopian.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ms10398/utopian.js/labels{/name}","releases_url":"https://api.github.com/repos/ms10398/utopian.js/releases{/id}","deployments_url":"https://api.github.com/repos/ms10398/utopian.js/deployments","created_at":"2018-02-11T09:00:51Z","updated_at":"2018-02-11T13:29:26Z","pushed_at":"2018-02-11T14:36:41Z","git_url":"git://github.com/ms10398/utopian.js.git","ssh_url":"git@github.com:ms10398/utopian.js.git","clone_url":"https://github.com/ms10398/utopian.js.git","svn_url":"https://github.com/ms10398/utopian.js","homepage":"","size":9279,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"utopian-io:master","ref":"master","sha":"402fec9de5b92936443da3a5ba971c391f88b47e","user":{"login":"utopian-io","id":18612062,"avatar_url":"https://avatars2.githubusercontent.com/u/18612062?v=4","gravatar_id":"","url":"https://api.github.com/users/utopian-io","html_url":"https://github.com/utopian-io","followers_url":"https://api.github.com/users/utopian-io/followers","following_url":"https://api.github.com/users/utopian-io/following{/other_user}","gists_url":"https://api.github.com/users/utopian-io/gists{/gist_id}","starred_url":"https://api.github.com/users/utopian-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/utopian-io/subscriptions","organizations_url":"https://api.github.com/users/utopian-io/orgs","repos_url":"https://api.github.com/users/utopian-io/repos","events_url":"https://api.github.com/users/utopian-io/events{/privacy}","received_events_url":"https://api.github.com/users/utopian-io/received_events","type":"Organization","site_admin":false},"repo":{"id":121041333,"name":"utopian.js","full_name":"utopian-io/utopian.js","owner":{"login":"utopian-io","id":18612062,"avatar_url":"https://avatars2.githubusercontent.com/u/18612062?v=4","gravatar_id":"","url":"https://api.github.com/users/utopian-io","html_url":"https://github.com/utopian-io","followers_url":"https://api.github.com/users/utopian-io/followers","following_url":"https://api.github.com/users/utopian-io/following{/other_user}","gists_url":"https://api.github.com/users/utopian-io/gists{/gist_id}","starred_url":"https://api.github.com/users/utopian-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/utopian-io/subscriptions","organizations_url":"https://api.github.com/users/utopian-io/orgs","repos_url":"https://api.github.com/users/utopian-io/repos","events_url":"https://api.github.com/users/utopian-io/events{/privacy}","received_events_url":"https://api.github.com/users/utopian-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/utopian-io/utopian.js","description":"Utopian JS - The Utopian API ready for browser usage","fork":false,"url":"https://api.github.com/repos/utopian-io/utopian.js","forks_url":"https://api.github.com/repos/utopian-io/utopian.js/forks","keys_url":"https://api.github.com/repos/utopian-io/utopian.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/utopian-io/utopian.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/utopian-io/utopian.js/teams","hooks_url":"https://api.github.com/repos/utopian-io/utopian.js/hooks","issue_events_url":"https://api.github.com/repos/utopian-io/utopian.js/issues/events{/number}","events_url":"https://api.github.com/repos/utopian-io/utopian.js/events","assignees_url":"https://api.github.com/repos/utopian-io/utopian.js/assignees{/user}","branches_url":"https://api.github.com/repos/utopian-io/utopian.js/branches{/branch}","tags_url":"https://api.github.com/repos/utopian-io/utopian.js/tags","blobs_url":"https://api.github.com/repos/utopian-io/utopian.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/utopian-io/utopian.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/utopian-io/utopian.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/utopian-io/utopian.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/utopian-io/utopian.js/statuses/{sha}","languages_url":"https://api.github.com/repos/utopian-io/utopian.js/languages","stargazers_url":"https://api.github.com/repos/utopian-io/utopian.js/stargazers","contributors_url":"https://api.github.com/repos/utopian-io/utopian.js/contributors","subscribers_url":"https://api.github.com/repos/utopian-io/utopian.js/subscribers","subscription_url":"https://api.github.com/repos/utopian-io/utopian.js/subscription","commits_url":"https://api.github.com/repos/utopian-io/utopian.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/utopian-io/utopian.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/utopian-io/utopian.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/utopian-io/utopian.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/utopian-io/utopian.js/contents/{+path}","compare_url":"https://api.github.com/repos/utopian-io/utopian.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/utopian-io/utopian.js/merges","archive_url":"https://api.github.com/repos/utopian-io/utopian.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/utopian-io/utopian.js/downloads","issues_url":"https://api.github.com/repos/utopian-io/utopian.js/issues{/number}","pulls_url":"https://api.github.com/repos/utopian-io/utopian.js/pulls{/number}","milestones_url":"https://api.github.com/repos/utopian-io/utopian.js/milestones{/number}","notifications_url":"https://api.github.com/repos/utopian-io/utopian.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/utopian-io/utopian.js/labels{/name}","releases_url":"https://api.github.com/repos/utopian-io/utopian.js/releases{/id}","deployments_url":"https://api.github.com/repos/utopian-io/utopian.js/deployments","created_at":"2018-02-10T18:17:15Z","updated_at":"2018-02-10T22:50:19Z","pushed_at":"2018-02-11T23:09:19Z","git_url":"git://github.com/utopian-io/utopian.js.git","ssh_url":"git@github.com:utopian-io/utopian.js.git","clone_url":"https://github.com/utopian-io/utopian.js.git","svn_url":"https://github.com/utopian-io/utopian.js","homepage":"","size":9279,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":2,"open_issues":0,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/utopian-io/utopian.js/pulls/2"},"html":{"href":"https://github.com/utopian-io/utopian.js/pull/2"},"issue":{"href":"https://api.github.com/repos/utopian-io/utopian.js/issues/2"},"comments":{"href":"https://api.github.com/repos/utopian-io/utopian.js/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/utopian-io/utopian.js/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/utopian-io/utopian.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/utopian-io/utopian.js/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/utopian-io/utopian.js/statuses/194bdd02ba673530722489d953eb8f326437de6c"}},"author_association":"COLLABORATOR"}],"platform":"github","type":"development","tags":["utopian-io","utopian-js","library","utopian-api"],"moderator":{"account":"wehmoen","time":"2018-02-12T00:46:35.439Z","reviewed":true,"pending":false,"flagged":false}}"
created2018-02-12 00:46:09
last_update2018-02-12 00:46:36
depth0
children4
last_payout2018-02-19 00:46:09
cashout_time1969-12-31 23:59:59
total_payout_value99.670 HBD
curator_payout_value43.101 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,594
author_reputation27,572,487,973,390
root_title"[Utopian.js] - Final Release with all features added"
beneficiaries
0.
accountutopian.pay
weight2,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id36,794,582
net_rshares23,834,993,844,945
author_curate_reward""
vote details (26)
@utopian-io ·
### Hey @ms10398 I am @utopian-io. I have just upvoted you!
#### Achievements
- You have less than 500 followers. Just gave you a gift to help you succeed!
- Seems like you contribute quite often. AMAZING!
#### Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER!
- <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a>
- <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a>
- Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a>

[![mooncryption-utopian-witness-gif](https://steemitimages.com/DQmYPUuQRptAqNBCQRwQjKWAqWU3zJkL3RXVUtEKVury8up/mooncryption-s-utopian-io-witness-gif.gif)](https://steemit.com/~witnesses)

**Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
properties (22)
authorutopian-io
permlinkre-ms10398-utopian-js-final-release-with-all-features-added-20180212t101748475z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-02-12 10:17:48
last_update2018-02-12 10:17:48
depth1
children0
last_payout2018-02-19 10:17:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,083
author_reputation152,955,367,999,756
root_title"[Utopian.js] - Final Release with all features added"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id36,898,559
net_rshares0
@wehmoen · (edited)
$1.54
 
👍  
properties (23)
authorwehmoen
permlinkre-ms10398-utopian-js-final-release-with-all-features-added-20180212t004647225z
categoryutopian-io
json_metadata{}
created2018-02-12 00:46:48
last_update2020-06-03 07:01:21
depth1
children2
last_payout2018-02-19 00:46:48
cashout_time1969-12-31 23:59:59
total_payout_value1.158 HBD
curator_payout_value0.386 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1
author_reputation86,504,380,503,125
root_title"[Utopian.js] - Final Release with all features added"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id36,794,703
net_rshares209,842,471,464
author_curate_reward""
vote details (1)
@ms10398 ·
Are you flash? :D
properties (22)
authorms10398
permlinkre-wehmoen-re-ms10398-utopian-js-final-release-with-all-features-added-20180212t004756006z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-02-12 00:47:57
last_update2018-02-12 00:47:57
depth2
children0
last_payout2018-02-19 00:47:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length17
author_reputation27,572,487,973,390
root_title"[Utopian.js] - Final Release with all features added"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id36,794,922
net_rshares0
@utopian.tip ·
Hey @wehmoen, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
properties (22)
authorutopian.tip
permlinkre-re-ms10398-utopian-js-final-release-with-all-features-added-20180212t004647225z-20180212t200833
categoryutopian-io
json_metadata""
created2018-02-12 20:08:33
last_update2018-02-12 20:08:33
depth2
children0
last_payout2018-02-19 20:08:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length157
author_reputation238,310,597,885
root_title"[Utopian.js] - Final Release with all features added"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id37,017,169
net_rshares0