Skip to content

Commit

Permalink
deps,actions: update deps and make tweaks (#75)
Browse files Browse the repository at this point in the history
* deps,actions: update deps and make tweaks

- Update dependencies and developer dependencies to their latest
versions.
- Switch from Node-Fetch to Undici.
- Update the GitHub Actions workflows to their latest versions.
- Remove Node.js v12 from the testing matrix as it reached it's EoL
(End-of-Life) stage, and add Node.js v16 and v18 to the testing
matrix.
- Align all examples (in README and JSDocs) to the code style of the
codebase.
- Inline JSDocs that only have a description.
- Format the `typedoc.json` file and remove the usage of the `minimal`
theme as it was removed.
- Move the `APIOptions` interface to the `src/typings.ts` file and
export it so it's shown in the documentation.
- Bump version to 3.1.4.

---------

Co-authored-by: Julian Berryessa <[email protected]>
  • Loading branch information
VoltrexKeyva and jpbberry authored Mar 23, 2023
1 parent a2d9685 commit cc14fb8
Show file tree
Hide file tree
Showing 11 changed files with 248 additions and 334 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [12, 14]
node: [14, 16, 18]
steps:
- uses: actions/checkout@master
- name: Cache node modules
uses: actions/cache@v2
- uses: actions/checkout@v3
- name: Cache node_modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
Expand All @@ -25,12 +25,13 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Setup node
uses: actions/setup-node@v1
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
check-latest: true
registry-url: https://registry.npmjs.org/
- name: Compile typescript
- name: Compile TypeScript
run: npm run build:ci
- name: Lint typescript
- name: Lint TypeScript
run: npm run lint:ci
11 changes: 6 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 18
check-latest: true
registry-url: https://registry.npmjs.org/
- run: npm publish --unsafe-perm
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_SECRET}}
NODE_AUTH_TOKEN: ${{ secrets.NPM_SECRET }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ typings/
.tern-port
package-lock.json
yarn.lock
eslint_report.json
eslint_report.json
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.9.0
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,36 @@ You can also setup webhooks via Topgg.Webhook, look down below at the examples f
If you're looking for an easy way to post your bot's stats (server count, shard count), check out [`topgg-autoposter`](https://npmjs.com/package/topgg-autoposter)

```js
const client = Discord.Client() // Your discord.js client or any other
const { AutoPoster } = require('topgg-autoposter')
const client = Discord.Client(); // Your discord.js client or any other
const { AutoPoster } = require("topgg-autoposter");

AutoPoster('topgg-token', client)
.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
AutoPoster("topgg-token", client).on("posted", () => {
console.log("Posted stats to Top.gg!");
});
```

With this your server count and shard count will be posted to Top.<span>gg

## Webhook server

```js
const express = require('express')
const Topgg = require('@top-gg/sdk')
const express = require("express");
const Topgg = require("@top-gg/sdk");

const app = express() // Your express app
const app = express(); // Your express app

const webhook = new Topgg.Webhook('topggauth123') // add your Top.gg webhook authorization (not bot token)
const webhook = new Topgg.Webhook("topggauth123"); // add your Top.gg webhook authorization (not bot token)

app.post('/dblwebhook', webhook.listener(vote => {
// vote is your vote object
console.log(vote.user) // 221221226561929217
})) // attach the middleware
app.post(
"/dblwebhook",
webhook.listener((vote) => {
// vote is your vote object
console.log(vote.user); // 221221226561929217
})
); // attach the middleware

app.listen(3000) // your port
app.listen(3000); // your port
```

With this example, your webhook dashboard should look like this:
![](https://i.imgur.com/wFlp4Hg.png)
37 changes: 18 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@top-gg/sdk",
"version": "3.1.3",
"version": "3.1.4",
"description": "Official Top.gg Node SDK",
"main": "./dist/index.js",
"scripts": {
"build": "tsc",
"build:ci": "npm i --also=dev && tsc",
"build:ci": "npm i --include=dev && tsc",
"docs": "typedoc",
"prepublishOnly": "npm run build:ci",
"lint": "eslint src/**/*.ts",
Expand All @@ -23,25 +23,24 @@
},
"homepage": "https://topgg.js.org",
"devDependencies": {
"@top-gg/eslint-config": "^0.0.2",
"@types/express": "^4.17.11",
"@types/node": "^14.14.41",
"@types/node-fetch": "^2.5.10",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^24.3.6",
"express": "^4.17.1",
"husky": "^6.0.0",
"lint-staged": "^11.0.0",
"prettier": "^2.3.0",
"typedoc": "^0.21.0",
"typescript": "^4.4.4"
"@top-gg/eslint-config": "^0.0.3",
"@types/express": "^4.17.17",
"@types/node": "^18.15.5",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-jest": "^27.2.1",
"express": "^4.18.2",
"husky": "^8.0.3",
"lint-staged": "^13.2.0",
"prettier": "^2.8.6",
"typedoc": "^0.23.28",
"typescript": "^5.0.2"
},
"dependencies": {
"node-fetch": "^2.6.1",
"raw-body": "^2.4.1"
"raw-body": "^2.5.2",
"undici": "^5.21.0"
},
"types": "./dist/index.d.ts"
}
Loading

0 comments on commit cc14fb8

Please sign in to comment.