NestJS and NuxtJS starter boilerplate
For development the following additional dependencies are required:
Make sure you have the latest version of nodenv
(Node.js version manager) by following instruction:
brew upgrade nodenv
Create development
and test
databases:
CREATE DATABASE nest-nuxt-boilerplate-development
CREATE DATABASE nest-nuxt-boilerplate-test
Run migrations:
yarn db:migrate
NODE_ENV=test yarn db:migrate
Folder | Description |
---|---|
/ |
Contains project configuration files as well as typescript and linting specifications which are applied to both (NestJS and NuxtJS) applications. |
app/client |
Contains the NuxtJS application directory as described here. |
app/server |
Contains the NestJS application directory as described here. |
This project is managed with helm v3
nest-nuxt-boilerplate
with your awesome-project-name
in /deploy
your-namespace
with your own k8s namespaceCreate shared namespace
kubectl create ns your-namespace
Copy deploy/secrets.example.yaml
to
Deploy secrets
kubectl apply -n your-namespace -f deploy/secrets.yaml
Deploy Helm chart
cd deploy && helmfile apply
Push to master branch will trigger new deployment on k8s.
# install dependencies
$ yarn install
# serve with hot reload at localhost:3000 (backend) and localhost:5000 (frontend)
$ overmind s
# build for production and launch combinded server (NestJS server serves NuxtJS frontend)
$ yarn build
$ yarn start:prod
For detailed explanation on how things work, check out NestJS docs or NuxtJS docs.
k8s deployment includes db-migrate-job which will automatically run migrations on each deplyoment. Locally you have to use the following commands to interact with typeorm cli.
yarn db:migration:generate <migration_name>
yarn db:migrate
yarn db:rollback
To run migrations against test database use
NODE_ENV=test yarn db:migrate
We chose to use the Nest.js code first
approach (see here) which means that the app/server/schemal.gql
file is automatically generated based on the types and resolvers we define in our Nest.js application. Further, we make use of GraphQL Code Generator to generate types and queries on the fly for the client based on the server’s schema.gql
file and the operations defined in one of the following files:
app/client/apollo/mutations.graphql
app/client/apollo/queries.graphql
app/client/apollo/subscriptions.graphql
The results are written to app/client/apollo/generated-operations.ts
and can be used as-is (see here for more information).
If you run the application with overmind s
then generated-operations.ts
will be re-generated if there are changes to one of the files listed above. Otherwise you have to run yarn generate:types
manually to re-generate the output file.
Author: zebbra-repos
Source Code: https://github.com/zebbra-repos/nestjs-nuxtjs-boilerplate
#nestjs #nuxtjs #vue #vuejs #javascript