UNPKG

2.82 kBMarkdownView Raw
1![banner image](https://github.com/RekkyRek/RantScript/raw/master/images/RantScript.png)
2
3### RantScript allows you to access the whole devRant API via JS.
4
5##
6
7### Install
8```javascript
9npm install rantscript
10```
11### Examples
12
13#### Console logging the 10 top posts on devRant:
14
15```javascript
16var devRant = require('rantscript');
17
18devRant
19 .rants('top', 10, 0)
20 .then((response)=>{
21 console.log(response);
22 })
23```
24
25#### Enableing debug mode and compression:
26
27```javascript
28var devRant = require('rantscript');
29devRant.httpSettings.SET_DEBUG(true);
30console.log(devrant.httpSettings.GET_DEBUG());
31//Returns True
32
33devRant.httpSettings.SET_COMPRESS(true);
34console.log(devrant.httpSettings.GET_COMPRESS());
35//Returns True
36```
37#### Logging in and posting a rant:
38
39```javascript
40var devRant = require('rantscript');
41
42//Get authentication token from devRant API
43devRant
44 .login('username', 'password')
45 .then((response)=>{
46 //Then post a rant to devRant with token gotten from previous request.
47
48 devRant.postRant(
49 "Rant Text",
50 "Tags, Separated, By, Commas",
51 response["auth_token"]
52 ).then((resp)=>{
53 //Then console.log the rant data.
54 console.log(resp);
55 })
56 })
57```
58
59##
60
61### All Functions
62| Function | Usage | Description |
63| ------------ | ------------------------------------------------- | ------------------------- |
64| .rants | .rants('sort', limit, skip, token) | Load rants. |
65| .rant | .rant(rant_id) | Load a single rant by id. |
66| .search | .search('search term') | Search on devRant |
67| .profile | .profile('Username') | Load a profile by name |
68| .login | .login('Username','Password') | Get a devRant auth token |
69| .postRant | .postRant('Rant', 'Tags', token) | Post a rant to devRant |
70| .postComment | .postComment('Comment', rant_id, token) | Post a comment to a rant |
71| .vote | .vote(<0 = down & 1 = up>, rant_id, token) | Vote on a rant |
72| .voteComment | .voteComment(<0 = down & 1 = up>, rant_id, token) | Vote on a comment |
73| .httpSettings| See Bellow | Change settings for the http requests|
74
75### All Settings
76| Function | Usage |
77| ------------ | ----------------------------------------------------- |
78| .GET_DEBUG() | Returns the current Debug state. |
79| .SET_DEBUG(true or false) | Enable or disable console.log |
80| .GET_COMPRESS() | Returns the current Compress state. |
81| .SET_COMPRESS(true or false) | Enable or disable compression. |