Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✅ Login API (MVC Architecture)

A simple login API endpoint built using a scalable MVC architecture. It only handles login, not signup.

Upon successful login, the endpoint returns a JWT token signed with a secret key and valid for 60 minutes.


✅ Features

Architecture

  • Scalable MVC structure with clear separation of concerns.
  • Modular design.

Dependency Injection

  • Uses DI for clean dependency management and testability.

Interfaces

  • Uses interfaces for loose coupling between layers and services.

Error Handling

  • Proper error handling using a custom error structure AppError.

✅ Requirements

  • Go 1.24.x

✅ Setup

1. Clone the repository

git clone https://github.com/ashishDevv/login-task.git

2. Install dependencies

go download

3. Create .env file

APP_PORT=8080
DB_URL=""
AUTH_SECRET=supersecretkey
AUTH_EXPIRY_MIN=60

4. Build the project

go build cmd/main.go

5. Run the server

./main

✅ Routes

POST /login

Request

POST /login
Content-Type: application/json

{
  "email": "ashu@gmail.com",
  "password": "12345"
}

Response

{
  "id": 1,
  "token": "JWT token with 60min expiry"
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages