This project was originally created as a traditional Node.JS application, and was refactored to run as a Lambda function on AWS.
It currently acts as a GraphQL layer built on top of the publicly available D&D 5e REST API, but with plans to eventually migrate the data into an AWS data store.
To get started developing your own implementation:
- Clone or download this repository onto your local development machine.
- Ensure you have Node and NPM installed on your machine.
- Navigate to the directory containing the project, run
npm install
- To test the application locally, you will need to create a .env file with the following key and value
- BASE_URL = 'http://dnd5eapi.co/api'
- From the project's main directory, run
node server.js
. The application will run on http://localhost:3000, and you can access the Graphiql user interface for testing queries at http://localhost:3000/graphql
You will first need an AWS account.
- First, from inside your project directory, select all files and folders and create a .zip file
- From the AWS Console, choose the Lambda service.
- Choose 'Create Function', then 'Author from scratch'
- Give the function a name of your choice
- Provide the function a suitable IAM role with, at minimum, Cloudwatch permissions.
- Again click 'Create Function'
- From the dropdown above the code editor, choose to upload a .zip file and select the file you created previously
To run the Lambda code, you will need to decide how the function will be triggered. I connected an API Gateway with GET and POST routes (if you choose this method, make sure to select Lambda Proxy Integration for each route).
Good luck!