chore: improve config files

This commit is contained in:
divlo 2021-03-08 14:33:53 +01:00
parent c7f64a6312
commit 4b95cd4293
12 changed files with 24838 additions and 56 deletions

View File

@ -5,11 +5,7 @@ title: '[Documentation]'
labels: 'documentation' labels: 'documentation'
--- ---
<!-- <!-- Please make sure your issue has not already been fixed. -->
Please make sure your issue has not already been fixed.
Please place an x (no spaces - [x]) in all [ ] that apply.
-->
## Documentation ## Documentation

View File

@ -5,11 +5,7 @@ title: '[Improvement]'
labels: 'improvement' labels: 'improvement'
--- ---
<!-- <!-- Please make sure your issue has not already been fixed. -->
Please make sure your issue has not already been fixed.
Please place an x (no spaces - [x]) in all [ ] that apply.
-->
## Type of Improvement ## Type of Improvement

View File

@ -3,9 +3,7 @@
Please first discuss the change you wish to make via issue before making a change. It might avoid a waste of your time. Please first discuss the change you wish to make via issue before making a change. It might avoid a waste of your time.
Before submitting your contribution, please take a moment to review this document: Before submitting your contribution, please take a moment to review this document:
https://github.com/Thream/socketio-jwt/blob/master/.github/CONTRIBUTING.md https://github.com/Thream/socketio-jwt/blob/master/CONTRIBUTING.md
Please place an x (no spaces - [x]) in all [ ] that apply.
--> -->

View File

@ -27,11 +27,11 @@ jobs:
- name: 'Cache dependencies' - name: 'Cache dependencies'
uses: 'actions/cache@v2.1.4' uses: 'actions/cache@v2.1.4'
with: with:
path: '**/node_modules' path: '.npm'
key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: 'Install dependencies' - name: 'Install dependencies'
run: 'npm install' run: 'npm ci --cache .npm --prefer-offline'
- name: 'Lint' - name: 'Lint'
run: 'npm run lint' run: 'npm run lint'

View File

@ -12,19 +12,25 @@ jobs:
steps: steps:
- uses: 'actions/checkout@v2' - uses: 'actions/checkout@v2'
- name: 'Cache dependencies' - name: Use Node.js ${{ matrix.node-version }}
uses: 'actions/cache@v2.1.4' uses: 'actions/setup-node@v2.1.5'
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/package.json') }}
- uses: 'actions/setup-node@v2.1.5'
with: with:
node-version: 14 node-version: 14
registry-url: 'https://registry.npmjs.org/' registry-url: 'https://registry.npmjs.org/'
- run: 'npm install' - name: 'Cache dependencies'
- run: 'npm run build' uses: 'actions/cache@v2.1.4'
- run: 'npm publish --access public' with:
path: '.npm'
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
- name: 'Install dependencies'
run: 'npm ci --cache .npm --prefer-offline'
- name: 'Build'
run: 'npm run build'
- name: 'Publish package on npm'
run: 'npm publish --access public'
env: env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

15
.gitignore vendored
View File

@ -2,9 +2,7 @@
# dependencies # dependencies
node_modules node_modules
.pnp .npm
.pnp.js
.yarn
# production # production
build build
@ -12,19 +10,8 @@ build
# testing # testing
coverage coverage
# envs
.env
.env.production
# debug # debug
npm-debug.log* npm-debug.log*
yarn-debug.log*
yarn-error.log*
# lockfiles
package-lock.json
yarn.lock
pnpm-lock.yaml
# editors # editors
.vscode .vscode

1
.npmrc
View File

@ -1,2 +1 @@
package-lock=false
save-exact=true save-exact=true

View File

@ -1,2 +0,0 @@
--install.no-lockfile true
save-exact true

View File

@ -97,7 +97,6 @@ const io = new Server(9000)
io.use( io.use(
authorize({ authorize({
secret: 'your secret or public key', secret: 'your secret or public key',
algorithms: ['RS256'],
onAuthentication: async decodedToken => { onAuthentication: async decodedToken => {
// return the object that you want to add to the user property // return the object that you want to add to the user property
// or throw an error if the token is unauthorized // or throw an error if the token is unauthorized
@ -118,7 +117,7 @@ io.on('connection', async (socket) => {
- `secret` is a string containing the secret for HMAC algorithms, or a function that should fetch the secret or public key as shown in the example with `jwks-rsa`. - `secret` is a string containing the secret for HMAC algorithms, or a function that should fetch the secret or public key as shown in the example with `jwks-rsa`.
- `algorithms` (default: `HS256`) - `algorithms` (default: `HS256`)
- `onAuthentication` is a function that will be called with the decodedToken as a parameter after the token is authenticated. Return a value to add to the `user` property in the socket object. - `onAuthentication` is a function that will be called with the `decodedToken` as a parameter after the token is authenticated. Return a value to add to the `user` property in the socket object.
### Client side ### Client side
@ -147,7 +146,7 @@ socket.on('messages', (data) => {
Anyone can help to improve the project, submit a Feature Request, a bug report or even correct a simple spelling mistake. Anyone can help to improve the project, submit a Feature Request, a bug report or even correct a simple spelling mistake.
The steps to contribute can be found in the [CONTRIBUTING.md](./.github/CONTRIBUTING.md) file. The steps to contribute can be found in the [CONTRIBUTING.md](./CONTRIBUTING.md) file.
## 📄 License ## 📄 License

24804
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -60,23 +60,23 @@
"coverageDirectory": "../coverage/" "coverageDirectory": "../coverage/"
}, },
"ts-standard": { "ts-standard": {
"files": [ "ignore": [
"./src/**/*.ts" "build",
"coverage",
"node_modules"
], ],
"envs": [ "envs": [
"node", "node",
"jest" "jest"
] ],
"report": "stylish"
}, },
"scripts": { "scripts": {
"build": "rimraf ./build && tsc", "build": "rimraf ./build && tsc",
"markdownlint": "markdownlint '**/*.md' --dot --ignore node_modules", "markdownlint": "markdownlint '**/*.md' --dot --ignore node_modules",
"lint": "ts-standard | snazzy", "lint": "ts-standard",
"format": "ts-standard --fix | snazzy",
"release": "release-it", "release": "release-it",
"test": "jest", "test": "jest",
"test:watchAll": "jest --watchAll",
"test:clearCache": "jest --clearCache",
"postinstall": "husky install", "postinstall": "husky install",
"prepublishOnly": "pinst --disable", "prepublishOnly": "pinst --disable",
"postpublish": "pinst --enable" "postpublish": "pinst --enable"
@ -105,7 +105,6 @@
"release-it": "14.4.1", "release-it": "14.4.1",
"rimraf": "3.0.2", "rimraf": "3.0.2",
"server-destroy": "1.0.1", "server-destroy": "1.0.1",
"snazzy": "9.0.0",
"socket.io": "3.1.2", "socket.io": "3.1.2",
"socket.io-client": "3.1.2", "socket.io-client": "3.1.2",
"ts-jest": "26.5.3", "ts-jest": "26.5.3",