change routee

This commit is contained in:
guwandyk committed 2026-08-04 18:01:20 +05:00
1 parent 2dc0d1faa6
commit bd7bdf5867
16 files changed
+47 -41

No files matched your search

Vendored
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -39,7 +39,7 @@ docker compose up -d --build
``` ```
- API: `http://localhost:5050` - API: `http://localhost:5050`
- Base path: `/v1` - Base path: `/api/v1`
- PostgreSQL: host port `5424` - PostgreSQL: host port `5424`
Database migrations (golang-migrate CLI): Database migrations (golang-migrate CLI):
+3 -1
View File
@@ -8,6 +8,7 @@ import (
"bankline/pkg/client/postgresql" "bankline/pkg/client/postgresql"
"bankline/pkg/logging" "bankline/pkg/logging"
"context" "context"
"fmt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/jackc/pgx/v4/pgxpool" "github.com/jackc/pgx/v4/pgxpool"
swaggerFiles "github.com/swaggo/files" swaggerFiles "github.com/swaggo/files"
@@ -27,7 +28,7 @@ import (
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html // @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost:5050 // @host localhost:5050
// @BasePath /v1 // @BasePath /api/v1
// @securityDefinitions.apikey BearerAuth // @securityDefinitions.apikey BearerAuth
// @in header // @in header
@@ -54,6 +55,7 @@ func main() {
func startPostgresql(cfg *config.Config, logger *logging.Logger) *pgxpool.Pool { func startPostgresql(cfg *config.Config, logger *logging.Logger) *pgxpool.Pool {
postgresSQLClient, err := postgresql.NewClient(context.TODO(), 3, cfg.Storage) postgresSQLClient, err := postgresql.NewClient(context.TODO(), 3, cfg.Storage)
if err != nil { if err != nil {
fmt.Println("error", err)
return nil return nil
} }
return postgresSQLClient return postgresSQLClient
+1 -1
View File
@@ -2785,7 +2785,7 @@ const docTemplate = `{
var SwaggerInfo = &swag.Spec{ var SwaggerInfo = &swag.Spec{
Version: "1.0", Version: "1.0",
Host: "localhost:5050", Host: "localhost:5050",
BasePath: "/v1", BasePath: "/api/v1",
Schemes: []string{}, Schemes: []string{},
Title: "Bank Service APIs", Title: "Bank Service APIs",
Description: "Testing Swagger APIs.", Description: "Testing Swagger APIs.",
+1 -1
View File
@@ -16,7 +16,7 @@
"version": "1.0" "version": "1.0"
}, },
"host": "localhost:5050", "host": "localhost:5050",
"basePath": "/v1", "basePath": "/api/v1",
"paths": { "paths": {
"/admin/banner": { "/admin/banner": {
"get": { "get": {
+1 -1
View File
@@ -1,4 +1,4 @@
basePath: /v1 basePath: /api/v1
definitions: definitions:
appresult.AppError: appresult.AppError:
properties: properties:
+1 -1
View File
@@ -1,6 +1,6 @@
// Package ui serves the admin dashboard pages at /admin. // Package ui serves the admin dashboard pages at /admin.
// Pages are template shells; all data is fetched client-side from the // 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 package ui
import ( import (
+9 -9
View File
@@ -32,17 +32,17 @@ import (
) )
const ( const (
authURL = "/v1/admin" authURL = "/api/v1/admin"
categoryURL = "/v1/admin/categories" categoryURL = "/api/v1/admin/categories"
subCategoryURL = "/v1/admin/sub-categories" subCategoryURL = "/api/v1/admin/sub-categories"
settingURL = "/v1/admin/setting" settingURL = "/api/v1/admin/setting"
bannerURL = "/v1/admin/banner" bannerURL = "/api/v1/admin/banner"
newsURL = "/v1/admin/news" newsURL = "/api/v1/admin/news"
staticURL = "/v1/admin/static" staticURL = "/api/v1/admin/static"
currencyURL = "/v1/admin/currency" currencyURL = "/api/v1/admin/currency"
usersURL = "/v1/client/users" usersURL = "/api/v1/client/users"
) )
func Manager(client *pgxpool.Pool, logger *logging.Logger) *gin.Engine { func Manager(client *pgxpool.Pool, logger *logging.Logger) *gin.Engine {
+4
View File
@@ -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"
Executable
BIN
View File
Binary file not shown.
+4 -4
View File
@@ -4,7 +4,7 @@
* - Sends the raw JWT access token in the Authorization header * - Sends the raw JWT access token in the Authorization header
* (the backend middleware expects the bare token, no "Bearer " prefix). * (the backend middleware expects the bare token, no "Bearer " prefix).
* - Unwraps the response envelope { status, message, code, data }. * - 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. * - Throws ApiError with a friendly, human-readable message.
*/ */
(function () { (function () {
@@ -95,7 +95,7 @@
const refreshToken = tokens.refresh; const refreshToken = tokens.refresh;
if (!refreshToken) return false; if (!refreshToken) return false;
try { try {
const response = await fetch("/v1/admin/token", { const response = await fetch("/api/v1/admin/token", {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ refreshToken }), body: JSON.stringify({ refreshToken }),
@@ -116,7 +116,7 @@
/** /**
* Perform an authenticated JSON request. * Perform an authenticated JSON request.
* @param {string} method HTTP method * @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] * @param {{ body?: object, query?: object, formData?: FormData, retried?: boolean }} [options]
*/ */
async function request(method, path, options) { async function request(method, path, options) {
@@ -171,7 +171,7 @@
function upload(file) { function upload(file) {
const formData = new FormData(); const formData = new FormData();
formData.append("file", file); formData.append("file", file);
return request("POST", "/v1/admin/file", { formData }); return request("POST", "/api/v1/admin/file", { formData });
} }
window.Api = { window.Api = {
+2 -2
View File
@@ -15,7 +15,7 @@
/** Sign in and store the token pair. */ /** Sign in and store the token pair. */
async function login(loginValue, password) { async function login(loginValue, password) {
const pair = await Api.post("/v1/admin/login", { const pair = await Api.post("/api/v1/admin/login", {
login: loginValue, login: loginValue,
password: password, password: password,
}); });
@@ -37,7 +37,7 @@
const initialEl = document.getElementById("profile-initial"); const initialEl = document.getElementById("profile-initial");
if (!nameEl) return; if (!nameEl) return;
try { 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"; const fullName = (profile && profile.fullName) || "Admin";
nameEl.textContent = fullName; nameEl.textContent = fullName;
if (avatarEl && profile && profile.avatar) { if (avatarEl && profile && profile.avatar) {
+6 -6
View File
@@ -5,11 +5,11 @@
"use strict"; "use strict";
const CARDS = [ const CARDS = [
{ id: "stat-news", endpoint: "/v1/admin/news", listKey: "news" }, { id: "stat-news", endpoint: "/api/v1/admin/news", listKey: "news" },
{ id: "stat-categories", endpoint: "/v1/admin/categories", listKey: "categories" }, { id: "stat-categories", endpoint: "/api/v1/admin/categories", listKey: "categories" },
{ id: "stat-banners", endpoint: "/v1/admin/banner", listKey: "banners" }, { id: "stat-banners", endpoint: "/api/v1/admin/banner", listKey: "banners" },
{ id: "stat-static", endpoint: "/v1/admin/static", listKey: "statics" }, { id: "stat-static", endpoint: "/api/v1/admin/static", listKey: "statics" },
{ id: "stat-currency", endpoint: "/v1/admin/currency", listKey: "currencies" }, { id: "stat-currency", endpoint: "/api/v1/admin/currency", listKey: "currencies" },
]; ];
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
@@ -37,7 +37,7 @@
const container = document.getElementById("latest-news"); const container = document.getElementById("latest-news");
if (!container) return; if (!container) return;
try { 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) || []; const items = (data && data.news) || [];
if (!items.length) { if (!items.length) {
container.innerHTML = container.innerHTML =
+11 -11
View File
@@ -13,7 +13,7 @@
window.Resources = { window.Resources = {
categories: { categories: {
title: "Categories", title: "Categories",
endpoint: "/v1/admin/categories", endpoint: "/api/v1/admin/categories",
listKey: "categories", listKey: "categories",
searchable: true, searchable: true,
statusToggle: true, statusToggle: true,
@@ -36,19 +36,19 @@
"sub-categories": { "sub-categories": {
title: "Sub-categories", title: "Sub-categories",
endpoint: "/v1/admin/sub-categories", endpoint: "/api/v1/admin/sub-categories",
listKey: "subCategory", listKey: "subCategory",
searchable: true, searchable: true,
statusToggle: 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: { parentFilter: {
label: "Category", label: "Category",
endpoint: "/v1/admin/categories", endpoint: "/api/v1/admin/categories",
listKey: "categories", listKey: "categories",
labelField: "name", labelField: "name",
}, },
listUrl: (state) => "/v1/admin/sub-categories/" + state.parentId, listUrl: (state) => "/api/v1/admin/sub-categories/" + state.parentId,
getOneUrl: (id) => "/v1/admin/sub-categories/" + id + "/edit", getOneUrl: (id) => "/api/v1/admin/sub-categories/" + id + "/edit",
columns: [ columns: [
{ key: "Id", label: "ID", type: "id", sortKey: "id" }, { key: "Id", label: "ID", type: "id", sortKey: "id" },
{ key: "name", label: "Name", type: "lang" }, { key: "name", label: "Name", type: "lang" },
@@ -62,7 +62,7 @@
type: "select", type: "select",
required: true, required: true,
options: { options: {
endpoint: "/v1/admin/categories", endpoint: "/api/v1/admin/categories",
listKey: "categories", listKey: "categories",
valueField: "Id", valueField: "Id",
labelField: "name", labelField: "name",
@@ -80,7 +80,7 @@
banners: { banners: {
title: "Banners", title: "Banners",
endpoint: "/v1/admin/banner", endpoint: "/api/v1/admin/banner",
listKey: "banners", listKey: "banners",
searchable: true, searchable: true,
columns: [ columns: [
@@ -119,7 +119,7 @@
news: { news: {
title: "News", title: "News",
endpoint: "/v1/admin/news", endpoint: "/api/v1/admin/news",
listKey: "news", listKey: "news",
searchable: true, searchable: true,
columns: [ columns: [
@@ -144,7 +144,7 @@
static: { static: {
title: "Static pages", title: "Static pages",
endpoint: "/v1/admin/static", endpoint: "/api/v1/admin/static",
listKey: "statics", listKey: "statics",
searchable: true, searchable: true,
columns: [ columns: [
@@ -184,7 +184,7 @@
currency: { currency: {
title: "Currency", title: "Currency",
endpoint: "/v1/admin/currency", endpoint: "/api/v1/admin/currency",
listKey: "currencies", listKey: "currencies",
searchable: true, searchable: true,
columns: [ columns: [
+3 -3
View File
@@ -1,6 +1,6 @@
/** /**
* Settings page: single-record form backed by * 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 () { (function () {
"use strict"; "use strict";
@@ -26,7 +26,7 @@
async function load() { async function load() {
try { try {
const setting = await Api.get("/v1/admin/setting"); const setting = await Api.get("/api/v1/admin/setting");
if (setting) { if (setting) {
settingId = setting.Id || 1; settingId = setting.Id || 1;
logoPath.value = setting.logoR || ""; logoPath.value = setting.logoR || "";
@@ -68,7 +68,7 @@
errorEl.classList.add("hidden"); errorEl.classList.add("hidden");
UI.setLoading(submitButton, true); UI.setLoading(submitButton, true);
try { 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, logoR: logoPath.value,
phoneNumber: phoneInput.value.trim(), phoneNumber: phoneInput.value.trim(),
faxNumber: faxInput.value.trim(), faxNumber: faxInput.value.trim(),
Binary file not shown.