diff --git a/.DS_Store b/.DS_Store index 89e23e9..5493d67 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/README.md b/README.md index 8f74d3c..a03ee2c 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ docker compose up -d --build ``` - API: `http://localhost:5050` -- Base path: `/v1` +- Base path: `/api/v1` - PostgreSQL: host port `5424` Database migrations (golang-migrate CLI): diff --git a/backend/app.go b/backend/app.go index 1eb0bac..ad6b001 100755 --- a/backend/app.go +++ b/backend/app.go @@ -8,6 +8,7 @@ import ( "bankline/pkg/client/postgresql" "bankline/pkg/logging" "context" + "fmt" "github.com/gin-gonic/gin" "github.com/jackc/pgx/v4/pgxpool" swaggerFiles "github.com/swaggo/files" @@ -27,7 +28,7 @@ import ( // @license.url http://www.apache.org/licenses/LICENSE-2.0.html // @host localhost:5050 -// @BasePath /v1 +// @BasePath /api/v1 // @securityDefinitions.apikey BearerAuth // @in header @@ -54,6 +55,7 @@ func main() { func startPostgresql(cfg *config.Config, logger *logging.Logger) *pgxpool.Pool { postgresSQLClient, err := postgresql.NewClient(context.TODO(), 3, cfg.Storage) if err != nil { + fmt.Println("error", err) return nil } return postgresSQLClient diff --git a/backend/docs/docs.go b/backend/docs/docs.go index 7be1b7f..cd22cd7 100644 --- a/backend/docs/docs.go +++ b/backend/docs/docs.go @@ -2785,7 +2785,7 @@ const docTemplate = `{ var SwaggerInfo = &swag.Spec{ Version: "1.0", Host: "localhost:5050", - BasePath: "/v1", + BasePath: "/api/v1", Schemes: []string{}, Title: "Bank Service APIs", Description: "Testing Swagger APIs.", diff --git a/backend/docs/swagger.json b/backend/docs/swagger.json index d0e3a35..beff0f6 100644 --- a/backend/docs/swagger.json +++ b/backend/docs/swagger.json @@ -16,7 +16,7 @@ "version": "1.0" }, "host": "localhost:5050", - "basePath": "/v1", + "basePath": "/api/v1", "paths": { "/admin/banner": { "get": { diff --git a/backend/docs/swagger.yaml b/backend/docs/swagger.yaml index 56e4ba1..84f1689 100644 --- a/backend/docs/swagger.yaml +++ b/backend/docs/swagger.yaml @@ -1,4 +1,4 @@ -basePath: /v1 +basePath: /api/v1 definitions: appresult.AppError: properties: diff --git a/backend/internal/admin/ui/handler.go b/backend/internal/admin/ui/handler.go index f047f14..f5cb603 100644 --- a/backend/internal/admin/ui/handler.go +++ b/backend/internal/admin/ui/handler.go @@ -1,6 +1,6 @@ // Package ui serves the admin dashboard pages at /admin. // Pages are template shells; all data is fetched client-side from the -// existing JWT-protected /v1/admin API. +// existing JWT-protected /api/v1/admin API. package ui import ( diff --git a/backend/internal/handlers/manager/manager.go b/backend/internal/handlers/manager/manager.go index 31a706c..38f3667 100755 --- a/backend/internal/handlers/manager/manager.go +++ b/backend/internal/handlers/manager/manager.go @@ -32,17 +32,17 @@ import ( ) const ( - authURL = "/v1/admin" + authURL = "/api/v1/admin" - categoryURL = "/v1/admin/categories" - subCategoryURL = "/v1/admin/sub-categories" - settingURL = "/v1/admin/setting" - bannerURL = "/v1/admin/banner" - newsURL = "/v1/admin/news" - staticURL = "/v1/admin/static" - currencyURL = "/v1/admin/currency" + categoryURL = "/api/v1/admin/categories" + subCategoryURL = "/api/v1/admin/sub-categories" + settingURL = "/api/v1/admin/setting" + bannerURL = "/api/v1/admin/banner" + newsURL = "/api/v1/admin/news" + staticURL = "/api/v1/admin/static" + currencyURL = "/api/v1/admin/currency" - usersURL = "/v1/client/users" + usersURL = "/api/v1/client/users" ) func Manager(client *pgxpool.Pool, logger *logging.Logger) *gin.Engine { diff --git a/backend/logs/all.log b/backend/logs/all.log index e69de29..39b2d7d 100755 --- a/backend/logs/all.log +++ b/backend/logs/all.log @@ -0,0 +1,4 @@ +time="2026-08-04T15:11:49+05:00" level=info msg="read application configuration" func="bankline/internal/config.GetConfig.func1()" file="config.go:40" +time="2026-08-04T15:12:04+05:00" level=info msg="start application" func="main.start()" file="app.go:64" +time="2026-08-04T15:13:01+05:00" level=info msg="read application configuration" func="bankline/internal/config.GetConfig.func1()" file="config.go:40" +time="2026-08-04T15:13:16+05:00" level=info msg="start application" func="main.start()" file="app.go:66" diff --git a/backend/myapp b/backend/myapp new file mode 100755 index 0000000..9268421 Binary files /dev/null and b/backend/myapp differ diff --git a/backend/web/admin/assets/js/api.js b/backend/web/admin/assets/js/api.js index 91bbb30..239f2b7 100644 --- a/backend/web/admin/assets/js/api.js +++ b/backend/web/admin/assets/js/api.js @@ -4,7 +4,7 @@ * - Sends the raw JWT access token in the Authorization header * (the backend middleware expects the bare token, no "Bearer " prefix). * - Unwraps the response envelope { status, message, code, data }. - * - On 401 tries a one-shot refresh via POST /v1/admin/token, then retries. + * - On 401 tries a one-shot refresh via POST /api/v1/admin/token, then retries. * - Throws ApiError with a friendly, human-readable message. */ (function () { @@ -95,7 +95,7 @@ const refreshToken = tokens.refresh; if (!refreshToken) return false; try { - const response = await fetch("/v1/admin/token", { + const response = await fetch("/api/v1/admin/token", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ refreshToken }), @@ -116,7 +116,7 @@ /** * Perform an authenticated JSON request. * @param {string} method HTTP method - * @param {string} path request path, e.g. /v1/admin/news + * @param {string} path request path, e.g. /api/v1/admin/news * @param {{ body?: object, query?: object, formData?: FormData, retried?: boolean }} [options] */ async function request(method, path, options) { @@ -171,7 +171,7 @@ function upload(file) { const formData = new FormData(); formData.append("file", file); - return request("POST", "/v1/admin/file", { formData }); + return request("POST", "/api/v1/admin/file", { formData }); } window.Api = { diff --git a/backend/web/admin/assets/js/auth.js b/backend/web/admin/assets/js/auth.js index f633b7e..acb92d0 100644 --- a/backend/web/admin/assets/js/auth.js +++ b/backend/web/admin/assets/js/auth.js @@ -15,7 +15,7 @@ /** Sign in and store the token pair. */ async function login(loginValue, password) { - const pair = await Api.post("/v1/admin/login", { + const pair = await Api.post("/api/v1/admin/login", { login: loginValue, password: password, }); @@ -37,7 +37,7 @@ const initialEl = document.getElementById("profile-initial"); if (!nameEl) return; try { - const profile = await Api.get("/v1/admin/get-profile"); + const profile = await Api.get("/api/v1/admin/get-profile"); const fullName = (profile && profile.fullName) || "Admin"; nameEl.textContent = fullName; if (avatarEl && profile && profile.avatar) { diff --git a/backend/web/admin/assets/js/dashboard.js b/backend/web/admin/assets/js/dashboard.js index 26fc660..f92f2e0 100644 --- a/backend/web/admin/assets/js/dashboard.js +++ b/backend/web/admin/assets/js/dashboard.js @@ -5,11 +5,11 @@ "use strict"; const CARDS = [ - { id: "stat-news", endpoint: "/v1/admin/news", listKey: "news" }, - { id: "stat-categories", endpoint: "/v1/admin/categories", listKey: "categories" }, - { id: "stat-banners", endpoint: "/v1/admin/banner", listKey: "banners" }, - { id: "stat-static", endpoint: "/v1/admin/static", listKey: "statics" }, - { id: "stat-currency", endpoint: "/v1/admin/currency", listKey: "currencies" }, + { id: "stat-news", endpoint: "/api/v1/admin/news", listKey: "news" }, + { id: "stat-categories", endpoint: "/api/v1/admin/categories", listKey: "categories" }, + { id: "stat-banners", endpoint: "/api/v1/admin/banner", listKey: "banners" }, + { id: "stat-static", endpoint: "/api/v1/admin/static", listKey: "statics" }, + { id: "stat-currency", endpoint: "/api/v1/admin/currency", listKey: "currencies" }, ]; document.addEventListener("DOMContentLoaded", () => { @@ -37,7 +37,7 @@ const container = document.getElementById("latest-news"); if (!container) return; try { - const data = await Api.get("/v1/admin/news", { limit: 5, page: 1 }); + const data = await Api.get("/api/v1/admin/news", { limit: 5, page: 1 }); const items = (data && data.news) || []; if (!items.length) { container.innerHTML = diff --git a/backend/web/admin/assets/js/resources.js b/backend/web/admin/assets/js/resources.js index ec41e42..ea5044e 100644 --- a/backend/web/admin/assets/js/resources.js +++ b/backend/web/admin/assets/js/resources.js @@ -13,7 +13,7 @@ window.Resources = { categories: { title: "Categories", - endpoint: "/v1/admin/categories", + endpoint: "/api/v1/admin/categories", listKey: "categories", searchable: true, statusToggle: true, @@ -36,19 +36,19 @@ "sub-categories": { title: "Sub-categories", - endpoint: "/v1/admin/sub-categories", + endpoint: "/api/v1/admin/sub-categories", listKey: "subCategory", searchable: true, statusToggle: true, - // The list endpoint is scoped by category: GET /v1/admin/sub-categories/:categoryId + // The list endpoint is scoped by category: GET /api/v1/admin/sub-categories/:categoryId parentFilter: { label: "Category", - endpoint: "/v1/admin/categories", + endpoint: "/api/v1/admin/categories", listKey: "categories", labelField: "name", }, - listUrl: (state) => "/v1/admin/sub-categories/" + state.parentId, - getOneUrl: (id) => "/v1/admin/sub-categories/" + id + "/edit", + listUrl: (state) => "/api/v1/admin/sub-categories/" + state.parentId, + getOneUrl: (id) => "/api/v1/admin/sub-categories/" + id + "/edit", columns: [ { key: "Id", label: "ID", type: "id", sortKey: "id" }, { key: "name", label: "Name", type: "lang" }, @@ -62,7 +62,7 @@ type: "select", required: true, options: { - endpoint: "/v1/admin/categories", + endpoint: "/api/v1/admin/categories", listKey: "categories", valueField: "Id", labelField: "name", @@ -80,7 +80,7 @@ banners: { title: "Banners", - endpoint: "/v1/admin/banner", + endpoint: "/api/v1/admin/banner", listKey: "banners", searchable: true, columns: [ @@ -119,7 +119,7 @@ news: { title: "News", - endpoint: "/v1/admin/news", + endpoint: "/api/v1/admin/news", listKey: "news", searchable: true, columns: [ @@ -144,7 +144,7 @@ static: { title: "Static pages", - endpoint: "/v1/admin/static", + endpoint: "/api/v1/admin/static", listKey: "statics", searchable: true, columns: [ @@ -184,7 +184,7 @@ currency: { title: "Currency", - endpoint: "/v1/admin/currency", + endpoint: "/api/v1/admin/currency", listKey: "currencies", searchable: true, columns: [ diff --git a/backend/web/admin/assets/js/settings.js b/backend/web/admin/assets/js/settings.js index c330231..fcf8a0b 100644 --- a/backend/web/admin/assets/js/settings.js +++ b/backend/web/admin/assets/js/settings.js @@ -1,6 +1,6 @@ /** * Settings page: single-record form backed by - * GET /v1/admin/setting and POST /v1/admin/setting/:id. + * GET /api/v1/admin/setting and POST /api/v1/admin/setting/:id. */ (function () { "use strict"; @@ -26,7 +26,7 @@ async function load() { try { - const setting = await Api.get("/v1/admin/setting"); + const setting = await Api.get("/api/v1/admin/setting"); if (setting) { settingId = setting.Id || 1; logoPath.value = setting.logoR || ""; @@ -68,7 +68,7 @@ errorEl.classList.add("hidden"); UI.setLoading(submitButton, true); try { - const saved = await Api.post("/v1/admin/setting/" + (settingId || 1), { + const saved = await Api.post("/api/v1/admin/setting/" + (settingId || 1), { logoR: logoPath.value, phoneNumber: phoneInput.value.trim(), faxNumber: faxInput.value.trim(), diff --git a/frontend/node_modules.zip b/frontend/node_modules.zip new file mode 100644 index 0000000..2aee719 Binary files /dev/null and b/frontend/node_modules.zip differ