Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [sc-119] Helmet for express #32

Merged
merged 4 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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