Skip to content

khaledosman/serverless-graphql-mongodb-lambda

Repository files navigation

serverless-graphql-mongodb-lambda

serverless JavaScript Style Guide Conventional Commits Commitizen friendly semantic-release

Features / Tools

  1. VSCode debugger setup at .vscode/launch.json with serverless-offline, just press f5 to start a local server and inspect break points
  2. Apollo-Server v2 setup for an AWS Lambda
  3. Caching GraphQL Responses in memory or redis
  4. MongoDB/Mongoose integration & Caching connections outside of lambda handler
  5. Serverless setup for different environments & deployment targets
  6. serverless-warmup plugin integration to reduce cold starts possibility and keep the lambdas warm
  7. Semantic-versioning, changelog generation and automated releases thanks to semantic-release
  8. Linting with StandardJS
  9. Gzip compression
  10. Environment variables per stage can be defined in an env.yml file
  11. AWS X-Ray integration for traces
  12. GraphQL Playground integration w/ traces
  13. Apollo Engine/Graph Manager integration for monitoring
  14. Serverless Dashboard monitoring

Setup

  • Setup your aws credentials and aws profile using aws configure --profile <aws profile>
  • npm install
  • use yarn start to run in offline mode`
  • yarn deploy:dev to deploy dev environment
  • yarn deploy:live to deploy to live

Environment variables

  • Environment variables can be setup in env.yml file
  • add your ENGINE_API_KEY to a .env file

Deploying

  • Install serverless cli using npm i -g serverless
  • Install and setup your aws cli with an aws profile using aws config --profile=<aws profile>
  • use yarn deploy:dev or yarn deploy:live

Releasing

This repo uses semantic-release, commitizen, commitlint, husky and conventional commits in order to automate the release proccess

Setup/Prequisites

  1. The user needs to have a GH_TOKEN environment variable set with a valid git token that has push access to the repository which can be generated following these steps
  2. the token can be added into a ~/.bash_profile to avoid manually setting it before running the command.
  3. The script should be run from the release branch only (default: master) otherwise it will fail. To change the release branch you can edit the "release" section in the package.json file to temporarily set the release branch as follows
"release": {
  ...
  "branch": "feature/integrate-semantic-release"
  ...
}

Usage

  • yarn commit will run commitizen cli to generate a conventional style commit message
  • yarn release will do a dry-run of the release without pushing or changing any files
  • yarn release --no-ci will do a real release. We could potentially use this to automate releases when new commits/PRs land in the master branch Details

A release will

  • Bump the version in package.json according to semantic versioning (semver) based on the changes/commit messages (fix/perf = patch, feat = minor, breaking = major)
  • Create a git tag
  • Generate a CHANGELOG.md with the latest changes since the last release
  • Push the changes to the repository & create a git release

About

Lambda integration with serverless framework, vscode offline debugging, apollo-server, graphql, mongoose and atlas mongodb

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •