Skip to content

Commit

Permalink
Remove redundant bodyParser dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmwang committed Feb 21, 2023
1 parent be61d75 commit 4595b27
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 8 deletions.
1 change: 0 additions & 1 deletion package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"dependencies": {
"@apollo/server": "^4.1.0",
"@types/mongoose": "^5.7.16",
"body-parser": "^1.20.1",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.18.2",
Expand Down
4 changes: 1 addition & 3 deletions src/bootstrap/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import express, { json } from "express";
import cors from "cors";
import express from "express";
import { expressMiddleware } from "@apollo/server/express4";
import loaders from "./loaders";
import { Config } from "../config";
Expand All @@ -13,7 +12,6 @@ export default async (config: Config) => {

app.use(
"/graphql",
json(),
expressMiddleware(server, {
context: async ({ req }) => ({ token: req.headers.token }),
})
Expand Down
5 changes: 2 additions & 3 deletions src/bootstrap/loaders/express.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import express from "express";
import bodyParser from "body-parser";
import express, { json } from "express";
import cors from "cors";
import helmet from "helmet";

import { config } from "../../config";

export default async (app: express.Application) => {
// Body parser only needed during POST on the graphQL path
app.use(config.graphqlPath, bodyParser.json());
app.use(config.graphqlPath, json());

// Cors configuration
app.use(cors());
Expand Down

0 comments on commit 4595b27

Please sign in to comment.