Skip to content

Instantly share code, notes, and snippets.

View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
View App.js
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import Characters from './components/characters/Characters.js'
class App extends Component {
render() {
return (
<div className="App">
<Characters {...this.props}/>
View Characters.js
import React, {Component,PropTypes} from 'react'
import './characters.css';
class Characters extends Component{
constructor(props) {
super(props);
}
componentDidMount() {
var sess=this;
View output.json
[
{
"characterId": 1,
"name": "Homer Simpson",
"actor": "Dan Castellaneta",
"description": "Husband of Marge; father of Bart, Lisa, and Maggie.",
"debut": "Good Night (The Simpsons short)",
"airDate": "1987-04-19T00:00:00.000Z"
},
{
View package.json
{
"name": "backend",
"version": "1.0.0",
"description": "Backend for Serverless demo",
"main": "app.js",
"dependencies": {
"claudia-api-builder": "^4.1.1",
"claudia": "^5.1.1"
},
"devDependencies": {},
View app.js
var ApiBuilder = require('claudia-api-builder'),
api = new ApiBuilder();
var mysql = require('mysql');
var {Op, Sequelize} = require('sequelize');
module.exports = api;
api.get('/characters', function () {
return new Promise(
(resolve, reject) => {
View app.js
var ApiBuilder = require('claudia-api-builder'),
api = new ApiBuilder();
var mysql = require('mysql');
var {Op, Sequelize} = require('sequelize');
module.exports = api;
View serverless-demo.sql
CREATE TABLE `characters` (
`characterId` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(200) DEFAULT NULL,
`actor` varchar(200) DEFAULT NULL,
`description` varchar(500) DEFAULT NULL,
`debut` varchar(200) DEFAULT NULL,
`airDate` datetime DEFAULT NULL,
PRIMARY KEY (`characterId`)
) ENGINE=InnoDB AUTO_INCREMENT=71 DEFAULT CHARSET=latin1;
View credentials
[default]
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_ACCESS_SECRET