adding env variables and morgan and sentry

This commit is contained in:
talksik
2022-06-03 13:30:06 -07:00
parent da5861086e
commit 6eb8092864
7 changed files with 151 additions and 37 deletions
+19 -4
View File
@@ -1,24 +1,39 @@
import * as Sentry from '@sentry/node';
import * as Tracing from '@sentry/tracing';
/* eslint-disable @typescript-eslint/no-var-requires */
import express, { Application, NextFunction, Request, Response } from 'express';
import cors from 'cors';
import morgan from 'morgan';
const app = express();
app.use(morgan('combined'));
app.use(cors());
app.use(express.json());
app.use((req: Request, res: Response, next: NextFunction) => {
console.log('Time: ', new Date());
next();
});
app.get('/', (req: Request, res: Response) => {
res.send('hello world.');
});
app.use('/api/status', (req: Request, res: Response) => {
res.json({ message: 'wohoo, server is healthy' });
});
const PORT = process.env.PORT || 8080;
const server = app.listen(PORT, () => console.log('express running'));
const server = app.listen(PORT, () =>
console.log(`express running on port | ${PORT} in host machine`),
);
// won't catch any errors here and we don't want it to
console.log();
require('socket.io')(server, {
// todo: add authentication
cors: {
origin: '*',
},
});