Skip to content

Commit

Permalink
Add apidoc
Browse files Browse the repository at this point in the history
  • Loading branch information
edudepetris committed Nov 24, 2018
1 parent 2a10ec1 commit ea2a08b
Show file tree
Hide file tree
Showing 7 changed files with 272 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ benchmarks/graphs
.vscode

dist/

public/apidoc/
todo
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ Start mongodb
Run server
* ```$ yarn watch```

Generate ApiDoc
* ```$ yarn docs```
Open it on `/apidoc/`

[**Aditional docs**](https://gitlab.com/edudepetris/eldolar/wikis/Tutorials-&-Sources)

[**Aditional docs**](https://gitlab.com/edudepetris/eldolar/wikis/Tutorials-&-Sources)

[**Deployed on Heroku**](https://glacial-dusk-89024.herokuapp.com/api/v1/exchanges/now)
7 changes: 7 additions & 0 deletions apidoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "El Dolar",
"version": "0.1.0",
"description": "",
"title": "",
"url" : "https://api.github.com/v1"
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dependencies": {
"@types/cheerio": "^0.22.9",
"@types/express": "^4.16.0",
"apidoc": "^0.17.7",
"axios": "^0.18.0",
"cheerio": "^1.0.0-rc.2",
"concurrently": "^4.0.1",
Expand All @@ -19,7 +20,9 @@
"test": "mocha -r ts-node/register test/**/*.ts",
"watch-ts": "tsc -w",
"watch-node": "nodemon dist/app.js",
"watch": "concurrently -k -p \"[{name}]\" -n \"TypeScript, Node\" -c \"yello.bold, cyan.bold\" \"yarn run watch-ts\" \"yarn run watch-node\""
"watch": "concurrently -k -p \"[{name}]\" -n \"TypeScript, Node\" -c \"yello.bold, cyan.bold\" \"yarn run watch-ts\" \"yarn run watch-node\"",
"docs": "apidoc -i src/ -o public/apidoc/"

},
"devDependencies": {
"@types/chai": "^4.1.5",
Expand Down
3 changes: 3 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ app.set("port", process.env.PORT || 3000);
// routers
app.use('/api/v1/exchanges', ExchangeRouter)

// apidoc
app.use(express.static('public'));

// start
app.listen(app.get("port"), () => {
console.log("App is running on localhost:%d", app.get("port"));
Expand Down
20 changes: 19 additions & 1 deletion src/routers/exchangeRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,25 @@ import FetchNewExchangeService from '../services/fetchNewExchangeService';

const router: Router = Router();

// - GET /exchanges/now # returns all exchanges
/**
* @api {get} /exchanges/new Request Current exchange information
* @apiName GetExchange
* @apiGroup Exchange
*
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {
* "banks":[
* {
* "buy":{"$numberDecimal":"36.7"},
* "sell":{"$numberDecimal":"38.5"},"
* "name":"Nación"
* },
* ...
* ]
* }
*/

function exchange(req: Request, res: Response) : void {
Exchange.findOne({}).sort('-createdAt')
.then((exchange : IExchange) => {
Expand Down
Loading

0 comments on commit ea2a08b

Please sign in to comment.