Coder Social home page Coder Social logo

Vercel Edge - Zod Openapi about middleware HOT 9 OPEN

draew6 avatar draew6 commented on May 29, 2024
Vercel Edge - Zod Openapi

from middleware.

Comments (9)

yusukebe avatar yusukebe commented on May 29, 2024 1

@draew6

AH, sorry! I only use vercel dev, but when I use vercel command to deploy, it fails.

Screenshot 2024-01-03 at 6 47 10

from middleware.

yusukebe avatar yusukebe commented on May 29, 2024

@draew6

We cannot know with that much information. Please share the minimal code or project to reproduce.

from middleware.

draew6 avatar draew6 commented on May 29, 2024

@yusukebe

app.ts


import { swaggerUI } from '@hono/swagger-ui'
import { OpenAPIHono} from '@hono/zod-openapi'
import { Hono } from 'hono'

const app = new OpenAPIHono()
//const app = new Hono()


app.get("/balance", async (c) => {
    return c.json([])
  })

  app.get('/', swaggerUI({ url: '/doc'}))

export default app

api/index.ts

import { handle } from 'hono/vercel'
import app from '../app.js'

export const config = {
  runtime: 'edge'
}


export default handle(app)

vercel.json

{
  "rewrites": [
    {
      "source": "/(.*)",
      "destination": "/api"
    }
  ]
}

after trying to deploy with vercel command(CLI) its gives me

Error: The Edge Function "api/index" is referencing unsupported modules:
- @HONO: hono/utils/url

It works with Hono instance or if I disable Edge

from middleware.

yusukebe avatar yusukebe commented on May 29, 2024

@draew6

Thanks. But, I can't reproduce the problem. The following project works well!

https://github.com/yusukebe/vercel-zod-openapi

from middleware.

draew6 avatar draew6 commented on May 29, 2024

@yusukebe hmm weird, i just cloned and typed "vercel"
image
did you use "vercel" instead of "vercel dev" ?
What else can I do to debug it?
I am on vercel hobby if it matters

from middleware.

yusukebe avatar yusukebe commented on May 29, 2024

This is certainly an error I've never seen before and don't know how to resolve. Hmm

from middleware.

jxom avatar jxom commented on May 29, 2024

I am also getting the same issue here, along with the hono/jsx/jsx-runtime module.

I think the issue here is that Edge Functions (along with some other bundlers/runtimes) seem to struggle with resolving package.json#exports (at least nested modules – ie. hono/x/y).

A possible solution could be to create proxy packages (a package.json in a subdirectory that have resolvers to the dist files). Here is an example.

from middleware.

kevinbalicot avatar kevinbalicot commented on May 29, 2024

Hello @draew6, Did you fix the problem with @jxom 's solution? Can you share your fix ?

from middleware.

draew6 avatar draew6 commented on May 29, 2024

@jxom @kevinbalicot sorry, i am new to this. How would that look like in my example please?

from middleware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.