This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: build clean deploy | |
build: | |
go get ./... | |
go mod vendor | |
env GOOS=linux go build -ldflags="-s -w" -o bin/create_article api/create_article/main.go | |
env GOOS=linux go build -ldflags="-s -w" -o bin/create_author api/create_author/main.go | |
env GOOS=linux go build -ldflags="-s -w" -o bin/get_authors api/get_authors/main.go | |
env GOOS=linux go build -ldflags="-s -w" -o bin/get_articles api/get_articles/main.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service: serverless-example | |
frameworkVersion: '2' | |
provider: | |
name: aws | |
runtime: go1.x | |
lambdaHashingVersion: 20201221 | |
region: eu-central-1 | |
environment: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"github.com/aws/aws-lambda-go/events" | |
"github.com/aws/aws-lambda-go/lambda" | |
"github.com/marioarizaj/serverless-example/api/common" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"github.com/aws/aws-lambda-go/events" | |
"github.com/aws/aws-lambda-go/lambda" | |
"github.com/marioarizaj/serverless-example/api/common" | |
"github.com/marioarizaj/serverless-example/models" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type StorageIFace interface { | |
CreateAuthor(author *models.Author) (*models.Author, error) | |
GetAllAuthors() ([]models.Author, error) | |
CreateArticle(article *models.Article) (*models.Article, error) | |
GetAllArticles() ([]models.Article, error) | |
} | |
// Code down here does not change |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models | |
import "time" | |
type Article struct { | |
ID int `json:"id"` | |
Name string `json:"name"` | |
AuthorID int `json:"author_id"` | |
CreatedAt time.Time `json:"created_at"` | |
UpdatedAt time.Time `json:"updated_at"` |
NewerOlder