Converting Express Query Parameters with Zod in Effect Schema

I'd like to convert this code from Zod to Effect Schema as a way to learn the library, but I can't figure it out. I feel like it should be pretty straightforward? Any help would be greatly appreciated:

import express from 'express';
import {z} from 'zod';
const app = express();
const port = 8080;

app.get('/multiply', (req, res) => {
    const query = req.query as unknown;
    const parsedQuery = z.object({
        numberOne: z.coerce.number(),
        numberTwo: z.coerce.number(),
    }).safeParse(query);
    if (!parsedQuery.success) {
        res.status(400).send(parsedQuery.error);
        return;
    }
    const {numberOne, numberTwo} = parsedQuery.data;
    const result = numberOne * numberTwo;
    const response = {numberOne, numberTwo, result};
    console.log(response);
    res.send(response);
});

app.listen(port, () => {
    console.log(`Server listening on port ${port}`);
});
Was this page helpful?