Skip to content

Commit e595e5c

Browse files
committed
add swagger
1 parent d0d6302 commit e595e5c

File tree

6 files changed

+497
-7
lines changed

6 files changed

+497
-7
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ For the development of this project, a flowchart was created as application docu
4545
## Technologies
4646

4747
### Backend (Api)
48-
* Express
48+
* Nodejs
4949
* Typescript
50-
* Firebase (database)
50+
* Express
51+
* Firestore
5152
* Jwt authentication
53+
* Swagger
5254

5355
### Front End
5456
* NextJs

packages/api/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"firebase": "^8.6.8",
2222
"jsonwebtoken": "^8.5.1",
2323
"reflect-metadata": "^0.1.13",
24+
"swagger-ui-express": "^4.1.6",
2425
"uuid": "^8.3.2"
2526
},
2627
"devDependencies": {
@@ -30,6 +31,7 @@
3031
"@types/express": "^4.17.12",
3132
"@types/jsonwebtoken": "^8.5.3",
3233
"@types/node": "^15.14.0",
34+
"@types/swagger-ui-express": "^4.1.3",
3335
"@types/uuid": "^8.3.0",
3436
"@typescript-eslint/eslint-plugin": "^4.28.1",
3537
"@typescript-eslint/parser": "^4.28.1",

packages/api/src/adapters/controllers/pokemonController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class PokemonController {
5050
const pokemon = await this.repository.getOne(id, user, true)
5151

5252
if (pokemon === undefined) {
53-
res.status(500).send({ message: 'Pokemon not found' })
53+
res.status(404).send({ message: 'Pokemon not found' })
5454
return
5555
}
5656

packages/api/src/external/app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import express from 'express'
22
import bodyParser from 'body-parser'
33
import cors from 'cors'
4+
import swaggerUi from 'swagger-ui-express'
45

6+
import * as swaggerDocument from '../swagger.json'
57
import { apiRoutes } from './routes'
68

79
const app = express()
@@ -30,8 +32,6 @@ app.use(cors(options))
3032

3133
app.use(apiRoutes)
3234

33-
app.get('/', (req, res) => {
34-
res.send({ message: 'API' })
35-
})
35+
app.use('/', swaggerUi.serve, swaggerUi.setup(swaggerDocument))
3636

3737
export { app }

0 commit comments

Comments
 (0)