@wix/ditto-codegen-public 1.0.46 → 1.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ // A frontend API based on Astor's Server Endpoints (API Routes)
2
+ // See https://docs.astro.build/en/guides/endpoints/#server-endpoints-api-routes
3
+ import type { APIRoute } from "astro";
4
+
5
+ export const GET: APIRoute = async ({ request }) => {
6
+ return new Response(
7
+ JSON.stringify({
8
+ message: `This was a GET to ${request.url}`,
9
+ }),
10
+ );
11
+ };
12
+
13
+ export const POST: APIRoute = async ({ request }) => {
14
+ const body = await request.json();
15
+
16
+ const { name } = body;
17
+
18
+ console.log("name:", name);
19
+
20
+ return new Response(
21
+ JSON.stringify({
22
+ greeting: `Hello ${name}`,
23
+ }),
24
+ {
25
+ status: 200,
26
+ headers: {
27
+ "Content-Type": "application/json",
28
+ },
29
+ },
30
+ );
31
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.46",
3
+ "version": "1.0.48",
4
4
  "description": "AI-powered Wix CLI app generator - standalone executable",
5
5
  "scripts": {
6
6
  "build": "node build.mjs",
@@ -24,5 +24,5 @@
24
24
  "@wix/ditto-codegen": "1.0.0",
25
25
  "esbuild": "^0.25.9"
26
26
  },
27
- "falconPackageHash": "7c7d2461323857981a78949ab4a5a9fdcafedf192742fa80e66bde4a"
27
+ "falconPackageHash": "142105a8caf265293153b444e463722b33906381e198c4ac6a3115aa"
28
28
  }
@@ -1,29 +0,0 @@
1
- /**
2
- This file allows you to call backend APIs from your frontend of this app.
3
- You can generate various API methods including GET, POST, PUT, and DELETE.
4
- To learn more, check out our documentation: https://wix.to/Iabrrso
5
-
6
- Here's how you can call your API from your frontend code:
7
-
8
- import { httpClient } from '@wix/essentials';
9
-
10
- function MyComponent() {
11
- const callMyBackend = async () => {
12
- const res = await httpClient.fetchWithAuth(`${import.meta.env.BASE_API_URL}/my-api`);
13
- console.log(await res.text());
14
- };
15
-
16
- return <button onClick={callMyBackend}>Call backend GET function</button>;
17
- };
18
- */
19
-
20
- export async function GET(req: Request) {
21
- console.log('Log from GET.');
22
- return new Response('Response from GET.');
23
- };
24
-
25
- export async function POST(req: Request) {
26
- const data = await req.json();
27
- console.log('Log POST with body:', data);
28
- return Response.json(data);
29
- };
@@ -1,21 +0,0 @@
1
- /**
2
- This file allows you to define backend functions that you can call from the front end of this app with type-safety.
3
-
4
- Here's how you can call your web method from your frontend code:
5
-
6
- import { multiply } from '<path-to-your-web-methods-directory>/my-web-method.web';
7
-
8
- multiply(3, 4)
9
- .then(result => console.log(result));
10
-
11
- To learn more, check out our documentation: https://wix.to/6LV6Oka.
12
- */
13
-
14
- import { webMethod, Permissions } from '@wix/web-methods';
15
-
16
- export const multiply = webMethod(
17
- Permissions.Anyone,
18
- (a: number, b: number) => {
19
- return a * b;
20
- },
21
- );