项目作者: atilafassina

项目描述 :
🧟 Monster as a Service. A Netlify Function which returns a random D&D moster every time.
高级语言: TypeScript
项目地址: git://github.com/atilafassina/monster-as-a-service.git
创建时间: 2020-08-05T12:42:02Z
项目社区:https://github.com/atilafassina/monster-as-a-service

开源协议:

下载


🧟 Monster As A Service (MAAS)

Netlify Status

This is a microservice wrapping requests to D&D 5e API.

It will return a random monster at every request.

Goal

This repository is an example use-case on how to use Netlify Functions with TypeScript.

Watch the video on Youtube

Deploy your own instance

Deploy MAAS to Netlify

More instructions

If you need help understanding the ins and outs of this code, please refer to the video on ScopeLeak

Packages

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.