Skip to content

Commit

Permalink
added express-async-errors for error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
WagnerWD40 committed Jul 22, 2020
1 parent e343ad7 commit 9d0317d
Show file tree
Hide file tree
Showing 4 changed files with 2,020 additions and 5 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dependencies": {
"@types/node": "^14.0.23",
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"date-fns": "^2.15.0",
"express": "^4.17.1",
"express-async-errors": "^3.1.1",
Expand All @@ -28,6 +29,7 @@
},
"devDependencies": {
"@types/bcryptjs": "^2.4.2",
"@types/cors": "^2.8.6",
"@types/express": "^4.17.7",
"@types/jsonwebtoken": "^8.5.0",
"@types/multer": "^1.4.3",
Expand Down
1 change: 0 additions & 1 deletion src/routes/sessions.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ sessionsRouter.post('/', async (request, response) => {

return response.json({ user, token });


});

export default sessionsRouter;
6 changes: 2 additions & 4 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'reflect-metadata';

import express from 'express';
import 'express-async-errors';
import cors from 'cors';

import routes from './routes';
import uploadConfig from './config/upload';
Expand All @@ -11,17 +12,14 @@ import './database';

const app = express();

app.use(cors());
app.use(express.json());
app.use('/files', express.static(uploadConfig.directory));
app.use(routes);

// Error Handling
app.use(globalErrorHandler);

app.get('/', (req, res) => {
return res.json({ message: 'Hello world!' });
});

app.listen(3333, () => {
console.log('Server started on port 3333.');
});
Loading

0 comments on commit 9d0317d

Please sign in to comment.