Skip to content

Commit

Permalink
feat: [sc-119] Helmet for express (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
gubbih authored Nov 28, 2023
2 parents 20b2b3a + 72ce97e commit c711a4d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ Starts the api, you would now be able to make calls, look at the api doc
### `yarn test`
Runs all tests (see [jest](https://jestjs.io) for more).

### `yarn martin`
**ToDo cahnge name**
### `yarn prettier`
Formats the code according to the [.prettierrc](https://github.com/5-semesterprojekt/Backend/blob/main/.prettierrc).

<br>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "tsc",
"serve": "node dist/index.js",
"test": "jest --watch",
"martin": "prettier . --write",
"prettier": "prettier . --write",
"check-types": "tsc --noEmit",
"lint": "eslint src/**/*.ts"
},
Expand All @@ -22,6 +22,7 @@
"cors": "^2.8.5",
"express-validator": "^7.0.1",
"firebase": "10.5.0",
"helmet": "^7.1.0",
"jsonwebtoken": "^9.0.2",
"nodemailer": "^6.9.7"
},
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import userRoutes from './routes/users';
import cors from 'cors';
import { errorLogger, errorResponder, invalidPathHandler } from './errorHandler/handlerForExpress';
import { errors } from 'celebrate';
import helmet from 'helmet';

export const app = express();
const port = process.env.PORT || 3000;

app.use(express.json());
app.use(cors());

app.use(helmet());
app.use('/events', eventRoutes);
app.use('/users', userRoutes);

app.get('/', (req: Request, res: Response) => {
res.send(
'Hello dumbass, this is the backend. Go to <a href="https://localhost:3010/">localhost:3010/</a> to see the app',
);
res.send('Hello, this is the backend.');
});
// Catch celebrate validation errors
app.use(errors());
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3026,6 +3026,11 @@ hasown@^2.0.0:
dependencies:
function-bind "^1.1.2"

helmet@^7.1.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/helmet/-/helmet-7.1.0.tgz#287279e00f8a3763d5dccbaf1e5ee39b8c3784ca"
integrity sha512-g+HZqgfbpXdCkme/Cd/mZkV0aV3BZZZSugecH03kl38m/Kmdx8jKjBikpDj2cr+Iynv4KpYEviojNdTJActJAg==

hexoid@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/hexoid/-/hexoid-1.0.0.tgz#ad10c6573fb907de23d9ec63a711267d9dc9bc18"
Expand Down

0 comments on commit c711a4d

Please sign in to comment.