An api skeleton using mongodb for chubbyts-framework.
- node: 16
- @asteasolutions/zod-to-openapi: ^7.1.1
- @chubbyts/chubbyts-api: ^4.1.1
- @chubbyts/chubbyts-decode-encode: ^1.3.3
- @chubbyts/chubbyts-dic: ^1.2.0
- @chubbyts/chubbyts-dic-config: ^1.2.0
- @chubbyts/chubbyts-dic-types: ^1.2.1
- @chubbyts/chubbyts-framework: ^1.9.4
- @chubbyts/chubbyts-framework-router-path-to-regexp: ^1.4.1
- @chubbyts/chubbyts-http: ^1.2.1
- @chubbyts/chubbyts-http-cors: ^1.2.1
- @chubbyts/chubbyts-http-error: ^2.3.1
- @chubbyts/chubbyts-http-node-bridge: ^1.2.0
- @chubbyts/chubbyts-http-types: ^1.2.3
- @chubbyts/chubbyts-log-types: ^1.3.2
- @chubbyts/chubbyts-mongodb: ^1.4.0
- @chubbyts/chubbyts-negotiation: ^3.2.2
- @chubbyts/chubbyts-pino-adapter: ^1.3.1
- commander: ^12.1.0
- mongodb: ^6.8.0
- openapi3-ts: ^4.3.3
- pino: ^9.2.0
- uuid: ^10.0.0
- zod: ^3.23.8
Add the following environment variable to your system, for example within ~/.bashrc
:
export USER_ID=$(id -u)
export GROUP_ID=$(id -g)
docker-compose up -d
docker-compose exec node bash
pnpm start
- GET https://localhost/api/pets?sort[name]=asc
- POST https://localhost/api/pets
- GET https://localhost/api/pets/8ba9661b-ba7f-436b-bd25-c0606f911f7d
- PUT https://localhost/api/pets/8ba9661b-ba7f-436b-bd25-c0606f911f7d
- DELETE https://localhost/api/pets/8ba9661b-ba7f-436b-bd25-c0606f911f7d
Commands is code that is meant to be executed on command line.
Handler alias Controller, or Controller actions to be more precise.
Models, entities, documents what ever fits your purpose the best.
Repositories get data from storages like databases, opensearch, redis or whereever your models are stored or cached.
Service factories are the glue code of the dependeny injection container.
- Digitalocean
- Create digitalocean token
- Install digitalocean cli - doctl
- Pulumi
- Install pulumi cli - pulumi
- Install kubernetes cli - kubectl
cd pulumi
pnpm install
pulumi config set digitalocean:token XXXXXXXXXXXXXX --secret
pulumi config set chubbyts-petstore:cert-manager-email XXXXXXXXXXXXXX --secret
pulumi config set chubbyts-petstore:ip-range 10.10.11.0/24
pulumi config set chubbyts-petstore:k8s-node-Count: "1"
pulumi config set chubbyts-petstore:mongodb-node-Count: "1"
pulumi config set chubbyts-petstore:opensearch-node-Count: "1"
pulumi up
doctl registry login
doctl kubernetes clusters list
doctl kubernetes clusters kubeconfig save <clustername>
# lists all deployments: container definition(s) which provide(s) howto start a pod
kubectl get deployments
# show the current deployment definition
kubectl get deployment <deploymentname> -o yaml
# edit the current deployment defintion (should be done via code change and pulumi up, and not inline)
kubectl edit deployment <deploymentname>
# lists all pods: container(s) which provide(s) one application for example the cms
kubectl get pods
# show the current pod definition (do not edit!)
kubectl get pod <podname> -o yaml
# enter a pod
kubectl exec -it <podname> -- /bin/bash
Make sure the development version is running to reuse its mongodb instance.
docker build --platform=linux/amd64 -f ./docker/production/node/Dockerfile -t chubbyts-petstore-node .
docker run -it -e NODE_ENV=production -e MONGO_URI="<see docker-compose.yml, replace @mongo with @host.docker.internal>" -e SERVER_HOST=0.0.0.0 -e SERVER_PORT=3000 -p 3000:3000 chubbyts-petstore-node
2024 Dominik Zogg