How to add a JS frontend to an API-only Phoenix app

If you generated a Phoenix app with the --no-brunch option you probably needed an API backend app.

What if, with your app growing, you realize you’d like to add also some frontend code? This short how-to will show you how integrate a Webpack based app with support to Typescript, React and Sass.

Read More »

API Authentication with Phoenix and React - part 2

In the first part of this post I’ve shown how to configure the API server to let the user authenticate, return an authentication token, and request it to access protected routes. Now I’m going to configure a React app to consume that API and manage authentication. The app uses React Router to manage routes and Redux for the state of the app. Protect private routes I’m going to define a PrivateRoute component as a wrapper around Route.

Read More »

API Authentication with Phoenix and React - part 1

Scenario: you just wrote a cool web app using React for the frontend part and Phoenix as the API server. Then you realize everybody can poke around your stuff and you decide it’s time to restrict the access to known users, how to do it? I’ll configure a Phoenix server to manage access tokens, used by a React app to make authenticated calls. This blog post only deals with the backend part and consists of these steps:

Read More »

React+Sass+Typescript with Phoenix framework using Webpack

If you’re playing with Elixir and Phoenix you’ll probably already know that Phoenix uses Brunch.io to build the assets pipeline. I initially started building my app with React / Redux + SASS and I was quite happy, but when I decided to add Typescript to the recipe, I found Brunch.io wasn’t very helpful! I’ve already used these tools using Webpack as building tool, so I decided to switch to it.

Read More »

How to logrotate rails logs

If you deploy a rails app forgetting to configure logs automatic rotation, few weeks later won’t be difficult to find something like this: $ ls -lh log/production.log -rw-rw-r-- 1 www-data www-data 93,2M apr 10 17:49 production.log Think if you have to find some error log inside a 100MB file, not easy… :) Setting log rotation isn’t difficult at all. I know two main ways. Use syslog This is a really easy solution.

Read More »

Generate the sitemap of a Ghost blog during deploy

Waiting for a sitemap generator inside the core of Ghost (planned as “future implementation”) I decided to implement a way to generate an up-to-date sitemap.xml during deployment. As you can read in the previous post I’m deploying this blog with Capistrano and capistrano-node-deploy. So I added a deploy:generate_sitemap task which is executed at the end of the deployment process. This is the Capfile extract: namespace :deploy do task :generate_sitemap do run "cd #{latest_release}&& .

Read More »

Git: Content-addressable filesystem and Version Control System

GIT: Content-addressable filesystem and Version Control System from Tommaso Visconti

Read More »

Paypal Express Checkout with Ruby on Rails and paypal-sdk-merchant

In my last work, Agrimè.it, an ecommerce built using Ruby on rails, I had to implement the cart payment using Paypal Express Checkout. Sadly, I found that was the worst time to do it, because Paypal was migrating the classic API to the new REST API and the documentation was a real mess! Walking through the doc links, I jumped (without a particular logic) from the new to the old API reference and vice versa.

Read More »

Passare a Vim grazie ad Emacs

Grazie Sciamp per avermi convinto a passare a Vim parlandomi di Emacs :) Lo so, sembra uno scherzo, eppure è proprio vero! Era da tanto che volevo cambiare editor passando da Textmate a qualcos’altro, ho intravisto Sublime Text 2, ma volevo qualcosa di open source. Da un po’ di tempo Alessandro stava rompendo le scatole a tutti su quanto è figo Emacs :) e avevo iniziato a lavorarci un po’, ma non sono mai riuscito ad entrarci in sintonia.

Read More »

Create a contact form for Jekyll

As I promised to a reader who wrote me an email some days ago, with this post I’ll explain how I built the contact form of this website using Sinatra and Sendgrid. As you know (or you’re just learning) this site is made by Jekyll, a static site generator written in Ruby. As the result of the work of Jekyll it is a static HTML website, so it’s not immediate to build a contact form.

Read More »