Saving State Between API Calls

While working on a phoenix application, I found the need to hang onto some state between API calls. It wasn’t quite enough state, and losing the state wasn’t exactly a huge loss, so I decided to use Elixir’s Agent.

To ensure my state was easy to retrieve, I needed to name my Agent after something I’d easily have. As this is a Twilio application, the phone number being called should do nicely.

Read more.

XML Layouts in Phoenix

While working on a Phoenix app with an API, I felt I was missing out on the great templating engine offered by Phoenix. Fortunately, the next part of the application involved writing TwiML, an XML-based DSL built for programming Twilio.

Taking the example from their docs, the following response would respond with “Hello, world!” over the phone!

Read more.

Validation of API Calls With Ecto

After recently using elixir and phoenix to recreate the API for an old side project, I wanted to use Ecto’s embedded schemas, a schema that is not persisted to an underlying table, to validate the JSON coming into an API endpoint and get a workable domain object for the call before transforming it into the model persisted for the DB.

We’ll look at how I set up the sign-up and sign-in endpoints using the embeded schemas to validate the incoming JSON.

Read more.

Angular, Typescript, RequireJS, and More, Pt. 3

This is part 3 of our series. You can find part 1 here and part 2 here.

This post’s topic is unit testing. We’ll be using Mocha, Chai, and Sinon.JS. Everything will be run with Karma on PhantomJS, so we will be able to run this easily on a CI server such as Travis or Jenkins.

Read more.

Angular, TypeScript, RequireJS, and More, Pt. 2

This is part 2 of our series. Click here if you need to read part 1.

Now that we have our project set up, we can start building our application.

Read more.