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
import Foundation | |
@propertyWrapper | |
public struct Injected<Value> { | |
public var wrappedValue: Value { | |
get { | |
SwiftDI.default.resolve() | |
} | |
} |
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
// Without DI | |
class Store { | |
static let shared = Store() | |
func save(key, String, value: Any) { /*...*/ } | |
func load(key: String) -> Any? { /*...*/ } | |
} | |
class ViewModel { | |
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: | |
name: todo-api | |
# app and org for use with dashboard.serverless.com | |
#app: your-app-name | |
#org: your-org-name | |
custom: | |
webpack: | |
webpackConfig: ./webpack.config.js | |
includeModules: true |
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: | |
name: todo-api | |
custom: | |
webpack: | |
webpackConfig: ./webpack.config.js | |
includeModules: true | |
plugins: | |
- serverless-webpack |
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
export interface TodoItem { | |
id: string | |
name: string | |
done: boolean | |
createdAt: string | |
} |
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
import * as AWS from 'aws-sdk' | |
import 'source-map-support/register' | |
import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda' | |
import * as uuid from 'uuid' | |
import { TodoItem } from '../../models/TodoItem' | |
export const handler = async (event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> => { | |
const data = JSON.parse(event.body); | |
const id = uuid.v4(); |
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
import * as AWS from 'aws-sdk' | |
import 'source-map-support/register' | |
import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda' | |
import * as uuid from 'uuid' | |
import { TodoItem } from '../../models/TodoItem' | |
export const handler = async (event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> => { | |
const { name } = JSON.parse(event.body); | |
const id = uuid.v4(); |
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
import * as AWS from 'aws-sdk' | |
import { DocumentClient } from 'aws-sdk/clients/dynamodb' | |
import { TodoItem } from '../models/TodoItem' | |
export default class TodoRepository { | |
constructor( | |
private readonly docClient: DocumentClient = createDynamoDBClient(), | |
private readonly todoTable = process.env.TODOS_TABLE) { |
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
import * as uuid from 'uuid' | |
import TodoRepository from '../repositories/TodoRepository' | |
import { TodoItem } from '../models/TodoItem' | |
export default class TodoService { | |
todoRepository: TodoRepository; |
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
import 'source-map-support/register' | |
import { APIGatewayProxyHandler, APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda' | |
import TodoService from '../../services/todoService' | |
export const handler: APIGatewayProxyHandler = async (event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> => { | |
const { name } = JSON.parse(event.body) | |
const todoService = new TodoService() | |
const todo = await todoService.createTodo(name) |