Acebots-AI / my-tiny-service

0 stars 1 forks source link

Add endpoint that returns current timestamp #19

Closed artmoskvin closed 4 months ago

artmoskvin commented 4 months ago

The timestamp should have the ISO format

acebots-ai[bot] commented 4 months ago

Based on the project outline, here's a plan for implementing an endpoint that returns the current timestamp in ISO format:

  1. Create a New Endpoint in the Root Router:

    • Since the project structure includes a root.py file under my_tiny_service/api/routers, which already contains a simple endpoint, it's a suitable place to add a new endpoint for returning the current timestamp.
    • This endpoint will be a GET request since it only needs to retrieve information.
  2. Implement the Timestamp Functionality:

    • Within the new endpoint function, use Python's datetime module to get the current time and format it to ISO 8601 format. This can be achieved with datetime.datetime.now().isoformat().
    • Ensure that the endpoint returns this timestamp string in the response.
  3. Update the API Router:

    • Add the new endpoint to the router object in root.py by using the @router.get() decorator. This makes the endpoint accessible via the specified path, e.g., /timestamp.
  4. Test the New Endpoint:

    • Add a new test case in tests/test_api.py to ensure the timestamp endpoint is accessible and returns the correct format. This involves making a request to the new endpoint and verifying the response format and status code.
  5. Documentation and Comments:

    • Document the new endpoint function with a docstring explaining its purpose and the response format. Also, ensure that any new test cases are clearly commented to explain their purpose and expected outcomes.

This plan should guide the implementation of the new feature in a structured and testable manner.

artmoskvin commented 4 months ago

@acedev-ai looks good, please proceed

acebots-ai[bot] commented 4 months ago

The implementation for the new endpoint that returns the current timestamp in ISO format has been completed. Here are the steps that were taken:

  1. A new branch named feature/add-timestamp-endpoint was created.
  2. The endpoint get_current_timestamp was added to my_tiny_service/api/routers/root.py. This endpoint returns the current timestamp in ISO 8601 format.
  3. A test case test_timestamp_endpoint was added to tests/test_api.py to ensure the new endpoint functions as expected.
  4. A pull request has been created for these changes. You can review and merge it here.

This completes the implementation of the requested feature.