├── .gitignore ├── images ├── robot.png ├── arm-grabber.png ├── base-rocket.png ├── base-spring.png ├── torso-pouch.png ├── arm-dual-claw.png ├── arm-propeller.png ├── example_robot.png ├── head-big-eye.png ├── head-friendly.png ├── head-shredder.png ├── torso-gauged.png ├── arm-stubby-claw.png ├── head-single-eye.png ├── base-double-wheel.png ├── base-single-wheel.png ├── base-triple-wheel.png ├── head-surveillance.png ├── arm-articulated-claw.png └── torso-flexible-gauged.png ├── package.json └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | node_modules/ -------------------------------------------------------------------------------- /images/robot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/robot.png -------------------------------------------------------------------------------- /images/arm-grabber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/arm-grabber.png -------------------------------------------------------------------------------- /images/base-rocket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/base-rocket.png -------------------------------------------------------------------------------- /images/base-spring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/base-spring.png -------------------------------------------------------------------------------- /images/torso-pouch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/torso-pouch.png -------------------------------------------------------------------------------- /images/arm-dual-claw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/arm-dual-claw.png -------------------------------------------------------------------------------- /images/arm-propeller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/arm-propeller.png -------------------------------------------------------------------------------- /images/example_robot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/example_robot.png -------------------------------------------------------------------------------- /images/head-big-eye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/head-big-eye.png -------------------------------------------------------------------------------- /images/head-friendly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/head-friendly.png -------------------------------------------------------------------------------- /images/head-shredder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/head-shredder.png -------------------------------------------------------------------------------- /images/torso-gauged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/torso-gauged.png -------------------------------------------------------------------------------- /images/arm-stubby-claw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/arm-stubby-claw.png -------------------------------------------------------------------------------- /images/head-single-eye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/head-single-eye.png -------------------------------------------------------------------------------- /images/base-double-wheel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/base-double-wheel.png -------------------------------------------------------------------------------- /images/base-single-wheel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/base-single-wheel.png -------------------------------------------------------------------------------- /images/base-triple-wheel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/base-triple-wheel.png -------------------------------------------------------------------------------- /images/head-surveillance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/head-surveillance.png -------------------------------------------------------------------------------- /images/arm-articulated-claw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/arm-articulated-claw.png -------------------------------------------------------------------------------- /images/torso-flexible-gauged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jmcooper/build-a-bot-server/HEAD/images/torso-flexible-gauged.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "build-a-bot-server", 3 | "version": "1.0.0", 4 | "description": "A server used by the Pluralsight Vue.js Fundamentals course", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node ." 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+ssh://git@github.com/jmcooper/build-a-bot-server.git" 12 | }, 13 | "keywords": [ 14 | "Vue.js", 15 | "funamentals", 16 | "training", 17 | "api" 18 | ], 19 | "author": "Jim Cooper", 20 | "license": "ISC", 21 | "bugs": { 22 | "url": "https://github.com/jmcooper/build-a-bot-server/issues" 23 | }, 24 | "homepage": "https://github.com/jmcooper/build-a-bot-server#readme", 25 | "dependencies": { 26 | "connect-history-api-fallback": "^1.5.0", 27 | "express": "^4.16.3" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const express = require("express"); 3 | 4 | const app = express(); 5 | 6 | app.get('/api/parts', (req, res) => 7 | res.send({ 8 | heads: [ 9 | { 10 | id: 1, 11 | description: 12 | "A robot head with an unusually large eye and teloscpic neck -- excellent for exploring high spaces.", 13 | title: "Large Cyclops", 14 | src: "/api/images/head-big-eye.png", 15 | type: "heads", 16 | cost: 1225.5 17 | }, 18 | { 19 | id: 2, 20 | description: "A friendly robot head with two eyes and a smile -- great for domestic use.", 21 | title: "Friendly", 22 | src: "/api/images/head-friendly.png", 23 | cost: 945.0, 24 | type: "heads", 25 | onSale: true 26 | }, 27 | { 28 | id: 3, 29 | description: 30 | "A large three-eyed head with a shredder for a mouth -- great for crushing light medals or shredding documents.", 31 | title: "Shredder", 32 | src: "/api/images/head-shredder.png", 33 | type: "heads", 34 | cost: 1275.5 35 | }, 36 | { 37 | id: 4, 38 | description: 39 | "A simple single-eyed head -- simple and inexpensive.", 40 | title: "Small Cyclops", 41 | src: "/api/images/head-single-eye.png", 42 | type: "heads", 43 | cost: 750.0 44 | }, 45 | { 46 | id: 5, 47 | description: 48 | "A robot head with three oscillating eyes -- excellent for surveillance.", 49 | title: "Surveillance", 50 | src: "/api/images/head-surveillance.png", 51 | type: "heads", 52 | cost: 1255.5 53 | } 54 | ], 55 | arms: [ 56 | { 57 | id: 1, 58 | description: "An articulated arm with a claw -- great for reaching around corners or working in tight spaces.", 59 | title: "Articulated", 60 | src: "/api/images/arm-articulated-claw.png", 61 | type: "arms", 62 | cost: 275 63 | }, 64 | { 65 | id: 2, 66 | description: "An arm with two independent claws -- great when you need an extra hand. Need four hands? Equip your bot with two of these arms.", 67 | title: "Two Clawed", 68 | src: "/api/images/arm-dual-claw.png", 69 | type: "arms", 70 | cost: 285 71 | }, 72 | { 73 | id: 3, 74 | description: "A telescoping arm with a grabber.", 75 | title: "Grabber", 76 | src: "/api/images/arm-grabber.png", 77 | type: "arms", 78 | cost: 205.5 79 | }, 80 | { 81 | id: 4, 82 | description: "An arm with a propeller -- good for propulsion or as a cooling fan.", 83 | title: "Propeller", 84 | src: "/api/images/arm-propeller.png", 85 | type: "arms", 86 | cost: 230, 87 | onSale: true 88 | }, 89 | { 90 | id: 5, 91 | description: "A short and stubby arm with a claw -- simple, but cheap.", 92 | title: "Stubby Claw", 93 | src: "/api/images/arm-stubby-claw.png", 94 | type: "arms", 95 | cost: 125 96 | } 97 | ], 98 | torsos: [ 99 | { 100 | id: 1, 101 | description: "A torso that can bend slightly at the waist and equiped with a heat guage.", 102 | title: "Flexible Gauged", 103 | src: "/api/images/torso-flexible-gauged.png", 104 | type: "torsos", 105 | cost: 1575 106 | }, 107 | { 108 | id: 2, 109 | description: "A less flexible torso with a battery gauge.", 110 | title: "Gauged", 111 | src: "/api/images/torso-gauged.png", 112 | type: "torsos", 113 | cost: 1385 114 | }, 115 | { 116 | id: 3, 117 | description: "A simple torso with a pouch for carrying items.", 118 | title: "Gauged", 119 | src: "/api/images/torso-pouch.png", 120 | type: "torsos", 121 | cost: 785, 122 | onSale: true 123 | } 124 | ], 125 | bases: [ 126 | { 127 | id: 1, 128 | description: "A two wheeled base with an accelerometer for stability.", 129 | title: "Double Wheeled", 130 | src: "/api/images/base-double-wheel.png", 131 | type: "bases", 132 | cost: 895 133 | }, 134 | { 135 | id: 2, 136 | description: "A rocket base capable of high speed, controlled flight.", 137 | title: "Rocket", 138 | src: "/api/images/base-rocket.png", 139 | type: "bases", 140 | cost: 1520.5 141 | }, 142 | { 143 | id: 3, 144 | description: "A single-wheeled base with an accelerometer capable of higher speeds and navigating rougher terrain than the two-wheeled variety.", 145 | title: "Single Wheeled", 146 | src: "/api/images/base-single-wheel.png", 147 | type: "bases", 148 | cost: 1190.5 149 | }, 150 | { 151 | id: 4, 152 | description: "A spring base - great for reaching high places.", 153 | title: "Spring", 154 | src: "/api/images/base-spring.png", 155 | type: "bases", 156 | cost: 1190.5 157 | }, 158 | { 159 | id: 5, 160 | description: "An inexpensive three-wheeled base. only capable of slow speeds and can only function on smooth surfaces.", 161 | title: "Triple Wheeled", 162 | src: "/api/images/base-triple-wheel.png", 163 | type: "bases", 164 | cost: 700.5 165 | } 166 | ] 167 | }) 168 | ); 169 | 170 | app.post('/api/cart', (req, res) => 171 | setTimeout(() => res.status(201).send(), 800) 172 | ); 173 | 174 | app.post('/api/sign-in', (req, res) => res.status(200).send()); 175 | 176 | app.use('/api/images', express.static('images')); 177 | 178 | app.listen(8081, () => console.log('Server listening on port 8081!')); 179 | 180 | --------------------------------------------------------------------------------