Skip to content

Commit

Permalink
🌈 style: replace private api path
Browse files Browse the repository at this point in the history
  • Loading branch information
shurco committed Aug 8, 2023
1 parent 1baaec0 commit 456d075
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions internal/handlers/private/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// Products is ...
// [get] /api/products
// [get] /api/_/products
func Products(c *fiber.Ctx) error {
db := queries.DB()

Expand All @@ -28,7 +28,7 @@ func Products(c *fiber.Ctx) error {
}

// GetProduct is ...
// [get] /api/products/:product_id
// [get] /api/_/products/:product_id
func Product(c *fiber.Ctx) error {
productID := c.Params("product_id")
db := queries.DB()
Expand Down
14 changes: 7 additions & 7 deletions internal/handlers/private/product.http
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@ Content-Type: application/json

###
# @name products
GET {{host}}/api/products
GET {{host}}/api/_/products
Authorization: Bearer {{signin.response.body.result}}

###
# @name fake_product
GET {{host}}/api/products/123456789012345
GET {{host}}/api/_products/123456789012345
Authorization: Bearer {{signin.response.body.result}}

###
# @name product
GET {{host}}/api/products/fv6c9s9cqzf36sc
GET {{host}}/api/_/products/fv6c9s9cqzf36sc
Authorization: Bearer {{signin.response.body.result}}

###
# @name active
PATCH {{host}}/api/products/active/fv6c9s9cqzf36sc
PATCH {{host}}/api/_/products/active/fv6c9s9cqzf36sc
Authorization: Bearer {{signin.response.body.result}}

###
# @name check
GET {{host}}/api/products/stripe/fv6c9s9cqzf36sc/check
GET {{host}}/api/_/products/stripe/fv6c9s9cqzf36sc/check
Authorization: Bearer {{signin.response.body.result}}


###
# @name image_add
POST {{host}}/api/products/fv6c9s9cqzf36sc/image
POST {{host}}/api/_/products/fv6c9s9cqzf36sc/image
Authorization: Bearer {{signin.response.body.result}}


###
# @name image_delete
DELETE {{host}}/api/products/fv6c9s9cqzf36sc/image/dj9bae53oob0ukj
DELETE {{host}}/api/_/products/fv6c9s9cqzf36sc/image/dj9bae53oob0ukj
Authorization: Bearer {{signin.response.body.result}}
2 changes: 1 addition & 1 deletion internal/routes/api_private_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func ApiPrivateRoutes(c *fiber.App) {
sign.Post("/in", handlers.SignIn)
sign.Post("/out", middleware.JWTProtected(), handlers.SignOut)

product := c.Group("/api/products", middleware.JWTProtected())
product := c.Group("/api/_/products", middleware.JWTProtected())
product.Get("/", handlers.Products)
product.Post("/", handlers.AddProduct)
product.Get("/:product_id<len(15)>", handlers.Product)
Expand Down
2 changes: 1 addition & 1 deletion web/admin/components/form/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default {
const formData = new FormData();
formData.append('document', f);

fetch(`/api/products/${this.productId}/image`, {
fetch(`/api/_/products/${this.productId}/image`, {
credentials: 'include',
method: 'POST',
body: formData,
Expand Down
12 changes: 6 additions & 6 deletions web/admin/products.html
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ <h2 class="text-2xl font-bold text-gray-900 sm:text-3xl">Add</h2>

methods: {
async listProducts() {
const response = await fetch(`/api/products`, {
const response = await fetch(`/api/_/products`, {
credentials: "include",
method: 'GET',
});
Expand All @@ -268,7 +268,7 @@ <h2 class="text-2xl font-bold text-gray-900 sm:text-3xl">Add</h2>
},

async getProduct(id) {
const response = await fetch(`/api/products/${id}`, {
const response = await fetch(`/api/_/products/${id}`, {
credentials: "include",
method: 'GET',
});
Expand All @@ -279,7 +279,7 @@ <h2 class="text-2xl font-bold text-gray-900 sm:text-3xl">Add</h2>
},

async addStripe(index, id) {
const response = await fetch(`/api/products/stripe/${id}`, {
const response = await fetch(`/api/_/products/stripe/${id}`, {
credentials: "include",
method: 'POST',
});
Expand All @@ -299,7 +299,7 @@ <h2 class="text-2xl font-bold text-gray-900 sm:text-3xl">Add</h2>
},

async deleteProduct(index) {
const response = await fetch(`/api/products/${this.products.products[index].id}`, {
const response = await fetch(`/api/_/products/${this.products.products[index].id}`, {
credentials: "include",
method: 'DELETE',
});
Expand All @@ -317,7 +317,7 @@ <h2 class="text-2xl font-bold text-gray-900 sm:text-3xl">Add</h2>
},

async updateProductActive(index) {
const response = await fetch(`/api/products/${this.products.products[index].id}/active`, {
const response = await fetch(`/api/_/products/${this.products.products[index].id}/active`, {
credentials: "include",
method: 'PATCH',
});
Expand All @@ -336,7 +336,7 @@ <h2 class="text-2xl font-bold text-gray-900 sm:text-3xl">Add</h2>

async deleteProductImage(index, product_id) {
const image = this.product.info.images[index]
const response = await fetch(`/api/products/${product_id}/image/${image.id}`, {
const response = await fetch(`/api/_/products/${product_id}/image/${image.id}`, {
credentials: "include",
method: 'DELETE',
});
Expand Down

0 comments on commit 456d075

Please sign in to comment.