#How to connect expressjs with nuxt3
26 messages · Page 1 of 1 (latest)
🤔 why not the nitro server ? Which is already present in nuxt 3 ?
I'd also suggest using Nitro directly ☺️
thanks
could sound dumb but I'm new to the JS environment so in there you put like database queries or whatever that return JSON ?
Yeah, you can technically return any data but JSON is most common
Could be a DB query, another API call and more
I'm trying to use https://adminjs.co/ to generate an automatic CRUD dashboard for my app.
adminjs has several adapters for popular frameworks, express, fastify, etc., but not h3
integrating it with express is pretty trivial, so I thought that was the direction i'd try here, but I can use some help with this
the express integration works by creating an express router
AdminJS is an open-source auto-generated admin panel for your Node.js application that allows you to manage all your data in one place
Using nuxts built in tools like h3 is the way to go here. Check out the docs for the server directory to get started in building something like a JSON API https://nuxt.com/docs/guide/directory-structure/server
actually, getting express to work was pretty easy
export default fromNodeMiddleware(expressApp)
@quasi plaza yeah it's great that it works, just not needed 😄
in my case it's needed cause there's no adapter for adminjs
so I need to use express, fastify, koa, etc.
@river terrace i think what most people miss in general in the JS community is the concept of supporting apis, just because it is not needed by you or someone on a greenfield project does not mean it is not needed by people in existing projects
Everything is "rewrite and new" so instead of supporting well established community standards (like the express api) we have several "new shiny" things like h and nitro and probably other things i'm unaware of. Those new things should adapt the existing behavior as a first class concern
as is in the documentation there is no support for async express function, which excludes entire ecosystems like koa
Well, nobody stops you from using your existing express API as separate service 😊
(Also, h3 has built-in async support)
Except for the fact that it breaks the possibility of doing certain things such as, oh I don't know, using httponly cookie session id headers.
This is exactly what i mean, forcing people to rewrite is the opposite of what large teams want.
The docs call out that you cannot use promises inside of the node adapter for express
Use a nuxt 2 api from nuxt 3 👍
Example question for modules: #modules message