Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from mzmessenger/module
Browse files Browse the repository at this point in the history
Module
  • Loading branch information
koh110 authored Apr 25, 2020
2 parents 447229c + 9914e0c commit 604b02b
Show file tree
Hide file tree
Showing 7 changed files with 641 additions and 439 deletions.
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
INTERNAL_API='http://localhost:3001/api/internal/socket'
INTERNAL_API='http://localhost:3001/api/internal/socket'
REDIS_HOST=127.0.0.1
2 changes: 1 addition & 1 deletion .github/workflows/mzm-socket.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [12.x]
node-version: [14.x]

steps:
- uses: actions/checkout@v2
Expand Down
1,041 changes: 618 additions & 423 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@
"dependencies": {
"bunyan": "^1.8.12",
"dotenv": "^8.2.0",
"ioredis": "^4.16.2",
"ioredis": "^4.16.3",
"request": "^2.88.2",
"uuid": "^7.0.3",
"ws": "^7.2.3"
"ws": "^7.2.5"
},
"devDependencies": {
"@types/bunyan": "^1.8.6",
"@types/ioredis": "^4.14.9",
"@types/jest": "^25.2.1",
"@types/node": "^13.11.1",
"@types/node": "^13.13.2",
"@types/request": "^2.48.4",
"@types/ws": "^7.2.4",
"@typescript-eslint/eslint-plugin": "^2.28.0",
"@typescript-eslint/parser": "^2.28.0",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@typescript-eslint/parser": "^2.29.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-prettier": "^3.1.3",
"jest": "^25.3.0",
"prettier": "^2.0.4",
"jest": "^25.4.0",
"prettier": "^2.0.5",
"rmtcmd": "^0.3.0",
"ts-jest": "^25.3.1",
"ts-jest": "^25.4.0",
"typescript": "^3.8.3"
}
}
7 changes: 7 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ export const WORKER_NUM = 2
export const SOCKET_LISTEN = 3000

export const INTERNAL_API_URL = process.env.INTERNAL_API

export const redis = {
options: {
host: process.env.REDIS_HOST,
enableOfflineQueue: false
}
}
7 changes: 3 additions & 4 deletions src/lib/redis.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Redis from 'ioredis'
const redis = new Redis({
host: '127.0.0.1',
enableOfflineQueue: true
})
import * as config from '../config'

const redis = new Redis(config.redis.options)

export default redis
2 changes: 1 addition & 1 deletion src/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (cluster.isMaster) {
cluster.fork()
})
} else {
redis.on('connect', async () => {
redis.on('ready', async () => {
const wss = new WebSocket.Server(
{
port: SOCKET_LISTEN
Expand Down

0 comments on commit 604b02b

Please sign in to comment.