Skip to content

Commit

Permalink
feat: add cors and morgan logger
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Oct 28, 2023
1 parent 1631521 commit b376db7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"colord": "^2.9.3",
"compose-middleware": "^5.0.1",
"compression": "^1.7.4",
"cors": "^2.8.5",
"croner": "^7.0.1",
"dayjs": "^1.11.9",
"detect-browser": "^5.3.0",
Expand Down Expand Up @@ -83,6 +84,7 @@
"devDependencies": {
"@types/bcryptjs": "^2.4.3",
"@types/compression": "^1.7.2",
"@types/cors": "^2.8.15",
"@types/express": "^4.17.17",
"@types/jsonwebtoken": "^9.0.2",
"@types/lodash": "^4.14.198",
Expand Down
13 changes: 9 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { initSocketio } from './ws';
import { monitorManager } from './model/monitor';
import { settings } from './utils/settings';
import { env } from './utils/env';
import cors from 'cors';

const port = settings.port;

Expand All @@ -36,7 +37,8 @@ monitorManager.startAll();
app.use(compression());
app.use(express.json());
app.use(passport.initialize());
// app.use(morgan('tiny'));
app.use(morgan('tiny'));
app.use(cors());

// http://expressjs.com/en/advanced/best-practice-security.html#at-a-minimum-disable-x-powered-by-header
app.disable('x-powered-by');
Expand Down

0 comments on commit b376db7

Please sign in to comment.