
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
discourse-js
Advanced tools
$ npm i discourse-js
import Discourse from 'discourse-js';
const userApiKey = '<user-api-key-from-discourse>';
const apiUsername = '<user-username-from-discourse>';
const baseUrl = '<your-discourse-url>' || 'http://localhost:3000';
const discourse = new Discourse();
discourse.config({ userApiKey, apiUsername, baseUrl })
discourse.posts
.create({
topic_id: 11, // optional (required for creating a new post on a topic.)
raw: 'Hello World',
imageUri: imageUri, // optional to create a post/topic with an image.
})
.then(res => console.log(res))
.catch(err => console.log(err));
discourse.categories
.getCategory({ cat_id: 'category-id' })
.then(res => console.log(res))
.catch(err => console.log(err));
discourse.getSubcategory
.getCategory({ cat_id: 'category-id', subcat_id: 'subcategory-id' })
.then(res => console.log(res))
.catch(err => console.log(err));
discourse.groups
.getMembers({ group_name: 'group-name' })
.then(res => console.log(res))
.catch(err => console.log(err));
Todo
Todo
discourse.posts
.create({
topic_id: 11, // optional (required for creating a new post on a topic.)
raw: 'Hello World',
imageUri: imageUri, // optional to create a post/topic with an image.
})
.then(res => console.log(res))
.catch(err => console.log(err));
discourse.posts
.like({ id: 72 })
.then(res => console.log(res))
.catch(err => console.log(err));
discourse.posts
.unlike({ id: 72 })
.then(res => console.log(res))
.catch(err => console.log(err));
Note: You can only unlike
a post within 5 - 10 minutes after you have liked
it. Think of unlike
more so like an undo.
See this post here and here for information around the undocumented time limit on unliking a liked post.
discourse.posts
.reply({
topic_id: 72,
raw: 'Hello World',
reply_to_post_number: 14,
})
.then(res => console.log(res))
.catch(err => console.log(err));
discourse.topics
.getTopic({ id })
.then(res => console.log(res)}
.catch(err => console.log(err))
Topics have a chunk size of 20, which mean you will only get 20 posts back in one get. This can cause weird problems with nested replies and long threads. You can override this by passing print: true
. Note this sets the chunk size to 1000. See API: Getting all posts in a topic
discourse.topics
.getTopic({
id,
print: true
})
.then(res => console.log(res)}
.catch(err => console.log(err))
discourse.topics
.deleteTopic({ id })
.then(res => console.log(res)} // Note: delete returns nothing.
.catch(err => console.log(err))
discourse.users
.getUser({ username })
.then(res => console.log(res)}
.catch(err => console.log(err))
This is if you are developing the discourse-js
API locally on your machine.
# Clone the repo
$ git clone git@gitlab.com:theworkshop/discourse-js.git
$ cd discourse-js
$ pwd|pbcopy # Copies the current working directory /path/to/discourse-js/
# cd into the directory you want to test locally.
$ npm install /path/to/discourse-js/
Why not just use npm link
?:
For speed and productivity. Symlinks do not work with React Native 💩📲.
Read more about npm link and why we do this here.
You will also need a Discourse server running. This can be local or running in the cloud.
Bump the version of the package:
yarn version --patch/--minor/--major
Our preversion, version, and postversion will run, create a new tag in git and push it to our remote repository. The updated package will then be published on npm.
MIT
FAQs
A client-side javascript wrapper for the discourse API.
The npm package discourse-js receives a total of 20 weekly downloads. As such, discourse-js popularity was classified as not popular.
We found that discourse-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.