This project consists of a license control API and a simple calculator application. The calculator application shuts down when the license period expires.
licensed-calculator/ ├── license-api/ │ ├── Dockerfile │ ├── license-api.js │ ├── package.json │ └── start_time.json └── calculator-app/ ├── Dockerfile ├── calculator-app.js ├── package.json └── public/ └── index.html
## Prerequisites
Ensure you have the following installed:
- Docker
- Docker Compose
- Node.js (for local development)
## Setup and Running
Follow these steps to set up and run the project.
### Step 1: Clone the Repository
```bash
git clone https://github.com/sakiphan/Docker-Licence.git
cd Docker-Licence
docker-compose up --build
This command will start both the license control API and the calculator application.
Open your browser and navigate to http://localhost:3000
to use the calculator application.
The license control API checks the validity of a license for a certain period (in this example, 2 minutes). The API runs at http://localhost:4000/check-license
.
GET /check-license
: Checks if the license is still valid. If the license has expired, it returns a 403 status code.
When the license is valid:
{
"message": "License is valid. Remaining time: 119.99599981307983 seconds"
}
When the license has expired:
{
"message": "License has expired."
}
The calculator application is integrated with the license control API. When the license period expires, the application will shut down.
The calculator has a simple user interface with buttons for digits and basic arithmetic operations.
The application periodically checks the license status every 10 seconds. If the license has expired, it hides the calculator interface and displays an alert message.
- Fork this repository.
- Create a new branch.
- Commit your changes.
- Push to the branch.
- Open a pull request.