Created
May 9, 2016 14:07
-
-
Save LevelbossMike/3ed00818f42f565f463cee47e303bdab to your computer and use it in GitHub Desktop.
New Twiddle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from "ember-data"; | |
export default DS.JSONAPIAdapter.extend(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function returnJSON(status, body) { | |
return json(...arguments); | |
}; | |
export function json(status, body) { | |
if (arguments.length === 1) { | |
body = status; | |
status = 200; | |
} | |
return [ | |
status, | |
{ "Content-Type": "application/json" }, | |
JSON.stringify(body) | |
]; | |
}; | |
export const server = new Pretender(); | |
export function initialize() { | |
server.handledRequest = function(verb, path, request) { | |
console.log(`handled request to ${verb} ${path}`); | |
} | |
server.unhandledRequest = function(verb, path, request) { | |
console.log(`undhandled request ${verb} ${path}`); | |
} | |
}; | |
export default { | |
name: 'pretender', | |
initialize | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from "ember-data"; | |
const { Model, attr } = DS; | |
export default Model.extend({ | |
name: attr() | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import { server, json } from '../initializers/pretender'; | |
server.map(function() { | |
this.get('/people/1', function() { | |
return json({ | |
data: { | |
type: 'person', | |
id: 1, | |
attributes: { | |
name: 'George Michael Bluth' | |
} | |
} | |
}); | |
}); | |
}); | |
export default Ember.Route.extend({ | |
model: function() { | |
return this.store.findRecord('person', 1); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from "ember-data"; | |
export default DS.JSONAPISerializer.extend(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.7.2", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "release", | |
"ember-data": "canary", | |
"ember-template-compiler": "release", | |
"route-recognizer": "https://rawgit.com/tildeio/route-recognizer/56f5fcec6ae58d8e86b5dc77609809fb91198142/dist/route-recognizer.js", | |
"FakeXMLHttpRequest": "https://rawgit.com/pretenderjs/FakeXMLHttpRequest/23c3a96b5b24f1bfe595867437e4f128a29c2840/fake_xml_http_request.js", | |
"pretender": "https://rawgit.com/pretenderjs/pretender/c6de9afe18b1472aded2592f5a80ad9a26a0e262/pretender.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment