- deploy:dev: deploy to the GCP dev environment
- deploy:prod: deploy to the GCP prod environment
- deploy:local: start local development environment
- lint: start tslint for project files
- test: start unit tests
It is a skeleton for your Serverless applications for Google Cloud Platform. It uses TypeScript, webpack plugin for Serverless function.
Make sure you read whole documentation from the Serverless Framework website for further development.
GCP has totally different serverless architecture than AWS. Is uses just one function as entry point because GCP does not have API Gateway. The API should be built from this point manually. The core concept is a basic Express server.
Serverless Framework supports GCP much worse than AWS. In this repo we use sls plugin as well as Functions Framework from GCP. It's tricky to develop APIs with GCP and SLS.
Cloud Functions Admin
instead of Cloud Functions Developer
when try to
set up Service Account in IAM & admin
section of the Console.
NOT PUBLIC
. You need
to change it in Functions Console section manually! answer
- On the Cloud Functions homepage, highlight the Cloud Function you want to add all access to.
- Click "Show Info Panel" on the top right.
- Click "Add Members" and type "allUsers" then select "Cloud Function Invokers" under "Cloud Function" in the Role box.
- Click "Save"
- Entry point routing example
- Dev server environment
- Dot Env support
- TypeScript with Webpack
- One test endpoint
Here we use the pure .env scheme.
BASE_URL=http://localhost:4000
NAME=flo-api
.env is a default file for development, and it will be injected by webpack plugin directly to the index.js. You will not find it in the result file, but it will work in runtime.
This mechanism is a stage sensitive for deployment. You need to add files for each stage with the next schema:
.env.{stage}
. Example .env.prod