All Projects → noppoMan → Hexaville

noppoMan / Hexaville

Licence: mit
The modern serverless web application engine and framework for Swift

Programming Languages

swift
15916 projects
swift4
162 projects

Projects that are alternatives of or similar to Hexaville

Aws Mobile React Native Starter
AWS Mobile React Native Starter App https://aws.amazon.com/mobile
Stars: ✭ 2,247 (+1726.83%)
Mutual labels:  api-gateway, aws, serverless, lambda
Aws Serverless Ecommerce Platform
Serverless Ecommerce Platform is a sample implementation of a serverless backend for an e-commerce website. This sample is not meant to be used as an e-commerce platform as-is, but as an inspiration on how to build event-driven serverless microservices on AWS.
Stars: ✭ 469 (+281.3%)
Mutual labels:  api-gateway, aws, serverless, lambda
Aws Lambda Fastify
Insipired by aws-serverless-express to work with Fastify with inject functionality.
Stars: ✭ 190 (+54.47%)
Mutual labels:  api-gateway, aws, serverless, lambda
Serverless Next.js
⚡ Deploy your Next.js apps on AWS Lambda@Edge via Serverless Components
Stars: ✭ 2,977 (+2320.33%)
Mutual labels:  api-gateway, aws, serverless, lambda
Workshop Donkeytracker
Workshop to build a serverless tracking application for your mobile device with an AWS backend
Stars: ✭ 27 (-78.05%)
Mutual labels:  api-gateway, aws, serverless, lambda
Mangum
AWS Lambda & API Gateway support for ASGI
Stars: ✭ 475 (+286.18%)
Mutual labels:  api-gateway, aws, serverless, lambda
Shep
A framework for building JavaScript Applications with AWS API Gateway and Lambda
Stars: ✭ 376 (+205.69%)
Mutual labels:  api-gateway, aws, serverless, lambda
Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (-58.54%)
Mutual labels:  api-gateway, aws, serverless, lambda
Aws Mobile React Sample
A React Starter App that displays how web developers can integrate their front end with AWS on the backend. The App interacts with AWS Cognito, API Gateway, Lambda and DynamoDB on the backend.
Stars: ✭ 650 (+428.46%)
Mutual labels:  api-gateway, aws, serverless, lambda
Aws Sam Cli
CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
Stars: ✭ 5,817 (+4629.27%)
Mutual labels:  api-gateway, aws, serverless, lambda
Terraform Nextjs Plugin
A plugin to generate terraform configuration for Nextjs 8 and 9
Stars: ✭ 41 (-66.67%)
Mutual labels:  api-gateway, aws, serverless, lambda
Up
Up focuses on deploying "vanilla" HTTP servers so there's nothing new to learn, just develop with your favorite existing frameworks such as Express, Koa, Django, Golang net/http or others.
Stars: ✭ 8,439 (+6760.98%)
Mutual labels:  api-gateway, aws, serverless, lambda
Historical
A serverless, event-driven AWS configuration collection service with configuration versioning.
Stars: ✭ 85 (-30.89%)
Mutual labels:  aws, serverless, lambda
Seoul Bike
서울시 자전거 따릉이를 위한 대여소 찾기 서비스 입니다.
Stars: ✭ 78 (-36.59%)
Mutual labels:  aws, serverless, lambda
Serverless Stack
💥 Serverless Stack (SST) is a framework that makes it easy to build serverless apps.
Stars: ✭ 1,252 (+917.89%)
Mutual labels:  aws, serverless, lambda
Node Lambda Log
Basic logging mechanism for Node 6.10+ Lambda Functions
Stars: ✭ 115 (-6.5%)
Mutual labels:  aws, serverless, lambda
Lambda Refarch Webapp
The Web Application reference architecture is a general-purpose, event-driven, web application back-end that uses AWS Lambda, Amazon API Gateway for its business logic. It also uses Amazon DynamoDB as its database and Amazon Cognito for user management. All static content is hosted using AWS Amplify Console.
Stars: ✭ 1,208 (+882.11%)
Mutual labels:  aws, serverless, lambda
Aws Serverless Airline Booking
Airline Booking is a sample web application that provides Flight Search, Flight Payment, Flight Booking and Loyalty points including end-to-end testing, GraphQL and CI/CD. This web application was the theme of Build on Serverless Season 2 on AWS Twitch running from April 24th until end of August in 2019.
Stars: ✭ 1,290 (+948.78%)
Mutual labels:  aws, serverless, lambda
Lambcycle
🐑🛵 A declarative lambda middleware with life cycle hooks 🐑🛵
Stars: ✭ 88 (-28.46%)
Mutual labels:  aws, serverless, lambda
Awesome Aws
A curated list of awesome Amazon Web Services (AWS) libraries, open source repos, guides, blogs, and other resources. Featuring the Fiery Meter of AWSome.
Stars: ✭ 9,895 (+7944.72%)
Mutual labels:  aws, serverless, lambda

Hexaville

codebeat badge

Hexaville - The Serverless Framework using AWS Lambda + ApiGateway etc as a back end. Build applications comprised of microservices that run in response to events, auto-scale for you, and only charge you when they run. This lowers the total cost of maintaining your apps, enabling you to develop more, faster.

It's the greatest motivation to help many Swift and mobile application developers with rapid server side development and low cost operation.

Supported Cloud Servises

  • [x] AWS Lambda(Node.js 8.1 Runtime) + APIGateway
  • [ ] Google Cloud Function

Pre-Required

  • Docker: using for builiding swift application
  • serverless: using for deployment

Deployment Engine

Plugins

Recommended Database Clients

  • DynamoDB: A DynamoDB typesafe client in AWSSDKSwift

Example Application for Hexaville

HexavilleTODOExample has following practical examples for Hexaville application.

  • User authentication with GitHub's OAuth
  • Data persistence with DynamoDB
  • Dynamic HTML Rendering

Quick Start

Install Docker for mac

Install Docker for mac from here, If you haven't installed yet.

Install Hexaville from Script(Highly recommended)

curl -L https://rawgit.com/noppoMan/Hexaville/master/install.sh | bash

The script clones the hexaville repository to ~/.hexaville and adds the source line to your profile (~/.zshrc, or ~/.bashrc).

export PATH="$PATH:$HOME/.hexaville"

source your profile and then, type hexaville

source ~/.bashrc
hexaville

Install Hexaville from Source

git clone https://github.com/noppoMan/Hexaville.git
cd Hexaville
swift build

and then, should link Hexaville executable path to /usr/local/bin or something like that.

Create a Project

Usage: hexaville generate <projectName>

hexaville generate Hello --dest /path/to/your/app

swift-tools-version

You can specify swift-tools-version for the new project with --swift-tools-version option. Current default tool version is 5.1

If the tool version is higher than 3.1, layouts and definiations of Package.swift are refined.

e.g.

# swift.version will be 5.1
hexaville generate Hello

# swift.version will be 5.0
hexaville generate Hello --swift-tools-version 5.0

# swift.version will be swift-4.0-DEVELOPMENT-SNAPSHOT-2017-08-04-a
hexaville generate Hello --swift-tools-version swift-4.0-DEVELOPMENT-SNAPSHOT-2017-08-04-a

Open your project with Xcode

swift package generate-xcodeproj
open *.xcodeproj

The created codes in the project is example snippet of https://github.com/noppoMan/HexavilleFramework

HexavilleFramework is an express like micro framework for Hexaville.

The syntax is following.

import HexavilleFramework

let app = HexavilleFramework()

app.use(RandomNumberGenerateMiddleware())

let router = Router()

router.use(.GET, "/") { request, context in
    let htmlString = "<html><head><title>Hexaville</title></head><body>Welcome to Hexaville!</body></html>"
    return Response(headers: ["Content-Type": "text/html"], body: htmlString)
}

app.use(router)

try app.run()

Deploy Your Project

Hexaville depends on serverless at deployment.

See Install Guide: https://serverless.com/framework/docs/getting-started/

Packaging hexaville application

hexaville package command does the following.

  • build a swift application on the docker(Ubuntu14.04) to create the ELF that is executed on servrless environment.
  • zip ELF, swift standard libraries, runtime program and assets
cd /path/to/your/app
hexaville package

Deploying to the cloud

serverless deploy --stage staging

Default serverless.yml that is created by hexaville generate has only staging and production environment. If you'd like to add other environments, please edit severless.yml manually.

Troubleshooting

1. What is executableTarget in Hexavillefile.yml?

executableTarget is a name that specified in products(name: 'executableTarget') on Package.swift. In following case, it's a my-app not MyApp.

let package = Package(
    name: "MyApp",
    products: [
        .executable(name: "my-app", targets: ["MyApp"])
    ],
    ....
)

Access to your api resources

curl https://xxxxxx.execute-api.ap-northeast-1.amazonaws.com/staging/

or access the endpoint from Browser.

Binary Media Types

Currenty Hexaville supports following binary media types

  • image/*
  • application/octet-stream
  • application/x-protobuf
  • application/x-google-protobuf

How to get binary content?

Threr are two rules to respond to the binary content in the routing handler.

  • RowBinaryData should be encoded as Base64
  • Adding "Content-Type": "{BinaryMediaType}" to the response headers
router.use(.get, "/some_image") { request, context in
    let imageData = Data(contentsOf: URL(string: "file:///path/to/your/image.jpeg")!)
    return Response(headers: ["Content-Type": "image/jpeg"], body: imageData.base64EncodedData())
}

Getting binary content from Hexaville, need to send request that includes Content-Type: {BinaryMediaType} and Accept: {BinaryMediaType} headers

curl --request GET -H "Accept: image/jpeg" -H "Content-Type: image/jpeg" https://yourdomain.com/staging/random_image

# ????JFIF``??;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 70
# ??C
#
#
#
#
#
# #%$""!&+7/&)4)!"0A149;>>>%.DIC<H7=>;??C
#
#
# ;("(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;???"??
# ............

How to debug?

You can debug your application with the HexavilleFramework's builtin web server with serve command.

/path/to/your/app/.build/debug/Hello serve
# => Hexaville Builtin Server started at 0.0.0.0:3000

Advanced Settings

Environment Variables

See: https://serverless.com/framework/docs/providers/aws/guide/variables/

VPC and Security Groups

See: https://serverless.com/framework/docs/providers/aws/guide/functions#vpc-configuration

Swift Versioning and Build Configuration

You can configure swift versioning and build configuration in swift directive

  • default swift version is 5.1
  • default build configuration is debug
swift:
  version: 5.1 #format should be major.minor.[patch] or valid SWIFT DEVELOPMENT-SNAPSHOT name
  buildOptions:
    configuration: release

Use SWIFT DEVELOPMENT-SNAPSHOT

You can also specify SWIFT DEVELOPMENT-SNAPSHOT as internal using swift version.
The format is same as swiftenv version

e.g.

swift:
  version: swift-4.0-DEVELOPMENT-SNAPSHOT-2017-08-04-a

Static Assets

You can also upload static assets. Just put your assets into the assets directory in your project root.

Loading Static Assets in Application

You can load static assets from local filesystem with AssetLoader

import HexavilleFramework

let data = try AssetLoader.shared.load(fileInAssets: "/html/index.html")

Against for the Severless weak points

Too many connections will created between Serveless functions and RDB, Cache Server

Almost Web develoeprs access RDB, Cache Server through connection pooling from your applications. It's a one of the best practice for reducing connection for them. But Functions that are called on Serverless is like a Pre-Folk. It means can not have connection pooling and the number of connection of Database is same as number of functions that are executed in parallel.

In that case, Hexaville provides you to connection pooling mechanism with hexaville-tcp-proxy-server.

hexaville-tcp-proxy-server is not only a Proxy Sever But Connection Pooling Server. See the detail to see README.

Cold Start

There are several third parties's libraries to againt cold start on github.

The major one is serverless-plugin-warmup

How to update Hexaville CLI Version?

$ rm -rf ~/.hexaville
$ curl -L https://rawgit.com/noppoMan/Hexaville/master/install.sh | bash
$ hexaville version

Contributing

All developers should feel welcome and encouraged to contribute to Hexaville, see our getting started document here to get involved.

To contribute a feature or idea to Hexaville, submit an issue and fill in the template. If the request is approved, you or one of the members of the community can start working on it.

If you find a bug, please submit a pull request with a failing test case displaying the bug or create an issue.

If you find a security vulnerability, please contact [email protected] as soon as possible. We take these matters seriously.

Related Articles

License

Hexaville is released under the MIT license. See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].