-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): integrate Sentry for error tracking and performance mon…
…itoring
- Loading branch information
1 parent
c310b61
commit 8af22e1
Showing
23 changed files
with
2,173 additions
and
476 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
node_modules | ||
.env.local | ||
client/dist | ||
dist | ||
*.pem | ||
client_secret_google.json | ||
.dockerignore | ||
Dockerfile | ||
fly.toml | ||
.sentryclirc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
|
||
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e47dd8f8-9001-5778-935f-26c423d1c364")}catch(e){}}(); | ||
import { Router } from 'express'; | ||
import { UserController } from '../controllers/user.js'; | ||
export const userRouter = Router(); | ||
userRouter.get('/', UserController.getAll); | ||
userRouter.get('/metadata', UserController.getUserMetadata); | ||
userRouter.patch('/metadata', UserController.updateMetadata); | ||
//# sourceMappingURL=user.js.map | ||
//# debugId=e47dd8f8-9001-5778-935f-26c423d1c364 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
|
||
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="62622897-5a65-57e6-aca4-f51f534bae6c")}catch(e){}}(); | ||
export {}; | ||
//# sourceMappingURL=chat.js.map | ||
//# debugId=62622897-5a65-57e6-aca4-f51f534bae6c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
|
||
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c29ae288-55da-5678-813f-087d8331c37e")}catch(e){}}(); | ||
export {}; | ||
//# sourceMappingURL=socket.js.map | ||
//# debugId=c29ae288-55da-5678-813f-087d8331c37e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
|
||
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f323123a-586e-5376-8e83-93d61217b5a6")}catch(e){}}(); | ||
export {}; | ||
//# sourceMappingURL=user.js.map | ||
//# debugId=f323123a-586e-5376-8e83-93d61217b5a6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,56 @@ | ||
import express from 'express' | ||
import logger from 'morgan' | ||
import { Server } from 'socket.io' | ||
import { createServer } from 'node:http' | ||
import cors from 'cors' | ||
import dotenv from 'dotenv' | ||
import { userRouter } from './src/router/user.js' | ||
import { createTables } from './src/database/index.js' | ||
import { createClient } from '@libsql/client' | ||
import { SocketRouter } from './src/router/socket.js' | ||
import { ChatRouter } from './src/router/chat.js' | ||
import { checkJwtMiddleware } from './src/middlewares/auth.js' | ||
import { refreshAccessToken } from './src/middlewares/refreshAccessToken.js' | ||
|
||
dotenv.config({ path: '.env.local' }) | ||
const port = process.env.PORT ?? 3000 | ||
const clientDomain = process.env.CLIENT_DOMAIN ?? 'http://localhost:5173' | ||
import './src/utils/instrument.js'; | ||
import express from 'express'; | ||
import logger from 'morgan'; | ||
import { Server } from 'socket.io'; | ||
import { createServer } from 'node:http'; | ||
import cors from 'cors'; | ||
import dotenv from 'dotenv'; | ||
import { userRouter } from './src/router/user.js'; | ||
import { createTables } from './src/database/index.js'; | ||
import { createClient } from '@libsql/client'; | ||
import { SocketRouter } from './src/router/socket.js'; | ||
import { ChatRouter } from './src/router/chat.js'; | ||
import { checkJwtMiddleware } from './src/middlewares/auth.js'; | ||
import { refreshAccessToken } from './src/middlewares/refreshAccessToken.js'; | ||
import * as Sentry from '@sentry/node'; | ||
|
||
dotenv.config({ path: '.env.local' }); | ||
const port = process.env.PORT ?? 3000; | ||
const clientDomain = process.env.CLIENT_DOMAIN ?? 'http://localhost:5173'; | ||
|
||
const client = createClient({ | ||
url: process.env.DB_URL ?? '', | ||
authToken: process.env.DB_AUTH_TOKEN ?? '', | ||
}) | ||
createTables(client) | ||
}); | ||
createTables(client); | ||
|
||
const app = express() | ||
const server = createServer(app) | ||
const app = express(); | ||
const server = createServer(app); | ||
const io = new Server(server, { | ||
cors: { origin: clientDomain }, | ||
maxHttpBufferSize: 2e8, | ||
connectionStateRecovery: { | ||
maxDisconnectionDuration: 2 * 60 * 1000, | ||
skipMiddlewares: true, | ||
}, | ||
}) | ||
}); | ||
|
||
const socketRouter = new SocketRouter(io, client) | ||
const chatRouter = new ChatRouter(client) | ||
const socketRouter = new SocketRouter(io, client); | ||
const chatRouter = new ChatRouter(client); | ||
|
||
app.use(cors({ origin: clientDomain })) | ||
socketRouter.init() | ||
app.use(express.json()) | ||
app.use(logger('dev')) | ||
app.use(cors({ origin: clientDomain })); | ||
socketRouter.init(); | ||
app.use(express.json()); | ||
app.use(logger('dev')); | ||
|
||
app.get('/', (req, res) => res.send('Welcome to Chatify API')) | ||
app.get('/api', (req, res) => res.send('Welcome to Chatify API')) | ||
app.get('/', (req, res) => res.send('Welcome to Chatify API')); | ||
app.get('/api', (req, res) => res.send('Welcome to Chatify API')); | ||
|
||
app.use(checkJwtMiddleware, refreshAccessToken) | ||
app.use('/api/chats', chatRouter.init()) | ||
app.use('/api/users', userRouter) | ||
app.use(checkJwtMiddleware, refreshAccessToken); | ||
app.use('/api/chats', chatRouter.init()); | ||
app.use('/api/users', userRouter); | ||
|
||
app.use((req, res) => res.status(404).send('404 Not Found')) | ||
Sentry.setupExpressErrorHandler(app); | ||
app.use((req, res) => res.status(404).send('404 Not Found')); | ||
|
||
server.listen(port, () => console.log(`Server is running in port ${port}`)) | ||
server.listen(port, () => console.log(`Server is running in port ${port}`)); |
Oops, something went wrong.