apolodoro
apolodoro
Explore posts from servers
HHono
Created by apolodoro on 7/15/2024 in #help
zValidator Middleware Error
I have literally only implemented the example
import { zValidator } from "@hono/zod-validator";
import { Hono } from "hono";
import { z } from "zod";

const app = new Hono();

const route = app.post(
"/posts",
zValidator(
"form",
z.object({
body: z.string(),
})
),
(c) => {
const validated = c.req.valid("form");
// ... use your validated data
}
);
import { zValidator } from "@hono/zod-validator";
import { Hono } from "hono";
import { z } from "zod";

const app = new Hono();

const route = app.post(
"/posts",
zValidator(
"form",
z.object({
body: z.string(),
})
),
(c) => {
const validated = c.req.valid("form");
// ... use your validated data
}
);
And is giving me this typescript error
Argument of type 'MiddlewareHandler<Env, string, { in: { form: { body: string | File; }; }; out: { form: { body: string; }; }; }>' is not assignable to parameter of type 'H<BlankEnv, "/posts", BlankInput, HandlerResponse<any>>'.
Argument of type 'MiddlewareHandler<Env, string, { in: { form: { body: string | File; }; }; out: { form: { body: string; }; }; }>' is not assignable to parameter of type 'H<BlankEnv, "/posts", BlankInput, HandlerResponse<any>>'.
1 replies
CDCloudflare Developers
Created by apolodoro on 3/14/2024 in #workers-help
TLS Issue - Workers to AWS IoT Core
I am trying to communicate to the AWS IoT core HTTPS endpoint through a cloudflare worker (using hono). I created a certificate and I tested successfully sending a message with curl and the downloaded certificates - https://docs.aws.amazon.com/iot/latest/developerguide/http.html
curl --tlsv1.2 \
--cacert Amazon-root-CA-1.pem \
--cert device.pem.crt \
--key private.pem.key \
--request POST \
--data "{ \"message\": \"Hello, world\" }" \
"https://IoT_data_endpoint:8443/topics/topic?qos=1"
curl --tlsv1.2 \
--cacert Amazon-root-CA-1.pem \
--cert device.pem.crt \
--key private.pem.key \
--request POST \
--data "{ \"message\": \"Hello, world\" }" \
"https://IoT_data_endpoint:8443/topics/topic?qos=1"
Then I configured the binding with wrangler
pnpx wrangler mtls-certificate upload --cert device.pem.crt --key private.pem.key --name AWS_IOT
pnpx wrangler mtls-certificate upload --cert device.pem.crt --key private.pem.key --name AWS_IOT
And then I configured an endpoint in hono
iotPublish.post("/", async (c) => {
try {
let topic = "test";
let message = { message: "hello" };

return await c.env.AWS_IOT.fetch(
`https://xxxxxx.iot.eu-central-1.amazonaws.com:8443/topics/topic?qos=1`,
{
method: "POST",

body: JSON.stringify(message),
}
);
} catch (e) {
console.log(e);
return Response.json({ error: JSON.stringify(e) }, { status: 500 });
}
});
iotPublish.post("/", async (c) => {
try {
let topic = "test";
let message = { message: "hello" };

return await c.env.AWS_IOT.fetch(
`https://xxxxxx.iot.eu-central-1.amazonaws.com:8443/topics/topic?qos=1`,
{
method: "POST",

body: JSON.stringify(message),
}
);
} catch (e) {
console.log(e);
return Response.json({ error: JSON.stringify(e) }, { status: 500 });
}
});
The result is always
{
"message": "Missing authentication",
"traceId": "8c6b18f4-b3d5-42c7-8edb-e2b0bbc09ad3"
}
{
"message": "Missing authentication",
"traceId": "8c6b18f4-b3d5-42c7-8edb-e2b0bbc09ad3"
}
Please help
1 replies
CDCloudflare Developers
Created by apolodoro on 3/13/2024 in #general-help
TLS issue - WORKER to AWS IoT Core
EDIT: THIS WORKS NOW! Just follow the steps bellow... EDIT: Make sure the compatibility_date = "2024-09-30" in your wrangler.toml is at least september 2024. I am trying to communicate to the AWS IoT core HTTPS endpoint through a cloudflare worker (using hono). I created a certificate and I tested successfully sending a message with curl and the downloaded certificates - https://docs.aws.amazon.com/iot/latest/developerguide/http.html
curl --tlsv1.2 \
--cacert Amazon-root-CA-1.pem \
--cert device.pem.crt \
--key private.pem.key \
--request POST \
--data "{ \"message\": \"Hello, world\" }" \
"https://IoT_data_endpoint:8443/topics/topic?qos=1"
curl --tlsv1.2 \
--cacert Amazon-root-CA-1.pem \
--cert device.pem.crt \
--key private.pem.key \
--request POST \
--data "{ \"message\": \"Hello, world\" }" \
"https://IoT_data_endpoint:8443/topics/topic?qos=1"
Then I configured the binding with wrangler
pnpx wrangler mtls-certificate upload --cert device.pem.crt --key private.pem.key --name AWS_IOT
pnpx wrangler mtls-certificate upload --cert device.pem.crt --key private.pem.key --name AWS_IOT
And then I configured an endpoint in hono
iotPublish.post("/", async (c) => {
try {
let topic = "test";
let message = { message: "hello" };

return await c.env.AWS_IOT.fetch(
`https://xxxxxx.iot.eu-central-1.amazonaws.com:8443/topics/topic?qos=1`,
{
method: "POST",

body: JSON.stringify(message),
}
);
} catch (e) {
console.log(e);
return Response.json({ error: JSON.stringify(e) }, { status: 500 });
}
});
iotPublish.post("/", async (c) => {
try {
let topic = "test";
let message = { message: "hello" };

return await c.env.AWS_IOT.fetch(
`https://xxxxxx.iot.eu-central-1.amazonaws.com:8443/topics/topic?qos=1`,
{
method: "POST",

body: JSON.stringify(message),
}
);
} catch (e) {
console.log(e);
return Response.json({ error: JSON.stringify(e) }, { status: 500 });
}
});
The result is always
{
"message": "Missing authentication",
"traceId": "8c6b18f4-b3d5-42c7-8edb-e2b0bbc09ad3"
}
{
"message": "Missing authentication",
"traceId": "8c6b18f4-b3d5-42c7-8edb-e2b0bbc09ad3"
}
Edit: you should get
{"message":"OK","traceId":"f6353148-67b1-707f-c50c-40e723b4c0d4"}
{"message":"OK","traceId":"f6353148-67b1-707f-c50c-40e723b4c0d4"}
Enjoy
21 replies
RRailway
Created by apolodoro on 3/1/2024 in #✋|help
Guacamole allowed?
So we are an irrigation engineering company. We have PLCs in our clients properties and we use guacamole + openvpn to securely allow them to connect to their machines via VNC in a seemless way. We are transitioning a lot of our infrastructure to railway and would like to move both the VPN server as well as the Guacamole service to railway to. However I have seen that both VNC and VPNs are not allowed. Would this be the case for this specific use case?
7 replies