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.