Skip to content

Commit

Permalink
move to /api
Browse files Browse the repository at this point in the history
  • Loading branch information
mudroljub committed Nov 24, 2024
1 parent 37ff3f5 commit 11d1cbb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ Feel free to get involved, suggest or implement new features.

### Public Routes

#### GET [`/quotes/random`](/quotes/random)
#### GET [`/api/quotes/random`](/api/quotes/random)
- **Description**: Fetches a random programming quote.

#### GET [`/quotes?author=Edsger_W._Dijkstra`](/quotes?author=Edsger_W._Dijkstra)
#### GET [`/quotes?page=1&quotesPerPage=20`](/quotes?page=1&quotesPerPage=20)
#### GET [`/quotes`](/quotes)
#### GET [`/api/quotes?author=Edsger_W._Dijkstra`](/api/quotes?author=Edsger_W._Dijkstra)
#### GET [`/api/quotes?page=1&quotesPerPage=20`](/api/quotes?page=1&quotesPerPage=20)
#### GET [`/api/quotes`](/api/quotes)
- **Description**: Retrieves quotes, with optional query parameters:
- `page`: The page number (default: 1).
- `quotesPerPage`: Number of quotes per page (default: 20).
- `author`: Filter quotes by a specific author.

#### GET `/quotes/:id`
#### GET `/api/quotes/:id`
- **Description**: Retrieves a single quote by its unique ID.

---
Expand All @@ -32,33 +32,33 @@ Feel free to get involved, suggest or implement new features.

Access to these routes requires a valid token.

#### POST `/quotes`
#### POST `/api/quotes`
- **Description**: Adds a new quote.
- **Required Parameters** (in JSON body):
- `author`: The name of the author (should match a Wikipedia entry).
- `text`: The quote text.
- **Optional Parameters**:
- `source`: The source or context of the quote.

#### PUT `/quotes/:id`
#### PUT `/api/quotes/:id`
- **Description**: Updates an existing quote by ID.
- **Parameters** (in JSON body):
- `author`, `text`, or `source`.

#### POST `/quotes/vote`
#### POST `/api/quotes/vote`
- **Description**: Votes for a specific quote.
- **Required Parameters** (in JSON body):
- `quoteId`: The ID of the quote.
- `newVote`: A numeric value (1–5).

#### DELETE `/quotes/:id`
#### DELETE `/api/quotes/:id`
- **Description**: Deletes a quote by its unique ID.

---

### Authentication

#### GET `/auth/token`
#### GET `/api/auth/token`
- **Description**: Logs in or registers a new user.
- **Required Parameters** (in JSON body):
- `email`: The user's email address.
Expand Down
4 changes: 2 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import mongoose from 'mongoose'
import { marked } from 'marked'

import { port, domain } from './config/host.js'
import router from './routes/router.js'
import apiRouter from './routes/router.js'
import { normalizeJsonKeys } from './middleware/normalize.js'

const app = express()
Expand All @@ -31,7 +31,7 @@ app.get('/', async(req, res) => {
}
})

app.use('/', router)
app.use('/api/', apiRouter)

// SERVER
app.listen(port, () => console.log(`Serving on ${domain}`))

0 comments on commit 11d1cbb

Please sign in to comment.