This project is a server application designed to handle HTTP requests for logging and retrieving data. It supports both GET and POST methods and includes features like data transformation using IDCT and hierarchical log storage.
- POST Requests: Save logs with optional data transformation (IDCT).
- GET Requests: Retrieve logs based on UID and date.
- CORS Support: Allows cross-origin requests.
- API Key and UID Validation: Ensures secure access.
- Hierarchical Log Storage: Logs are stored in a structured format based on UID and date.
- Error Handling: Comprehensive error handling for invalid requests and server issues.
- Clone the repository to your local machine.
- Navigate to the project directory.
- Install dependencies (if any) using:
npm install
- Create a
config.jsonfile in the root directory with the following structure:{ "apiKeys": ["your-api-key"], "users": ["user1", "user2"] } - Start the server:
node Server.js
Send a POST request to save logs:
- URL:
http://localhost:3800 - Headers:
x-api-key: Your API key.x-uid: User ID.
- Body (JSON):
{ "values": [1, 2, 3, ...] }
Retrieve logs by sending a GET request:
- URL:
http://localhost:3800?date=YYYY-MM-DD - Headers:
x-api-key: Your API key.x-uid: User ID.
Logs are stored in the logs directory, organized by UID and date.
- IDCT Function: Custom implementation for data transformation.
- Logging: Logs are written to both the terminal and a
server.logfile.
This project is licensed under the MIT License.