Skip to content

Transfer the values generated by compile-time to runtime. #102

Open

Activity

  1. added
    enhancement
    deducer
    generator
    sdk
    on Dec 18, 2023
  2. jianzs commented on Jan 10, 2024

    @jianzs
    ContributorAuthor

    After #120, this feature becomes available on the cloud platform. However, it's not yet supported in the simulation environment. A redesign of simulator is necessary to accommodate for simulation needs.

    This is an example that leverages this feature, identical to the app-with-prop-access located in the testapps.

    import { Router, Tester, HttpRequest, HttpResponse } from "@plutolang/pluto";
    
    const router = new Router("router");
    
    router.get("/echo", async (req: HttpRequest): Promise<HttpResponse> => {
      const message = req.query["message"] ?? "Hello, Pluto!";
      return {
        statusCode: 200,
        body: message,
      };
    });
    
    const tester = new Tester("e2e");
    
    tester.it("test echo", async () => {
      // Verify the correctness of business logic.
      const res = await fetch(router.url + "/echo?message=Hello%20Pluto!");
      const body = await res.text();
      if (res.status !== 200) {
        throw new Error(`Unexpected status code: ${res.status}`);
      }
      if (body !== "Hello Pluto!") {
        throw new Error(`Unexpected body: ${body}`);
      }
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    deducerenhancementgeneratorsdk

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions