Skip to content

NeginSal/api-hub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

API-HUB

A simple Go-based microservice gateway that demonstrates authentication, external API integration, SFTP file handling, MongoDB connection, and Swagger documentation.

✨ Features

JWT-based authentication (/login)

Protected routes (/protected/*)

Fetching and saving LMS data from mock API to MongoDB

Reading file content from SFTP server

Rate limiting & logging middleware

Swagger API docs at /swagger/index.html

⚑ Tech Stack

Golang (Gin framework)

MongoDB Atlas (Cloud database)

JWT for secure authentication

SFTP for file operations

Swagger for API documentation

πŸ“‚ Project Structure

api-hub/

β”œβ”€β”€ cmd/

β”‚ └── main.go

β”œβ”€β”€ internal/

β”‚ β”œβ”€β”€ config/

β”‚ β”œβ”€β”€ handlers/

β”‚ β”œβ”€β”€ middleware/

β”‚ β”œβ”€β”€ models/

β”‚ └── services/

β”œβ”€β”€ docs/

└── go.mod

βœ… How to Run

Clone the repo

Create .env file with:

JWT_SECRET=""

MONGO_URI=mongodb+srv://...your_atlas_uri

Run the app:

go run cmd/main.go

Open Swagger UI:

http://localhost:8080/swagger/index.html

🌐 API Endpoints

Public

POST /login β†’ Get JWT token

Protected (Require Bearer Token)

GET /protected/lms β†’ Fetch and store LMS data

GET /protected/sftp β†’ Download file from SFTP

πŸ“„ Authorize with JWT in Swagger

Call /login and copy the token

Click Authorize in Swagger

Paste: Bearer <your_token>

Now test protected endpoints

πŸ™οΈ Demo Credentials

username: admin

password: 1234

πŸš€ Notes

LMS API uses a mock server

MongoDB connection is cloud-based

SFTP uses Rebex test server

πŸŽ“ License

MIT

About

API Hub - Go Microservice Gateway.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages