This project is intended to showcase the use of a REST api built in GO. Users are allowed to create and edit stories. Stories need to be connected to a user's account. Users are able to share what they have created. A form of expression.
This project is a CRUD REST API connected to a PostgreSQL and Redis database. The system supports Creating, Reading, Updating and Deleting stories.
- Golang version >1.20.0
- Go Fiber
- Google uuid
- Golang PostgreSQL (lib/pq)
- Dot env (joho/godotenv)
- Visual Studio
Simply run git clone https://github.com/tolubydesign/angular-story-backend.git
and go run main.go
.
Location: {{host}}/story
Location: {{host}}/stories
GET /stories
200 Ok
{
"type": "success",
"data": [
{
"id": [id],
"title": "Title of story that we want to look at",
"description": "A small synopsys of the story that is contained in this story",
"content": {
"children": [
{
"children": [
{
"description": "Description of events taking place in the story. This will describe what is happening.",
"id": [id],
"name": "Name for this part of the story."
},
{
"children": [
{
"description": "lorem ipsum",
"id": [id],
"name": "lorem ipsum"
}
],
"description": "Description of events taking place in the story. This will describe what is happening.",
"id": [id],
"name": "lorem ipsum..."
},
],
"description": "Lorem ipsum...",
"id": [id],
"name": "Lorem ipsum..."
},
{
"children": [
{
"description": "Lorem ipsum...",
"id": [id],
"name": "Lorem ipsum..."
}
],
"description": "Lorem ipsum...",
"id": [id],
"name": "Lorem ipsum..."
}
],
"description": "Lorem ipsum...",
"id": [id],
"name": "Lorem ipsum..."
}
},
...
],
"message": "Fetch all stories."
}
GET /story/
{
"id": [id],
}
200 Ok
{
"type": "success",
"data": {
"id": [id],
"title": "text",
"description": "text",
"content": {
"children": [
{
"description": "not set",
"id": [id],
"name": "not set"
}
],
"id": [id],
"name": ""
}
},
"message": "Fetch single story."
}
POST /story
{
"title": "ADDED postman post request title",
"description": "ADDED postman post request description",
"content": {
"children": [
{
"children": null,
"description": "Quisque blandit magna vel lacinia fringilla. Mauris sit amet gravida tellus.",
"id": "ebd00c42-841c-44f2-8e8e-bde095d502c6",
"name": "Porttitor quis ultrices tortor"
},
{
"children": [
{
"children": null,
"description": "Quisque blandit magna vel lacinia fringilla. Mauris sit amet gravida tellus.",
"id": "859da15f-8cbf-4d31-b799-0e1309726534",
"name": "Porttitor quis ultrices tortor"
}
],
"description": "2 Quisque blandit magna vel lacinia fringilla. Mauris sit amet gravida tellus.",
"id": "c37eeaea-23f1-448e-89bd-1c010605c90e",
"name": "2 Porttitor quis ultrices tortor"
}
],
"description": "In aliquet nisi a.",
"id": "7e0d122f-b295-4082-9d7c-242d7b2bd517",
"name": "Nam blandit magna vel lacinia"
}
}
200 Ok
{
"type": "success",
"data": null,
"message": "Database has been updated."
}
DELETE /story/{{id}}
{
"id": [id],
}
200 Ok
{
"type": "success",
"data": null,
"message": "Deleted story with id: [id]"
}
PUT /story
{
"id": [id],
"title": "content",
"description": "description"
}
{
"content": {
"children": [
{
"children": null,
"description": "Lorem Ipsum...",
"id": [id],
"name": "Lorem Ipsum..."
},
{
"children": null,
"description": "Lorem Ipsum...",
"id": [id],
"name": "Lorem Ipsum..."
}
],
"description": "Lorem Ipsum...",
"id": [id],
"name": "Lorem Ipsum..."
}
}
404 Error
or
200 Ok
or ...
{
"type":"success",
"data":null,
"message":"Updated story with id: [id]"
}
- Improved Error Response
- JWT token
- User Profiles
- User login method
This is an educational project. The source code is licensed under the MIT license.
This library is distributed under the MIT license.