Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Latest commit

 

History

History
273 lines (187 loc) · 6.11 KB

slides.md

File metadata and controls

273 lines (187 loc) · 6.11 KB

title: Better APIs and smarter AIs output: index.html theme: theme controls: false logo: theme/logo.png

--

Better APIs and smarter AIs

YYCJS summer finale

-- sponsors

Our Sponsors

Assembly

Village Brewery

Startup Calgary

PetroFeed

--

How it all began...

The beginning of YYCJS

--

This year

--

Brought to you by

-- presenter

Cory Smith

Cory Smith

-- presenter

Eric Kryski

Eric Kryski

-- presenter

David Luecke

David Luecke

-- presenter

SAM

SAM

-- centered

Built with...

Feathers logo

--

Express

// npm install express body-parser
var express = require('express');
var bodyParser = require('body-parser');

var app = express()
  .use(bodyParser.json())
  .use('/', express.static(__dirname))
  .post('/todos', function(req, res, next) {
    var todo = req.body;
    res.json(todo);
  });

app.listen(8080);

--

Feathers Services

var feathers = require('feathers');
var bodyParser = require('body-parser');

var app = feathers()
  .use(bodyParser.json())
  .use('/', feathers.static(__dirname))
  .configure(feathers.rest())
  .configure(feathers.socketio())
  .use('/todos', {
    find: function(params, callback) {},
    get: function(id, params, callback) {},
    create: function(data, params, callback) {},
    update: function(id, data, params, callback) {},
    patch: function(id, data, params, callback) {},
    remove: function(id, params, callback) {}
  });

app.listen(8080);

--

A MongoDB REST and real-time API

10 lines, no generators, no magic

// npm install feathers feathers-mongodb body-parser
var feathers = require('feathers');
var bodyParser = require('body-parser');
var mongodb = require('feathers-mongodb');

var app = feathers()
  .configure(feathers.rest())
  .configure(feathers.socketio())
  .use(bodyParser.json())
  .use(feathers.static(__dirname))
  .use('/todos', mongodb({
    collection: 'todos'
  }));

app.listen(8080);

app.service('todos').create({
  text: 'A Todo created on the server'
  complete: false
});

--

Client use

feathers-client is a JavaScript client that connects to REST or real-time Feathers services. Use it on other NodeJS servers, with libraries like jQuery or client side frameworks like React, Angular or CanJS:

<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script src="socket.io/socket.io.js"></script>
<script src="node_modules/feathers-client/dist/feathers.js"></script>
<script type="text/javascript">
  var socket = io();
  var app = feathers().configure(feathers.socketio(socket));
  var todos = app.service('todos');

  todos.on('created', function(todo) {
    console.log('New Todo created: ' + todo.text);
  });

  todos.create({
    text: 'Todo created on the client',
    complete: false
  });
</script>

-- centered

Real-time proxy for existing APIs

Real time proxy

--

Demo: React real-time Todos

--

Demo: Android and iOS real-time Todos

--

Demo: A voice controlled shopping list

--

Programming the future

-- centered

Grace Hopper

--

COBOL (1959)

DISPLAY "Enter First Number      : " WITH NO ADVANCING
ACCEPT Num1
DISPLAY "Enter Second Number     : " WITH NO ADVANCING
ACCEPT Num2
DISPLAY "Enter operator (+ or *) : " WITH NO ADVANCING
ACCEPT Operator
IF Operator = "+" THEN
  ADD Num1, Num2 GIVING Result
END-IF
IF Operator = "*" THEN
  MULTIPLY Num1 BY Num2 GIVING Result
END-IF
DISPLAY "Result is = ", Result

--

JavaScript/ES6 (2015)

import readline from 'readline';

const rl = readline.createInterface({
  input: process.stdin, output: process.stdout
});

rl.question("Enter First Number", num1 => {
  num1 = parseInt(num1, 10);
  rl.question("Enter Second Number", num2 => {
    num2 = parseInt(num2, 10);
    rl.question("Enter Operator (+ or *)", operator => {
      let result = -1;

      if(operator === '*') {
        result = num1 * num2;
      } else if(operator === '+') {
        result = num1 + num2;
      }

      console.log('Result is = ' + result);
      rl.close();
    });
  });
});

--

More teaching. Less coding.