This project is an API Key Manager application developed using Node.js, Express, and MongoDB. I created this demo project to practice API creation, handling, and Docker management as part of my web application development training. To maximize your learning, I recommend creating a new project and typing each script yourself. Simply copying and pasting won't be as effective. Just being honest here.
- π Sign up and log in.
- ποΈ Generate API keys.
- π View their API keys and usage logs.
- βοΈ Use their API keys to access a sample
/multiply
endpoint.
Login Page:
Dashboard:
- π User Authentication: Secure user signup and login with password hashing.
- π API Key Generation: Generates unique API keys for each user.
- ποΈ API Key Management: Users can view and manage their generated API keys.
- π Usage Logs: Tracks API calls made with each API key.
- π§ͺ Sample API Endpoint: Provides a
/multiply
endpoint that demonstrates API key usage. - π³ Dockerized: Easy setup and deployment with Docker and Docker Compose.
- π³ Docker
- π³ Docker Compose
- Clone the repo:
git clone https://github.com/your-username/api-key-manager.git
- Navigate to the directory:
cd api-key-manager
- Run:
docker-compose up -d
- Access the app:
http://localhost:3000
. - Sign up or log in.
- Generate API keys and view usage logs on the dashboard.
- Use your API keys to access the
/multiply
endpoint.
/auth/signup
(POST): Creates a new user account./auth/login
(POST): Logs in an existing user./api/create-api-key
(POST): Generates a new API key./api/user-data
(GET): Retrieves API keys and usage logs./multiply
(POST): Multiplies two numbers (requires API key).
π Project Structure
api-key-manager/
β
βββ src/
β βββ config/
β β βββ database.js # ποΈ Database connection configuration
β β
β βββ controllers/
β β βββ authController.js # π User authentication logic
β β βββ apiKeyController.js # ποΈ API key management logic
β β βββ multiplyController.js # π§ͺ Sample API endpoint logic
β β
β βββ middleware/
β β βββ auth.js # π Authentication middleware
β β
β βββ models/
β β βββ User.js # π§ User model
β β
β βββ routes/
β β βββ authRoutes.js # πͺ Authentication routes
β β βββ apiKeyRoutes.js # ποΈ API key management routes
β β βββ multiplyRoutes.js # π§ͺ Sample API endpoint route
β β
β βββ app.js # βοΈ Main application file
β
βββ public/
β βββ css/
β β βββ styles.css # π¨ Stylesheets
β β
β βββ js/
β β βββ main.js # π₯οΈ Client-side JavaScript
β β
β βββ index.html # π Main HTML file
β
βββ .dockerignore
βββ .gitignore
βββ Dockerfile # π³ Dockerfile for building the application image
βββ docker-compose.yml # π³ Docker Compose configuration
βββ package.json # π¦ Project dependencies
βββ README.md # π This file
Contributions are welcome! Please open issues and pull requests.
This project is licensed under the MIT License.