Giter Club home page Giter Club logo

lamsubs's Introduction

Mailchimp App for LaMetric

An HTTP endpoint for polling Mailchimp subscriber numbers for an LaMetric Time device. Designed to run on Azure Functions uusing a Custom Request Handler which receives HTTP requests and responds like a web app.

Methods

Development

Uses Rocket so requires Rust nightly. Set up a nightly override on the directory once cloned:

rustup override set nightly

Set environment variables (see below) with the relevant config then run:

cargo run

to start the web server. Issue requests to the endpoints e.g.:

curl -v http://localhost:3000/api/get_subscribers

Unit tests

cargo test

Testing with Azure Functions

Requirements:

# Create the local.settings.json file which will set the environment variables
# Only required on a fresh clone when the file doesn't exist
func azure functionapp fetch-app-settings lamsubs
func start

Trigger HTTP function

curl -v http://localhost:7071/api/get_subscribers

Environment variables

  • LAMSUBS_MAILCHIMP_APIKEY: Mailchimp API key.
  • LAMSUBS_MAILCHIMP_LIST_ID: Mailchimp list ID string.
  • LAMSUBS_PRODUCTION: Set to any value when running in production.

Deployment

Create a new tag with the name format release-vx.y.z where x.y.z is a semantic versioning formatted version string e.g. release-v0.1.4

Azure uses the x86_64-unknown-linux-musl platform. Builds are done through a dedicated Docker container that has various C libraries built against musl.

Azure resources defined in main.bicep.

Manual

Requirements:

docker pull clux/muslrust
docker run -v $PWD:/volume --rm -t clux/muslrust cargo build --release
mkdir bin # host.json configured to expect binary here
cp target/x86_64-unknown-linux-musl/release/lamsubs bin/
bicep build ./main.bicep # generates main.json
az login
az deployment group create -f ./main.json -g lamsubs
func azure functionapp publish lamsubs

Automatic

Uses Azure ARM and Login GitHub actions to deploy.

AZURE_CREDENTIALS created as per the service principal instructions.

az ad sp create-for-rbac --name "lamsubs - GitHub" --sdk-auth --role contributor \
    --scopes /subscriptions/SUBSCRIPTIONID/resourceGroups/lamsubs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.