🧟 Monster as a Service. A Netlify Function which returns a random D&D moster every time.
This is a microservice wrapping requests to D&D 5e API.
It will return a random monster at every request.
This repository is an example use-case on how to use Netlify Functions with TypeScript.
If you need help understanding the ins and outs of this code, please refer to the video on ScopeLeak
Dependencies | Why |
---|---|
Netlify Dev¹ | To run Netlify Functions locally |
Netlify Lambda | Adds build-step to Netlify Functions |
TypeScript | The compiler for TypeScript (tsc ) |
node-fetch | Brings window.fetch api to NodeJS |
babel/preset-env | Tells Babel which JavaScript syntax to output |
babel/preset-typescript | Teach Babel to use TypeScript compiler |
types/aws-lambda | Request/Response types for AWS Lambdas² |
encoding | depency of node-fetch ³ |
1: Install it globally on your system
2: Netlify Functions uses AWS Lambdas under the hood
3: It should be a dependency of node-fetch
but it’s not added in v2, so we add manually so our build doesn‘t break.