CerberusMVC Documentation

Routing and Config


Providers need something, to instruct them how to handle the functions, route them to gateway logic and also configure stuff. In aws this is a AWS template file for Cloud Formation. In azure these are individual files for each function. This handles routing and config fo rhte system too. You will require one of these for your project before you can do anything else.

template.yaml (AWS Cloud Formation Project)

AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: cerberus-mvc-

Globals:
  Api:
    Cors:
      AllowMethods: "'GET, POST, PUT, DELETE, OPTIONS, PATCH'"
      AllowHeaders: "'Accept, Cache-Control, Content-Type, Content-Length, Authorization, Pragma, Expires'"
      AllowOrigin: "'*'"
      AllowCredentials: "'*'"
  Function:
    Timeout: 3
    Runtime: nodejs12.x
    Handler: handler.run
    Environment:
      Variables:
        API_NAME: Your Project
        API_ADDRESS: 'http://localhost:3000'
        API_VERSION: 0.0.1
        API_MODE: development
        API_CORS_LIST: 'http://localhost:8181' 
        
Resources:
  Health:
    Type: AWS::Serverless::Function
    Properties:
      ReservedConcurrentExecutions: 10
      Timeout: 30
      VpcConfig:
        SecurityGroupIds:
          - sg-0......1
        SubnetIds:
          - subnet-0......1
          - subnet-0......2
      Events:
        HealthGet:
          Type: Api
          Properties:
            Path: /health
            Method: get

  CatchAll:
    Type: AWS::Serverless::Function
    Properties:
      ReservedConcurrentExecutions: 10
      Timeout: 30
      VpcConfig:
        SecurityGroupIds:
          - sg-0......1
        SubnetIds:
          - subnet-0......1
          - subnet-0......2
      ReservedConcurrentExecutions: 10
      Events:
        CatchAll:
          Type: Api
          Properties:
            Path: /{error+}
            Method: any

template.json (Express JS Project)

{
	"global": {
		"environment": {
			"API_NAME": "fffffff", 
			"API_ADDRESS": "", 
			"API_VERSION": "", 
			"API_MODE": "", 
			"API_CORS_LIST": "" 
		}
	},
	"resources": [
		{
			"name": "Health",
			"handler": false,
			"environment": { "HEALTH_CONFIG": "dsds" },
			"method": "get",
			"path": "/health"
		},
		{
			"name": "test",
			"handler": false,
			"environment": {
				"API_NAME": "dddddddddd"
			},
			"method": "get",
			"path": "/test/{id}"
		}
	]
}

template.json (Socket.IO Project)

{
	"global": {
		"environment": {
			"API_NAME": "fffffff", 
			"API_ADDRESS": "", 
			"API_VERSION": "", 
			"API_MODE": "", 
			"API_CORS_LIST": "" 
		}
	},
	"resources": [
		{
			"name": "Health",
			"handler": false,
			"environment": { "HEALTH_CONFIG": "dsds" },
			"method": "socket",
			"path": "/health"
		},
		{
			"name": "test",
			"handler": false,
			"environment": {
				"API_NAME": "dddddddddd"
			},
			"method": "socket",
			"path": "/test/{id}"
		}
	]
}

template.json (Combined Express and Socket.IO Project)

{
	"global": {
		"environment": {
			"API_NAME": "fffffff", 
			"API_ADDRESS": "", 
			"API_VERSION": "", 
			"API_MODE": "", 
			"API_CORS_LIST": "" 
		}
	},
	"resources": [
		{
			"name": "Health",
			"handler": false,
			"environment": { "HEALTH_CONFIG": "dsds" },
			"method": "get",
			"path": "/health"
		},
		{
			"name": "test",
			"handler": false,
			"environment": {
				"API_NAME": "dddddddddd"
			},
			"method": "socket",
			"path": "/test/{id}"
		}
	]
}