Skip to content

Commit

Permalink
Merge pull request #29 from onelikeandidie/documentation/endpoints
Browse files Browse the repository at this point in the history
Added: Endpoints to home endpoint
  • Loading branch information
Unisergius authored Mar 13, 2024
2 parents df3d0b8 + 70a0c1a commit 1ccb8bd
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,41 @@ using express.js
@see Express.js Docs: http://expressjs.com/
*/

const ENDPOINTS = {
"sum": {
"method": "GET",
"params": "/:a/:b",
"example": {
"request": "/sum/6/2",
},
"description": "Adds 2 numbers"
},
"div": {
"method": "GET",
"params": "/:a/:b",
"example": {
"request": "/div/6/2",
},
"description": "Divides a by b"
},
"subtract": {
"method": "GET",
"params": "/:a/:b",
"example": {
"request": "/subtract/6/2",
},
"description": "Subtracts b from a"
},
"multiply": {
"method": "GET",
"params": "/:a/:b",
"example": {
"request": "/multiply/6/2",
},
"description": "Multiply 2 numbers"
},
}

// Create the Express application
const app: Express = express();

Expand All @@ -23,7 +58,10 @@ app.get('/', (_req: Request, res: Response) => {
// With express, we can respond with JSON directly without having to
// `JSON.stringify()` response. You might want to do this if you're building
// an API
res.json({ message: 'Hello World!' });
res.json({
message: 'Hello World!',
endpoints: ENDPOINTS
});
});

// This GET route is very flexible, it will answer any request going to
Expand Down

0 comments on commit 1ccb8bd

Please sign in to comment.