-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sketch out request-manager
- Loading branch information
Showing
33 changed files
with
764 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
/** | ||
Ember CLI sends analytics information by default. The data is completely | ||
anonymous, but there are times when you might want to disable this behavior. | ||
|
||
Setting `disableAnalytics` to true will prevent any data from being sent. | ||
*/ | ||
"disableAnalytics": false | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# compiled output | ||
/dist/ | ||
/dist/**/* | ||
/tmp/ | ||
/types/ | ||
**/*.d.ts | ||
|
||
# dependencies | ||
/bower_components/ | ||
|
||
# misc | ||
/.bowerrc | ||
/.editorconfig | ||
/.ember-cli | ||
/.env* | ||
/.eslintignore | ||
/.eslintrc.js | ||
/.gitignore | ||
/.template-lintrc.js | ||
/.travis.yml | ||
/.watchmanconfig | ||
/bower.json | ||
/config/ember-try.js | ||
/CONTRIBUTING.md | ||
/ember-cli-build.js | ||
/testem.js | ||
/tests/ | ||
/yarn.lock | ||
.gitkeep | ||
|
||
# ember-try | ||
/.node_modules.ember-try/ | ||
/bower.json.ember-try | ||
/package.json.ember-try | ||
|
||
# ember-data | ||
/node-tests | ||
|
||
# whitelist yuidoc's data.json for api docs generation | ||
!/dist/docs/data.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"ignore_dirs": ["tmp", "dist"] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# @ember-data/network | ||
|
||
Provides a simple request management solution and fetch utilities for ember-data | ||
|
||
## Compatibility | ||
|
||
- Ember.js v3.4 or above | ||
- Ember CLI v2.13 or above | ||
|
||
## Installation | ||
|
||
``` | ||
ember install @ember-data/debug | ||
``` | ||
|
||
## Usage | ||
|
||
[Longer description of how to use the addon in apps.] | ||
|
||
## License | ||
|
||
This project is licensed under the [MIT License](LICENSE.md). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './request-manager'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { DEBUG } from '@glimmer/env'; | ||
|
||
interface Request {} | ||
|
||
interface NextFn { | ||
(request: Request): Promise<unknown>; | ||
} | ||
|
||
interface RequestResponse { | ||
result: unknown; | ||
} | ||
|
||
interface Middleware { | ||
request(request: Request, next: NextFn): Promise<unknown>; | ||
} | ||
|
||
const Wares = new WeakMap<RequestManager, Middleware[]>(); | ||
|
||
function waresFor(manager: RequestManager): Middleware[] { | ||
let wares = Wares.get(manager); | ||
|
||
if (wares === undefined) { | ||
wares = []; | ||
Wares.set(manager, wares); | ||
} | ||
|
||
return wares; | ||
} | ||
|
||
class RequestManager { | ||
use(ware: Middleware) { | ||
const wares = waresFor(this); | ||
if (DEBUG) { | ||
if (Object.isFrozen(wares)) { | ||
throw new Error(`Cannot add a Middleware to a RequestManager after a request has been made`); | ||
} | ||
} | ||
wares.push(ware); | ||
} | ||
|
||
request(request: Request): Promise<RequestResponse> { | ||
const wares = waresFor(this); | ||
if (DEBUG) { | ||
if (!Object.isFrozen(wares)) { | ||
Object.freeze(wares); | ||
} | ||
} | ||
return perform(wares, request); | ||
} | ||
} | ||
|
||
async function perform(wares: Readonly<Middleware[]>, request: Request, i: number = 0): Promise<RequestResponse> { | ||
if (i === wares.length) { | ||
throw new Error(`No middleware was able to handle this request.`); | ||
} | ||
function next(r: Request): Promise<RequestResponse> { | ||
return perform(wares, r, i + 1); | ||
} | ||
const result = await wares[i].request(request, next); | ||
return { result }; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = function(/* environment, appConfig */) { | ||
return {}; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); | ||
|
||
module.exports = function(defaults) { | ||
let app = new EmberAddon(defaults, { | ||
'ember-cli-babel': { | ||
throwUnlessParallelizable: true, | ||
}, | ||
}); | ||
|
||
/* | ||
This build file specifies the options for the dummy test app of this | ||
addon, located in `/tests/dummy` | ||
This build file does *not* influence how the addon or the app using it | ||
behave. You most likely want to be modifying `./index.js` or app's build file | ||
*/ | ||
|
||
return app.toTree(); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
const name = require('./package').name; | ||
const addonBuildConfigForDataPackage = require('@ember-data/-build-infra/src/addon-build-config-for-data-package'); | ||
const addonBaseConfig = addonBuildConfigForDataPackage(name); | ||
|
||
module.exports = Object.assign({}, addonBaseConfig, { | ||
shouldRollupPrivate: true, | ||
externalDependenciesForPrivateModule() { | ||
return []; | ||
}, | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"name": "@ember-data/network", | ||
"version": "3.15.0-alpha.1", | ||
"description": "Provides a simple request management solution and fetch utilities for ember-data", | ||
"keywords": [ | ||
"ember-addon" | ||
], | ||
"repository": "https://github.com/emberjs/data/tree/master/packages/adapter", | ||
"license": "MIT", | ||
"author": "", | ||
"directories": { | ||
"doc": "doc", | ||
"test": "tests" | ||
}, | ||
"scripts": { | ||
"build": "ember build", | ||
"start": "ember serve", | ||
"test": "ember test", | ||
"test:all": "ember try:each" | ||
}, | ||
"dependencies": { | ||
"@ember-data/-build-infra": "3.15.0-alpha.1", | ||
"@ember/edition-utils": "^1.1.1", | ||
"ember-cli-babel": "^7.12.0", | ||
"ember-cli-test-info": "^1.0.0", | ||
"ember-cli-typescript": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ember-data/-test-infra": "3.15.0-alpha.1", | ||
"@ember/optional-features": "^1.0.0", | ||
"broccoli-asset-rev": "^3.0.0", | ||
"ember-cli": "~3.13.1", | ||
"ember-cli-blueprint-test-helpers": "^0.19.1", | ||
"ember-cli-dependency-checker": "^3.2.0", | ||
"ember-cli-htmlbars": "^4.0.3", | ||
"ember-cli-htmlbars-inline-precompile": "^3.0.1", | ||
"ember-cli-inject-live-reload": "^2.0.1", | ||
"ember-cli-sri": "^2.1.1", | ||
"ember-cli-uglify": "3.0.0", | ||
"ember-disable-prototype-extensions": "^1.1.3", | ||
"ember-export-application-global": "^2.0.0", | ||
"ember-load-initializers": "^2.1.0", | ||
"ember-maybe-import-regenerator": "^0.1.6", | ||
"ember-qunit": "^4.5.1", | ||
"ember-resolver": "^5.3.0", | ||
"ember-source": "^3.13.2", | ||
"ember-source-channel-url": "^2.0.1", | ||
"ember-try": "^1.2.1", | ||
"loader.js": "^4.7.0", | ||
"silent-error": "^1.1.1" | ||
}, | ||
"engines": { | ||
"node": ">= 8.0.0" | ||
}, | ||
"ember-addon": { | ||
"configPath": "tests/dummy/config" | ||
} | ||
} |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Application from '@ember/application'; | ||
import Resolver from './resolver'; | ||
import loadInitializers from 'ember-load-initializers'; | ||
import config from './config/environment'; | ||
|
||
const App = Application.extend({ | ||
modulePrefix: config.modulePrefix, | ||
podModulePrefix: config.podModulePrefix, | ||
Resolver, | ||
}); | ||
|
||
loadInitializers(App, config.modulePrefix); | ||
|
||
export default App; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export default config; | ||
|
||
/** | ||
* Type declarations for | ||
* import config from './config/environment' | ||
* | ||
* For now these need to be managed by the developer | ||
* since different ember addons can materialize new entries. | ||
*/ | ||
declare const config: { | ||
environment: any; | ||
modulePrefix: string; | ||
podModulePrefix: string; | ||
locationType: string; | ||
rootURL: string; | ||
}; |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title>Ember Data</title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
{{content-for "head"}} | ||
|
||
<link rel="stylesheet" href="{{rootURL}}assets/vendor.css"> | ||
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css"> | ||
|
||
{{content-for "head-footer"}} | ||
</head> | ||
<body> | ||
{{content-for "body"}} | ||
|
||
<script src="{{rootURL}}assets/vendor.js"></script> | ||
<script src="{{rootURL}}assets/dummy.js"></script> | ||
|
||
{{content-for "body-footer"}} | ||
</body> | ||
</html> |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Resolver from 'ember-resolver'; | ||
|
||
export default Resolver; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import EmberRouter from '@ember/routing/router'; | ||
import config from './config/environment'; | ||
|
||
const Router = EmberRouter.extend({ | ||
location: config.locationType, | ||
rootURL: config.rootURL, | ||
}); | ||
|
||
Router.map(function() {}); | ||
|
||
export default Router; |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Route.extend({}); |
6 changes: 6 additions & 0 deletions
6
packages/network/tests/dummy/app/routes/application/template.hbs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<ul> | ||
<li> | ||
<a href='/tests?hidepassed'>Tests</a> | ||
</li> | ||
</ul> | ||
{{outlet}} |
Empty file.
Empty file.
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
module.exports = function(environment) { | ||
var ENV = { | ||
modulePrefix: 'dummy', | ||
podModulePrefix: 'dummy/routes', | ||
environment: environment, | ||
rootURL: '/', | ||
locationType: 'auto', | ||
EmberENV: { | ||
RAISE_ON_DEPRECATION: false, | ||
}, | ||
|
||
APP: { | ||
// Here you can pass flags/options to your application instance | ||
// when it is created | ||
}, | ||
}; | ||
|
||
if (environment === 'development') { | ||
// ENV.APP.LOG_RESOLVER = true; | ||
// ENV.APP.LOG_ACTIVE_GENERATION = true; | ||
// ENV.APP.LOG_TRANSITIONS = true; | ||
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true; | ||
// ENV.APP.LOG_VIEW_LOOKUPS = true; | ||
} | ||
|
||
if (environment === 'test') { | ||
// Testem prefers this... | ||
ENV.locationType = 'none'; | ||
|
||
// keep test console output quieter | ||
ENV.APP.LOG_ACTIVE_GENERATION = false; | ||
ENV.APP.LOG_VIEW_LOOKUPS = false; | ||
|
||
ENV.APP.rootElement = '#ember-testing'; | ||
} | ||
|
||
return ENV; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
const browsers = ['last 1 Chrome versions', 'last 1 Firefox versions', 'last 1 Safari versions']; | ||
|
||
const needsIE11 = !!process.env.TARGET_IE11; | ||
|
||
if (needsIE11) { | ||
browsers.push('ie 11'); | ||
} | ||
|
||
module.exports = { | ||
browsers, | ||
}; |
Oops, something went wrong.