Skip to content

Commit

Permalink
add log and comment socket
Browse files Browse the repository at this point in the history
  • Loading branch information
Lisooo790926 committed Nov 1, 2023
1 parent 20f5ba5 commit ae17f4f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
26 changes: 13 additions & 13 deletions packages/relay/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
import TransactionManager from './singletons/TransactionManager'

main().catch((err) => {
console.log(`Uncaught error: ${err}`)
console.error(`Uncaught error: ${err}`)
process.exit(1)
})

Expand Down Expand Up @@ -61,20 +61,20 @@ async function main() {
const app = express()
const httpServer = createServer(app)

const io = new Server(httpServer, {
cors: {
origin: CLIENT_URL,
methods: ['GET', 'POST'],
},
})
// const io = new Server(httpServer, {
// cors: {
// origin: CLIENT_URL,
// methods: ['GET', 'POST'],
// },
// })

io.on('connection', (socket) => {
console.log('a user connected')
// io.on('connection', (socket) => {
// console.log('a user connected')

socket.on('disconnect', () => {
console.log('user disconnected')
})
})
// socket.on('disconnect', () => {
// console.log('user disconnected')
// })
// })

const port = process.env.PORT ?? 8000

Expand Down
1 change: 1 addition & 0 deletions packages/relay/src/routes/counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ async function fetchActions(req, res, db: DB) {

res.json({ counter: counter })
} catch (error: any) {
console.error(error)
res.status(500).json({ error })
}
}
2 changes: 2 additions & 0 deletions packages/relay/src/routes/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default (
}

async function fetchPosts(req, res, db: DB) {
// todo remove this try-catch
try {
if (req.query.query === undefined) {
const posts = await db.findMany('Post', {
Expand All @@ -61,6 +62,7 @@ async function fetchPosts(req, res, db: DB) {

res.json(posts.slice(0, Math.min(LOAD_POST_COUNT, posts.length)))
} catch (error: any) {
console.error(error)
res.status(500).json({ error })
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/relay/src/routes/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default (
)
res.json({ hash })
} catch (error: any) {
console.error(error)
res.status(500).json({ error })
}
})
Expand Down
1 change: 1 addition & 0 deletions packages/relay/src/routes/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default (
error: 'The user has already signed up.',
})
} else {
console.error(error)
res.status(500).json({ error: 'Internal server error' })
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/relay/src/routes/transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default (
)
res.json({ hash })
} catch (error: any) {
console.error(error)
res.status(500).json({ error })
}
})
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/src/routes/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default (

res.redirect(redirectUrl)
} catch (error) {
console.log(error)
console.error(error)
res.redirect(`${CLIENT_URL}/?error=apiError`)
}
})
Expand Down

0 comments on commit ae17f4f

Please sign in to comment.