h3 icon indicating copy to clipboard operation
h3 copied to clipboard

Request: Dockerized H3 API example

Open justindasilva opened this issue 3 years ago • 2 comments
trafficstars

Hello @pi0, I know you are very busy with Nuxt 3 development, so I don't expect you would be able to fulfil this request anytime soon. Maybe this could be put on the back burner. Or maybe someone else can help me here.

What I'm looking for is for a starter template to get me started with using Node + H3 + Docker + Testing.

I'll be making a series of mini-applications with somewhat different API's. Some will support only one endpoint. Some will support a few endpoints. Some need to support POST and PUT on top of GET endpoints. Some of these endpoints will share functions. I've been using the /server directory in Nuxt 3 and I feel like H3 would be a better choice for what I need instead of going with Express as seen in this example: https://github.com/petkivim/nodejs-rest-api-example

There is no frontend needed in these mini-apps. But what I would like is a good testing framework for the endpoints and utility functions.

I would love if each of my mini-apps had a structure that looked more or less like this:

/api
/api/endpoint1.js
/api/entity/endpoint2.js
/utils
/utils/function1.js
/tests
/tests/testFunction1.js
/tests/endpoint1.js
package.json
Dockerfile

And if I ran docker compose up from this repo, I would be able to access localhost:3000/api/endpoint and localhost:3000/api/entity/endpoint2. I would also love to be able to run yarn test and get my test suite to run all my tests.

I'm just very curious of the most minimal and ideal approach to setting this up. Any sort of guidance on best practice to accomplishing something close to what I want here would be very much appreciated :)

justindasilva avatar Apr 27 '22 17:04 justindasilva

I'm very sorry, after a bunch of research, I've just realized that Nitro is essentially what I'm looking for. I'm reading more about it now: https://nitro.unjs.io/guide/

I would love to see how a full example repo of nitropack being used. With testing and Docker. That would be cool.

justindasilva avatar May 01 '22 00:05 justindasilva

I'm very sorry, after a bunch of research, I've just realized that Nitro is essentially what I'm looking for. I'm reading more about it now: https://nitro.unjs.io/guide/

I would love to see how a full example repo of nitropack being used. With testing and Docker. That would be cool.

Nitropack is indeed with you are looking for. An example of usage is Nuxt and it can bundles with a nodeJS environment easily :)

Lyokolux avatar Sep 29 '22 08:09 Lyokolux

Dockering an h3 server itself is pretty much similar to dockerize any node.js application (https://nodejs.org/en/docs/guides/nodejs-docker-webapp/)

Let's track it via https://github.com/unjs/nitro/issues/54 for nitro docker support and docs.

Cheers.

pi0 avatar Feb 16 '23 15:02 pi0