A RESTful API written in Java made for sharing articles.
HTTP REQUEST | PATH | FUNCTIONALITY |
---|---|---|
GET | /api/topics | List all topics |
POST | /api/topics | Create new topics |
GET | /api/topics/{topicId} | Get a single topic w/ id |
PUT | /api/topics/{topicId} | Update a single topic w/ id |
DELETE | /api/topics/{topicId} | Delete a single topic w/ id |
GET | /api/topics/{topicId}/articles | Get all articles for single topic w/ id |
POST | /api/topics/{topicId}/articles | Create a new article in the given topic |
GET | /api/topics/{topicId}/articles/{articleId} | List single article in specified topic by Id |
PUT | /api/topics/{topicId}/articles/{articleId} | Update single article in specified topic by Id |
DELETE | /api/topics/{topicId}/articles/{articleId} | Delete single article in specified topic by Id |
GET | /api/topics/{topicId}/articles/{articleId}/comments | List all comments under a single article |
GET | /api/topics/{topicId}/articles/{articleId}/comments/{commentId} | Get single comment under another comment |
POST | /api/topics/{topicId}/articles/{articleId}/comments | Create new comment under given article |
GET | /api/topics/{topicId}/articles/{articleId}/comments/{commentId} | Get a single comment under a single article |
GET | /api/topics/{topicId}/articles/{articleId}/comments/{commentId}/thread | List all comments under another comment |
POST | /api/topics/{topicId}/articles/{articleId}/comments/{commentId} | Create new comment under another comment |
PUT | /api/topics/{topicId}/articles/{articleId}/comments/{commentId} | Update comment under given article |
DELETE | /api/topics/{topicId}/articles/{articleId}/comments/{commentId} | Delete comment under given article |
POST | /auth/users/register | Registers a new user |
POST | /auth/users/login | Logs a user in |
GET | /auth/users/profile | Get user's profile |
GET | /auth/users/profile/all | Get all profiles |
POST | /auth/users/profile | Create a new profile |
PUT | /auth/users/profile/update | Update a profile |
DELETE | /auth/users/profile | Delete a profile |
DELETE | /auth/users/delete/{userId} | Deletes a specified user by Id |
GET | /auth/users | Get a list of users |
PUT | /auth/users/login/changepassword | Change a user's password |
Feeling hungry? Let's create a Lunch
topic to discuss some of your favorite things to eat.
Before we can get around to creating topics, you'll need to register a user first.
At this point we'll assume that you have your dev environment up and running. Go ahead and find your way to your friendly neighborhood Postman and open up a new POST request.
Make sure you're pointing towards http://localhost:9092/auth/users/register and send the following in the body of the request. Quickly now! There's lunch to be discussed.
{
"userName" : "LunchLover",
"emailAddress" : "[email protected]",
"password" : "12345"
}
Make sure you have selected raw and JSON for your Body.
If you get an error saying "Unsupported Media Type", navigate to
your Headers section. In the Key section, add a Key field of Content-Type
and a Value of application/json
.
If you did it right you should see a response like the one below, stating that you created the object. Success!
{
"id": 2,
"userName": "LunchLover",
"emailAddress": "[email protected]",
"userProfile": null,
"topicList": null,
"articleList": null,
"commentList": null
}
We're now one step closer to discussing how much we love lunch!
Now that you're registered, you can log in to receive a JWT token used for authentication.
Change your endpoint to http://localhost:9092/auth/users/login and send the same content as you did to sign up in the body (again, formatted as JSON).
{
"userName" : "LunchLover",
"emailAddress" : "[email protected]",
"password" : "12345"
}
Once you do, you should see a response like so:
{
"jwt": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJMdW5jaG1hbi5sZWNsYWlyZUBlbWFpbC5jb20iLCJleHAiOjE2MTgyMTA3OTIsImlhdCI6MTYxODE3NDc5Mn0.Ct76ylDVo2L7PGdpOWDvZaHCUZSjQdUMo3y9jVAH-Js"
}
Great! Now we can use this to verify to the server that we are who we say we are.
Finally we're all set up to start talking about lunch. I'm starving!
Point your Postman to http://localhost:9092/api/topics/new and type (or copy/paste) the information below in the Body section of your request
{
"title" : "Lunch",
"description" : "My favorite meal of the day!"
}
Hold your horses!! Don't even think about sending it yet. I know you knew this was too good to be true. And it is.
Before we can access this endpoint, we need send along our JWT token so the server can verify that we are who we say we are.
Back in the Headers section of your request, add a field of type Authorization
and in the Value section add Bearer YOUR_JWT_TOKEN_HERE
Finally, we're ready to talk about Lunch. Hit Send.
{
"id": 4,
"name": "Lunch",
"description": "My favorite meal of the day!",
"articleList": null
}
If you've made it up to this point, you should be able to navigate the rest of the API with no problem.
Happy chatting!
- No body required
{
"title" : "Lunch",
"description" : "A place to talk about lunch"
}
Note that an id will automatically be generated for you when you send a POST request
- need to pass specified topic Id in the URL
{
"title" : "Updated title",
"description" : "Updated description"
}
- Not necessary to pass a body, just an Id in the URL
- Not necessary to pass a body
{
"title" : "some title",
"textContent" : "some text"
}
Note that it will automatically generate an Id for you
- Not necessary to have a body
{
"title" : "updated title",
"textContent" : "updated text"
}
- Delete the specified article
- No body necessary
- No body necessary
- No body necessary
{
"textContent" : "some text"
}
{
"textContent" : "some text"
}
- No body necessary
{
"textContent" : "updated text"
}
- No body necessary
{
"userName" : "YOUR_USERNAME",
"emailAddress" : "[email protected]",
"password" : "12345"
}
- No body necessary
- No body necessary
{
"firstName" : "Name",
"lastName" : "lastName",
"profileDescription" : "some text"
}
{
"firstName" : "Name",
"lastName" : "lastName",
"profileDescription" : "some text"
}
- No body necessary
- No body necessary
{
"userName" : "YOUR_USERNAME",
"emailAddress" : "[email protected]",
"password" : "12345"
}
{
"emailAddress" : "YOUR [email protected]",
"oldPassword" : "12345",
"newPassword" : "123456"
}
- Create topics within topics
- Check that user Profile actually deleted
- Finish UserControllerTest