Prisma Serverless
Template for Prisma (Nexus) + Typescript + AWS Serverless Lambda =
π
This boilerplate includes:
π Apollo Server Lambdaβ‘ Serverless with Webpack, Auto prune & Typescript supportβοΈ Prisma & CRUD schema generated using Nexusπ· CircleCI configuration to deploy to lambdaπ Basic permissions with graphql-shield
There's more to come
Table of contents
Project Structure
.
βββ config/ # Serverless env
βββ prisma/ # Prisma related config & Datamodel
βββ src/ # The magic happens here
β βββ generated/ # Generated prisma schema & client
β βββ permissions/ # Resolvers permissions
β βββ resolvers/ # App resolvers
β βββ Mutation/ # Resolvers mutations
β βββ Query/ # Resolvers queries
βββ typings/ # Typescript generic typings
βββ .babelrc # babel config
βββ .editorconfig # editor config
βββ .eslintrc.js # eslint config
βββ .gitignore # git ignore list
βββ .nvmrc # nvm config
βββ .prettierrc # Prettier configuration
βββ docker-compose.yml # Docker compose file (for local server)
βββ package.json # build scripts and dependencies
βββ README.md # This file ;)
βββ serverless.yml # Serverless configuration
βββ tsconfig.json # Typescript configuration
βββ yarn.lock # yarn lock file
Quickstart
Prerequisites
You'll need a prisma server setup to use this template.
You can either create a local prisma server using Docker
:
docker-compose up -d
Or deploy to a new prisma demo server:
yarn prisma deploy
Then, create an .env
referencing the prisma endpoint:
PRISMA_ENDPOINT="http://localhost:4469/app/dev"
PRISMA_SECRET="PRISMA_SECRET"
APP_SECRET="MY_APP_SECRET"
# install dependencies
yarn install
# Run local lambda http environment (API Gateway simulator)
yarn dev
# Run tests
yarn run test
Deploying
- Deploy & Generate the prisma schema based on the datamodel to the prisma server.
# Deploy the schema to the prisma server & generate prisma client & schema
yarn prisma deploy
# Resolvers deployment
# Deploy (development)
yarn deploy:dev
# Deploy (production)
yarn deploy:prod