change routee
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"version": "1.0"
|
||||
},
|
||||
"host": "localhost:5050",
|
||||
"basePath": "/v1",
|
||||
"basePath": "/api/v1",
|
||||
"paths": {
|
||||
"/admin/banner": {
|
||||
"get": {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
basePath: /v1
|
||||
basePath: /api/v1
|
||||
definitions:
|
||||
appresult.AppError:
|
||||
properties:
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"
|
||||
|
||||
BIN
backend/myapp
Executable file
BIN
backend/myapp
Executable file
Binary file not shown.
@@ -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 = {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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(),
|
||||
|
||||
BIN
frontend/node_modules.zip
Normal file
BIN
frontend/node_modules.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user