Skip to content

Instantly share code, notes, and snippets.

View alfianlosari's full-sized avatar
📱
Xcoding with Alfian | https://alfianlosari.com

Alfian Losari alfianlosari

📱
Xcoding with Alfian | https://alfianlosari.com
View GitHub Profile
import SwiftUI
struct FormList: View {
@State var isProfileExpanded = true
var body: some View {
Form {
Section {
DisclosureGroup(isExpanded: $isProfileExpanded) {
import SwiftUI
struct SidebarList: View {
let items: [Item]
var body: some View {
List {
Label("Home", systemImage: "house")
Divider()
import SwiftUI
struct SidebarList: View {
let items: [Item]
var body: some View {
List {
Label("Home", systemImage: "house")
Divider()
extension Item {
static var stubs: [Item] {
[
Item(title: "Computers", children: [
Item(title: "Desktops", children: [
Item(title: "iMac", children: nil),
Item(title: "Mac Mini", children: nil),
Item(title: "Mac Pro", children: nil)
]),
import SwiftUI
struct ItemsList: View {
let items: [Item]
var body: some View {
List(items, children: \.children) {
Text($0.title)
}
service: alf-todoapi
package:
artifact: .build/lambda/TodoAPI/lambda.zip
custom:
todosTableName: todos-${self:provider.stage}
provider:
name: aws
struct TodoLamdaHandler: EventLoopLambdaHandler {
//...
// Main handler
func handle(context: Lambda.Context, event: APIGateway.Request) -> EventLoopFuture<APIGateway.Response> {
guard let handler = Handler.current else {
return context.eventLoop.makeSucceededFuture(APIGateway.Response(with: APIError.requestError, statusCode: .badRequest))
}
import Foundation
import AWSLambdaEvents
extension APIGateway.Request {
private static let jsonDecoder: JSONDecoder = {
let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .formatted(Utils.iso8601Formatter)
return decoder
}()
struct TodoLamdaHandler: EventLoopLambdaHandler {
//...
init(context: Lambda.InitializationContext) throws {
// HTTP Client Setup
let timeout = HTTPClient.Configuration.Timeout(
connect: .seconds(30),
read: .seconds(30)
)
struct TodoLamdaHandler: EventLoopLambdaHandler {
//...
init(context: Lambda.InitializationContext) throws {
// HTTP Client Setup
let timeout = HTTPClient.Configuration.Timeout(
connect: .seconds(30),
read: .seconds(30)
)