move-services
Lorem ipsum dolor sit amet consectetur adipisicing elit. Facilis at ab recusandae fugiat, saepe molestiae doloribus assumenda rem voluptates non illum nemo dolorem architecto animi obcaecati esse eius et iure
Getting started
We are using the Serverless framework and on top of that we have
used the Yoaman template typescript-microservice
which allows us to configure all
serverless functions using Typescript instead of YAML. Please put all serverless
configuration into the serverless-config
directory. You will see there is already a
decent starting structure for you to base your configuration off of.
Deployment
Deployment runs a build and then pushes your serverless project/function to your cloud provider.
# deploy everything (slow but you'll need it the first time you deploy)
yarn deploy
# deploy a specific function or step-function
yarn deploy [fn]
Testing
Testing leverages the mocha
test runner and the chai
assertions library. All tests can
be found in the /test
directory.
# test everything
yarn test
# test a subset of scripts
yarn test [search]
Serverless
Most of the service definition/configuration you will do for your serverless function will
be found in the serverless-config
directory.
Environment Variables
The env.yml
file in the serverless-configuration
folder will look something like:
global: &all_stages
MAILGUN_API_KEY: "pubkey-xxyyzz"
MAILGUN_API_SECRET: "key-xxyyzz"
dev:
<<: *all_stages
AWS_STAGE: "dev"
FIREBASE_SERVICE_ACCOUNT: ""
FIREBASE_DATA_ROOT_URL: ""
stage:
<<: *all_stages
AWS_STAGE: "stage"
FIREBASE_SERVICE_ACCOUNT: ""
FIREBASE_DATA_ROOT_URL: ""
prod:
<<: *all_stages
AWS_STAGE: "prod"
FIREBASE_SERVICE_ACCOUNT: ""
FIREBASE_DATA_ROOT_URL: ""
This configuration allows for global variables as well as stage-specific settings. These variables will be brought up to your cloud provider the first time you do a full deployment.
Functions
Serverless is all about functions and while the normal method of defining them is within
the serverless.yml
file this quickly becomes cumbersome so instead we've created a more
composable way of defining your functions in TypeScript. This means you can more
modularity but it also means you get typing for your functions.
For instance, you can define a function like so:
serverless-config/functions/foobar.ts
const transportPrep: IServerlessFunction = {
description: "Lorem ipsum dolor sit amet consectetur adipisicing elit.",
handler: "lib/foobar.handler",
environment: "${file(env.yml):${self:custom.stage}}",
timeout: 10,
memorySize: 1024,
package: {
exclude: [...standardExclusions]
}
};