Mobile Backend Development

About me

(Shameless plug)

  • Manuel Weidmann
  • @7PEnterpriseMob
  • Backend Dev
  • Tech Hipster
  • Get-Shit-Done-Evangelist
  • #MakeDevelopmentQuiteOKAgain

(?!)

YE olde times

of backend dev

what actually happens

(totally different...)

if all stars align

Honestly, though

This is is what I DO

  • Backends for Mobile Clients
  • For lots of calls
  • For lots of different devices
  • DevOps
  • Infrastructure

Honestly, though

This is is what we USE

  • Jersey
  • Spring
  • Hapi
  • Spark

Honestly, though

This is is what we USE

  • Java
  • Node
  • Kotlin
  • Lua
  • Python
  • Shell

Honestly, though

This is is what we USE

  • Gitlab
  • Jenkins
  • Docker
  • Mock-Server

(really, that's the name...)

REST

  • Stateless
  • Everything is a resource
  • HTTP verbs convey intent

(duh...)

REST

  • JSON, XML, text
  • Custom MIME types
  • Automatic resource discovery
  • Thin clients

(ain't nobody got time for that...)

RESTFUL

ish

kind of

in a way

mostly...

REST?

CHILL.

  • You are not the web
  • Keep it simple
  • Keep your mobile devs happy
  • Keep your sanity
  • If it feels wrong it probably is



// GET simple server info                                                                                                                                                    
Server.route({                                                                                                                                                               
  method: 'GET',                                                                                                                                                             
  path: '/info',                                                                                                                                                             
  config: {                                                                                                                                                                  
    tags: ['api'],                                                                                                                                                           
    response: {                                                                                                                                                              
      schema: JenniferInfo.schema                                                                                                                                            
    }                                                                                                                                                                        
  },                                                                                                                                                                         
  handler: (request, reply) => {                                                                                                                                             
    Log.debug(request.headers);                                                                                                                                              
    return reply({                                                                                                                                                           
      name: require('./package').name,                                                                                                                                       
      version: require('./package').version                                                                                                                                  
    })                                          
  }                                                                                                                                                                          
})


// result

{
  "name": "jennifer",
  "version": "0.10.1"
}

// request

curl -X GET jennifer:8000/info



// GET simple server info                                                                                                                                                    
Server.route({                                                                                                                                                               
  method: 'GET',                                                                                                                                                             
  path: '/info',                                                                                                                                                             
  config: {                                                                                                                                                                  
    tags: ['api'],                                                                                                                                                           
    response: {                                                                                                                                                              
      schema: JenniferInfo.schema                                                                                                                                            
    }                                                                                                                                                                        
  },                                                                                                                                                                         
  handler: (request, reply) => {                                                                                                                                             
    Log.debug(request.headers);                                                                                                                                              
    return reply({                                                                                                                                                           
      name: require('./package').name,                                                                                                                                       
      version: require('./package').version                                                                                                                                  
    })
    .type('application/prs.com.sevenp.jennifer.info-v1+json')
  }                                                                                                                                                                          
})


// result

{
  "name": "jennifer",
  "version": "0.10.1"
}

// request

curl -X GET \
  --header 'Accept: application/\
  prs.com.sevenp.jennifer.info-v1+json'\
  jennifer:8000/info

API

(Yeah!)

DOCUMENTED API

(oh...)

?

  • Word
  • JavaDoc
  • Wiki (Confluence)
  • Specification (Open API, JSON APi)

Changes

(WHOops)

BREAKING

  • Just don't do it
  • Just do it
  • Transition your clients
  • Leave your clients behind

CLIENTS

API VERSIONING

API

API VERSION 2

  • Path - /api/v1/
  • Header - X-version=v1
  • Content-Type - application/info-v1+json
  • Model property - {'version': 'v1'}

CLIENTS

  • Your customer
  • Your apps in the wild
  • Your mobile devs
  • Your backend devs

CLIENTS

  • Keep talking and nobody explodes
  • Make it easy for your devs
  • Bear mobile in mind
  • Provide early access
  • Provide easy mocks

(mobile devs)

Mocks

on demand



HttpRequest request = request()
                .withMethod("GET")
                .withPath("/shipments")
                .withHeaders(new Header("emmi-api-version", new String[]{

HttpResponse response = response()
                .withStatusCode(200)
                .withHeader(header("Content-Type", CONTENT_TYPE_JSON))
                .withBody(fromTemplateResource("shipments/list/full.json",
                new ImmutablePair<>("$DATE", currentDate)));

automate

all

the things

  • Build
  • Test
  • Deployment
  • Delivery
  • Quality Check
  • Mocks
  • Documentation

Auto-what?

Tooling

(get shit done)

stages:
  - build
  - test
  - package
  - deploy

build:
  stage: build
  script:
    - mvn compile
    
test:
  stage: test
  script:
    - mvn test
    
package:
  stage: package
  script:
    - mvn -DskipTests package

deploy:
  only: 
   - master
  stage: deploy
  environment: einback
  script:
   - 'mvn -Dwar.warName=oauth-backend package'
   - 'curl -v -H "Authorization: $TOMCAT_AUTHORIZATION" \
      --upload-file target/oauth-backend.war "$TOMCAT_UPLOAD_URL"'

WHAT the...

(Don't ask)

(just fix it)

  • JSON is UTF encoded?
  • Please-ignore-me headers
  • We ran out of URI string

recommendations

(diy)

  • Kotlin
  • Kotlin (Javascript)
  • NodeJS
  • Docker
  • Open API
  • Swift for Backends
  • Spark Java

Thanks

a bunch.

there is one more thing:

f**k proxies.

Made with Slides.com