Dart templates to be used with OpenWhisk

Overview

Dart OpenWhisk function templates

This repository contains OpenWhisk function templates for writing serverless functions in the Dart programming language.

Usage

  1. Make sure OpenWhisk has been deployed to your Kubernetes cluster and the OpenWhisk CLI tool has been installed. See here and here for a brief introduction on how to do this.

  2. Download the Dart function templates from this repo and enter into the main directory:

git clone https://github.com/nicklasxyz/dart_openwhisk && \
cd dart_openwhisk
  1. Add new functionality to the function that is going to be deployed and managed by OpenWhisk:
code template/function/lib/src/function_base.dart
# ... Inside this file extend or add whatever you want to below the 'handleRequest' function  

Note: The files and directories in the dart_openwhisk/template directory are a part of a usual Dart project, but structured specifically for use with OpenWhisk. All new functionality should primarily be implemented as a part of the function package residing in the dart_openwhisk/template/function/ directory. Extra dependencies should be added to the respective pubspec.yaml files in the root of the template or in the template/function directory. The project can be compiled and tested locally as usual. See the forllowing README.md for more information.

  1. Build and push the function:
# Define your docker image name and function name below
export FUNC_NAME=  # For example: test-function
export IMAGE_NAME= # For example: username/test-function:latest

# Then build and push the docker image to Docker Hub:
docker build template --tag $IMAGE_NAME && docker push $IMAGE_NAME
  1. Create a package and deploy the serverless function:
wsk -i package create demo && \
wsk -i action create /guest/demo/$FUNC_NAME --docker $IMAGE_NAME --web true

# To remove function deployments run:
wsk -i action delete /guest/demo/$FUNC_NAME
  1. Wait a few seconds, then we can invoke the function by sending a request through curl:
### Retrieve function invocation URL
export FUNC_URL=$(wsk -i action get /guest/demo/$FUNC_NAME --url | tail -1)

### Example GET request
curl -k \
  -X GET $FUNC_URL; \
  echo

# If nothing was changed in the 'dart_openwhisk/template/function' 
# directory before deployment then we should just see the default response:
>> Hello from OpenWhisk & Dart!

### Example POST request:
curl -k \
  -d "{\"name\": \"Peter\", \"age\": \"42\", \"height\": \"180.5\"}" \
  -H "Content-Type: application/json" \
  -X POST $FUNC_URL; \
  echo

# If nothing was changed in the 'dart_openwhisk/template/function'
# directory before deployment then we should just see the default response:
>> [{"string_field":"Peter"}, {"int_field":42}, {"double_field":180.5}]

For more information on how other request methods work see the OpenWhisk API gateway docs

You might also like...

This app is used to download whatsapp status photo and videos

This app is used to download whatsapp status photo and videos

This app is used to download whatsapp status photo and videos. you can upload this app in playstore as well. there are lot's of application available like WhatsApp Story Saver, Story Downloader for whatsapp.

Nov 28, 2022

A basic flutter app used to accompany a walkthrough

FLUTTER WALKTHROUGH Install Flutter SDK Dart SDK comes with the Flutter SDK Android Studio or XCode or VS Code Android Studio Install Flutter plugin f

Dec 15, 2021

Lottery smart contract is built with Solidity and Brownie. Flutter Web is used to buid the UI and link the smart contract.

lottery_dapp A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if

Dec 15, 2021

This is a simple flutter prototype that can be used to search contacts on mobile phones.

flutter_contacts_example This is a simple prototype which allow us to search contacts. Getting Started This project is a starting point for a Flutter

Apr 20, 2022

A flutter base libs package, used in company's project.

组件库 project_base_libs_pkg 在pubspec.yaml的dependencies:中引入: project_base_libs_pkg: git: url: https://github.com/YouXianMing/flutter_project_

Nov 2, 2022

An example project to demonstrate how moor can be used on multiple platforms

An example project to demonstrate how moor can be used on multiple platforms

moor_shared An example project to demonstrate how moor can be used on multiple p

Dec 28, 2021

Relive is a cross-platform application that can be used both in Android/IOS and it is made using Flutter

Relive is a cross-platform application that can be used both in Android/IOS and it is made using Flutter

📌 Introduction Relive is a cross-platform application that can be used both in Android/IOS and it is made using Flutter. It aims to solve the mental

Nov 4, 2022

used REStful APIs to fetch reports of covid-19

covid_tracker A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if

Oct 9, 2022

A Dart library for creating a Dart object to represent directory trees.

Directory Tree A Dart library for creating a Dart object to represent directory trees. Getting Started Import and initialize package import 'package:d

Dec 1, 2021
Owner
Nicklas Sindlev Andersen
Nicklas Sindlev Andersen
To cure symptoms of various disease using medicines at home this app will act as guideline. Few animations are used and Firebase is used as database.

Medkit It's a Pharmacy application that help you in curing basic symptoms and diseases with medicines available in your home. How to Run Code Clone or

Muhammad Hamza 109 Dec 22, 2022
Routinger is a task scheduler app that is made to make you a better person at no extra cost. The code is open-source. Dart language and Flutter framework are used extensively.

Routinger This is a simple app that will allow you to schedule your tasks, create a simple to-do, and also make recurring tasks. The app ends you noti

Routinger 16 Dec 17, 2022
FlutterCardSwipe Card Swipe Animation Creating the swipe view as used in the Tinder.

FlutterCardSwipe Card Swipe Animation Creating the swipe view as used in the Tinder. Swipe right is considered accepted and swipe left is rejected.It

Ruchika Gupta 517 Dec 27, 2022
News Headline app is build in Flutter MVVM and REST Apis for News is used in this app.

About The Project Flutter MVVM project for News Headlines. REST Api for News is used in this project. App Demo Api for News Get free api from here : h

Aizaz ahmad 3 Aug 16, 2022
used sqflite flutter , bloc

todoapp A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this

sara attia 1 Dec 2, 2022
A simple app to demonstrate a testable, maintainable, and scalable architecture for flutter. flutter_bloc, hive, and REST API are some of the tech stacks used in this project.

last_fm A simple app to demonstrate a testable, maintainable, and scalable architecture for flutter. flutter_bloc, hive, and REST API are some of the

Elias Andualem 140 Dec 31, 2022
Kind of app that generally used to maintain our day-to-day tasks or list everything that we have to do.We can add more tasks at any time and delete a task that is completed.

todo_application A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Khaled Elnkhla 0 Nov 6, 2021
Compact representation of a placeholder for an image. Encode a blurry image under 30 caracters for instant display like used by Medium. Maintainer: @Solido

Flutter BlurHash Compact representation of a placeholder for an image. Generation You can use https://blurha.sh/ for testing or use any official api o

Flutter Community 408 Dec 30, 2022
Sorting Visualizer using Flutter followed MVVM Pattern and used Stacked Services. Hope you like it 😋

Sortlizer An App to visualize various sorting algorithms...Developed using Flutter, followed MVVM pattern, and used stacked services. Play Store Link

Roshan Kumar 17 Dec 28, 2022
Concepts used Flutter layout,State management, Blockchain integration, Http api integration, Smart contracts

HS_CryptoCoin_Wallet First project using Flutter with Blockchain Getting Started This project is a starting point for a Flutter application. A few res

Harsh Saxena 1 Dec 23, 2021