chore(server): console feedback at server listening event
This commit is contained in:
parent
6617ece90c
commit
4999207a6e
@ -14,6 +14,7 @@ import { getErrorCb, getListeningCb } from './helpers/server-callbacks'
|
||||
import { registerApis } from './routes/api/register'
|
||||
import { registerWebsocket } from './websocket'
|
||||
import type { Arguments } from './types'
|
||||
import { consoleInfo } from './helpers/errors'
|
||||
|
||||
// TODO: Remove type assertion while keeping correct types
|
||||
const argv = yargs(hideBin(process.argv)).options({
|
||||
@ -49,6 +50,12 @@ if (process.env.NODE_ENV !== 'test') {
|
||||
registerWebsocket(wss)
|
||||
|
||||
/* === Server callbacks === */
|
||||
app.on('mount', a => {
|
||||
console.log(a)
|
||||
})
|
||||
server.on('connect', () => {
|
||||
consoleInfo('Server connected')
|
||||
})
|
||||
server.on('upgrade', (request, socket, head) => {
|
||||
wss.handleUpgrade(request, socket, head, socket => {
|
||||
wss.emit('connection', socket, request)
|
||||
|
@ -2,7 +2,7 @@ import { concat } from 'ramda'
|
||||
|
||||
const prependDeemix = concat('[deemix-server]: ')
|
||||
|
||||
export const consoleInfo = (errorText: string) => console.info(prependDeemix(errorText))
|
||||
export const consoleInfo = (infoText: string) => console.info(prependDeemix(infoText))
|
||||
export const consoleError = (errorText: string) => console.error(prependDeemix(errorText))
|
||||
|
||||
export class BadRequestError extends Error {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import http from 'http'
|
||||
import type { Debugger } from 'debug'
|
||||
import { consoleInfo } from './errors'
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "error" event.
|
||||
@ -41,7 +42,9 @@ export function getListeningCb(server: http.Server, debug: Debugger) {
|
||||
|
||||
if (addr) {
|
||||
const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port
|
||||
debug('Listening on ' + bind)
|
||||
|
||||
debug(`Listening on ${bind}`)
|
||||
consoleInfo(`Listening on ${bind}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user