Steam Login App with NestJS
This project is a NestJS application that allows users to authenticate using their Steam account and retrieve their profile and inventory data.
Table of Contents
Installation
-
Clone the repository:
git clone https://github.com/HDTN/steam-login-app.git cd steam-login-app -
Install dependencies:
-
Set up environment variables: Create a
.envfile in the root directory and add your Steam API key and session secret:STEAM_API_KEY=your_steam_api_key_here SESSION_SECRET=your_session_secret
Usage
-
Start the application:
-
Navigate to
http://localhost:3000/auth/steamto initiate the Steam login process. -
Check the profile and inventory endpoints:
curl http://localhost:3000/auth/profile/{steamId} curl http://localhost:3000/steam/inventory/{steamId}
Project Structure
src/ ├── auth/ │ ├── auth.controller.ts │ ├── auth.module.ts │ ├── auth.service.ts │ └── steam.strategy.ts ├── steam/ │ ├── steam.controller.ts │ ├── steam.service.ts │ └── steam.module.ts ├── main.ts └── app.module.ts
- auth.controller.ts: Handles the authentication routes.
- auth.module.ts: Authentication module.
- auth.service.ts: Contains business logic for validating and fetching user data from Steam.
- steam.strategy.ts: Passport strategy for Steam OpenID authentication.
- steam.controller.ts: Handles the inventory routes.
- steam.service.ts: Contains business logic for fetching user inventory from Steam.
- main.ts: Entry point of the application.
- app.module.ts: Root module of the application.
Endpoints
GET /auth/steam: Initiates Steam login.GET /auth/steam/return: Callback endpoint for Steam login.GET /auth/success: Endpoint to confirm successful login.GET /auth/profile/:steamId: Fetches the user's Steam profile.GET /steam/inventory/:steamId: Fetches the user's CS2 inventory.
Environment Variables
STEAM_API_KEY: Your Steam API key. You can get it from Steam Web API Key.SESSION_SECRET: A secret key for session encryption.
Contributing
- Fork the repository.
- Create a new branch:
git checkout -b feature-name
- Make your changes.
- Commit your changes:
git commit -m 'Add feature name' - Push to the branch:
git push origin feature-name
- Create a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to customize this README according to your project's requirements.