A barebones Node.js app using:
Make sure you have Node.js and the Docker installed.
git clone git@github.com:Mau5Machine/node-prisma-graphql-boilerplate.git # or clone your own fork
cd node-prisma-graphql-boilerplate
npm installOnce you have all of your dependencies installed, let's set some environment variables to connect to an external database. I am setup with Postgres in this boilerplate.
Change the name of the env.example file to .env or create a new .env file to read the environment variables.
There are 2 .env file locations in this project.
- One is at the root of the project for the port and the environment
- Another inside of prisma directory for the prisma and docker configurations
Once these values are set, enter the following into the command line
export PRISMA_MANAGEMENT_API_SECRET="__SECRET_KEY_HERE__"
Replace SECRET_KEY_HERE text with your secret key inside of your prisma/.env file.
With all your env variables set and your docker service running on your machine, you can now build up the prisma API client container.
Navigate to the prisma directory and enter in the command line the following
docker-compose up -d
# Once that is complete, enter the following
prisma deploy
If you set everything up properly, you should be able to navigate to http://localhost:4466 OR the to port 4466 of the docker IP address and you will see a GraphQL Playground.
You can start your node server by typing in
npm run dev