-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac2d7d0
commit 91b59f4
Showing
14 changed files
with
665 additions
and
32 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 |
---|---|---|
@@ -1,33 +1,10 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
node_modules | ||
npm-debug.log | ||
typings | ||
|
||
# Optional npm cache directory | ||
.npm | ||
Thumbs.db | ||
.DS_Store | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
src/**/*.js | ||
*.map | ||
*.d.ts |
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 @@ | ||
README.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,6 @@ | ||
# Node generated files | ||
node_modules | ||
npm-debug.log | ||
# OS generated files | ||
Thumbs.db | ||
.DS_Store |
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 |
---|---|---|
@@ -1,2 +1,64 @@ | ||
# ng2-data | ||
Convential HTTP client for Model Data | ||
# NOT READY! | ||
## ng2-data | ||
Conventional HTTP client for Model Data in Angular 2 | ||
|
||
## Examples | ||
### Making Models | ||
```javascript | ||
// user.model.ts | ||
import {Model, Type} from 'ng2-data'; | ||
|
||
exports Model.define('student', { | ||
name: Type.string, | ||
age: Type.number, | ||
// classes: Type.has.many('courses'), | ||
// school: Type.has.one('school'), | ||
// nameAndAge: function (student) { | ||
// return student.name + student.age; | ||
// } | ||
}); | ||
``` | ||
|
||
### Loading Store | ||
```javascript | ||
import {StoreService, StoreConfig} from 'ng2-data'; | ||
|
||
export class AppComponent { | ||
constructor(store: StoreService) { | ||
store.init(new StoreConfig({baseUri: 'http://localhost:3003/api'})); | ||
} | ||
} | ||
``` | ||
|
||
|
||
### Using the store | ||
```javascript | ||
import {StoreService} from 'ng2-data'; | ||
|
||
export class MyComponent { | ||
constructor(store: StoreService) { | ||
// GET /users | ||
store.find('users').subscribe(/*...*/); | ||
|
||
// GET /courses?key=value | ||
store.find('courses', {/*query filter*/}).subscribe(/*...*/); // returns [user objects] | ||
|
||
// GET /users/1 | ||
store.findOne('user', 1).subscribe(/*...*/); // returns user object | ||
|
||
// POST /users | ||
store.create('user', {name:'bob'}).subscribe(/*...*/); | ||
// OR | ||
let bob = store.instance('user'); | ||
bob.name = 'bob'; | ||
//then | ||
bob.save().subscribe(/*...*/); | ||
|
||
// PUT /users/1 | ||
store.update('schools', 1, {/*with*/}).subscribe(/*...*/); // returns user object | ||
|
||
// DELETE /users/1 | ||
store.destroy('schools', 1).subscribe(/*...*/); // Returns OK | ||
} | ||
} | ||
``` |
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,10 @@ | ||
{ | ||
"port": 8000, | ||
"files": ["./src/**/*"], | ||
"server": { | ||
"baseDir": "./src", | ||
"routes": { | ||
"/node_modules": "node_modules" | ||
} | ||
} | ||
} |
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,47 @@ | ||
Error.stackTraceLimit = Infinity; | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 2000; | ||
|
||
__karma__.loaded = function () {}; | ||
|
||
System.config({ | ||
packages: { | ||
'base/src': { | ||
defaultExtension: false, | ||
format: 'register', | ||
map: Object.keys(window.__karma__.files) | ||
.filter(onlyAppFiles) | ||
.reduce(function (pathsMapping, appPath) { | ||
var moduleName = appPath.replace(/^\/base\/src\//, './').replace(/\.js$/, ''); | ||
pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath] | ||
return pathsMapping; | ||
}, {}) | ||
} | ||
} | ||
}); | ||
|
||
System.import('angular2/testing').then(function (testing) { | ||
return System.import('angular2/platform/testing/browser').then(function (providers) { | ||
testing.setBaseTestProviders(providers.TEST_BROWSER_PLATFORM_PROVIDERS, | ||
providers.TEST_BROWSER_APPLICATION_PROVIDERS); | ||
}); | ||
}).then(function () { | ||
return Promise.all( | ||
Object.keys(window.__karma__.files) | ||
.filter(onlySpecFiles) | ||
.map(function (moduleName) { | ||
return System.import(moduleName); | ||
})); | ||
}).then(function () { | ||
__karma__.start(); | ||
}, function (error) { | ||
__karma__.error(error.stack || error); | ||
}); | ||
|
||
function onlyAppFiles(filePath) { | ||
return /^\/base\/src\/(?!.*\.spec\.js$)([a-z0-9-_\.\/]+)\.js$/.test(filePath); | ||
} | ||
|
||
function onlySpecFiles(path) { | ||
return /\.spec\.js$/.test(path); | ||
} |
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,103 @@ | ||
module.exports = function (config) { | ||
config.set({ | ||
basePath: '', | ||
frameworks: ['jasmine'], | ||
plugins: [ | ||
require('karma-jasmine'), | ||
require('karma-chrome-launcher'), | ||
require('karma-mocha-reporter') | ||
], | ||
customLaunchers: { | ||
// chrome setup for travis CI using chromium | ||
Chrome_travis_ci: { | ||
base: 'Chrome', | ||
flags: ['--no-sandbox'] | ||
}, | ||
}, | ||
files: [{ | ||
pattern: 'node_modules/systemjs/dist/system-polyfills.js', | ||
included: true, | ||
watched: true | ||
}, { | ||
pattern: 'node_modules/systemjs/dist/system.src.js', | ||
included: true, | ||
watched: true | ||
}, { | ||
pattern: 'node_modules/es6-shim/es6-shim.js', | ||
included: true, | ||
watched: true | ||
}, { | ||
pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', | ||
included: true, | ||
watched: true | ||
}, { | ||
pattern: 'node_modules/rxjs/bundles/Rx.js', | ||
included: true, | ||
watched: true | ||
}, { | ||
pattern: 'node_modules/angular2/bundles/angular2.js', | ||
included: true, | ||
watched: true | ||
}, { | ||
pattern: 'node_modules/angular2/bundles/http.dev.js', | ||
included: true, | ||
watched: true | ||
}, { | ||
pattern: 'node_modules/angular2/bundles/router.dev.js', | ||
included: true, | ||
watched: true | ||
}, { | ||
pattern: 'node_modules/angular2/bundles/testing.dev.js', | ||
included: true, | ||
watched: true | ||
}, { | ||
pattern: 'karma-test-shim.js', | ||
included: true, | ||
watched: true | ||
}, | ||
|
||
// paths loaded via module imports | ||
{ | ||
pattern: 'src/**/*.js', | ||
included: false, | ||
watched: true | ||
}, | ||
|
||
// paths loaded via Angular's component compiler | ||
// (these paths need to be rewritten, see proxies section) | ||
{ | ||
pattern: 'src/**/*.html', | ||
included: false, | ||
watched: true | ||
}, { | ||
pattern: 'src/**/*.css', | ||
included: false, | ||
watched: true | ||
}, | ||
|
||
// paths to support debugging with source maps in dev tools | ||
{ | ||
pattern: 'src/**/*.ts', | ||
included: false, | ||
watched: false | ||
}, { | ||
pattern: 'src/**/*.js.map', | ||
included: false, | ||
watched: false | ||
} | ||
], | ||
// proxies: { | ||
// // required for component assets fetched by Angular's compiler | ||
// "/src/": "/base/src/" | ||
// }, | ||
exclude: [], | ||
preprocessors: {}, | ||
reporters: ['mocha'], | ||
port: 9876, | ||
colors: true, | ||
logLevel: config.LOG_INFO, | ||
autoWatch: true, | ||
browsers: ['Chrome'], | ||
singleRun: 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,57 @@ | ||
{ | ||
"name": "ng2-data", | ||
"version": "0.0.1", | ||
"description": "Convential HTTP client for Model Data in Angular 2", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/raghunat/ng2-data.git" | ||
}, | ||
"main": "src/ng2-data.js", | ||
"scripts": { | ||
"start": "concurrently \"npm run tsc:w\" \"npm run lite\" ", | ||
"tsc": "tsc", | ||
"tsc:w": "tsc -w", | ||
"lite": "lite-server", | ||
"typings": "typings", | ||
"postinstall": "typings install", | ||
"test": "./node_modules/karma/bin/karma start" | ||
}, | ||
"keywords": [ | ||
"angular", | ||
"angular2", | ||
"data", | ||
"orm", | ||
"http" | ||
], | ||
"author": "raghunat", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/raghunat/ng2-data/issues" | ||
}, | ||
"typings": "./ng2-data.d.ts", | ||
"homepage": "https://github.com/raghunat/ng2-data#readme", | ||
"dependencies": { | ||
"angular2": "2.0.0-beta.9", | ||
"es6-promise": "^3.0.2", | ||
"es6-shim": "^0.33.3", | ||
"reflect-metadata": "0.1.2", | ||
"rxjs": "5.0.0-beta.2", | ||
"zone.js": "0.5.15" | ||
}, | ||
"devDependencies": { | ||
"body-parser": "^1.15.0", | ||
"concurrently": "^2.0.0", | ||
"cors": "^2.7.1", | ||
"express": "^4.13.4", | ||
"glob": "^7.0.3", | ||
"jasmine-core": "^2.4.1", | ||
"jasmine-spec-reporter": "^2.4.0", | ||
"karma": "^0.13.22", | ||
"karma-chrome-launcher": "^0.2.2", | ||
"karma-jasmine": "^0.3.7", | ||
"karma-mocha-reporter": "^2.0.0", | ||
"lite-server": "^2.1.0", | ||
"systemjs": "~0.19.24", | ||
"typescript": "~1.7.5" | ||
} | ||
} |
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,15 @@ | ||
/** | ||
* Input Class | ||
*/ | ||
export class StoreConfig { | ||
public baseUri: string | ||
constructor(config:any = {}) { | ||
config = config || {}; | ||
|
||
// TODO | ||
// Sanitze inputs | ||
|
||
// bulk assign | ||
Object.assign(this, config); | ||
} | ||
} |
Oops, something went wrong.