Skip to content
This repository was archived by the owner on Aug 18, 2018. It is now read-only.

Commit 64429fa

Browse files
authored
Merge pull request #17 from reyesoft/feature/better_store
Feature/better store
2 parents c7ee27c + f813ea2 commit 64429fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+661
-460
lines changed

.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ root = true
44

55
[*]
66
indent_style = space
7-
indent_size = 4
7+
indent_size = 2
88
end_of_line = lf
99
charset = utf-8
1010
trim_trailing_whitespace = true
1111
insert_final_newline = true
1212

13+
[src/**/*]
14+
indent_size = 4
15+
1316
[*.md]
1417
trim_trailing_whitespace = false

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# 0.6.x
2+
3+
## Localstorage cache
4+
5+
- Save on localstore all data. When you request a resource or collection, first check memory. If its empty, read from store. If is empty, get the data from back-end.
6+
- typings and index.d.ts removed. We only use `import`
7+
8+
# 0.5.x
9+
10+
All data is merged on one single resource. If you request a request a single related resource, and on this request not include any another resource, related resources come from memory cache (if exists)

README.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Jsonapi client library developed for AngularJS based on typescript.
1919
- [X] Filtering by regular expression
2020
- [x] Get a relationship from a URL (url like attributes->relationships->resource->links->self)
2121
- [x] Default values for a new resource
22-
- [x] [Properties on collections](https://github.com/reyesoft/ts-angular-jsonapi/blob/master/src/library/interfaces/collection.d.ts) like `$length`, `$isloading` or `$source` (_`empty`_ |`cache`|`server`)
22+
- [x] [Properties on collections](https://github.com/reyesoft/ts-angular-jsonapi/blob/master/src/library/interfaces/collection.d.ts) like `$length`, `$is_loading` or `$source` (_`empty`_ |`cache`|`server`)
2323

2424
## Usage
2525

@@ -62,10 +62,6 @@ Like you know, the better way is with examples. Based on [endpoints example libr
6262

6363
### Defining a resource
6464

65-
1. hola
66-
2. hola 2
67-
3. hola
68-
6965
`authors.service.ts`
7066

7167
```typescript
@@ -191,8 +187,6 @@ let author = AuthorsService.get(
191187
);
192188
```
193189

194-
````
195-
196190
### Update a resource
197191

198192
```javascript
@@ -201,9 +195,8 @@ this.author.attributes.name += 'New Name';
201195
this.author.save(success => {
202196
console.log('author saved!');
203197
});
204-
````
198+
```
205199

206-
````
207200
### Handling errors
208201

209202
### Pagination
@@ -261,4 +254,3 @@ gulp dist
261254
```
262255

263256
And commit! Don't forget your pull request :)
264-
````

conf/gulp.conf.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,17 @@ exports.paths = {
2525
tasks: 'gulp_tasks'
2626
};
2727

28+
/**
29+
* used on gulp dist
30+
*/
31+
exports.htmlmin = {
32+
ignoreCustomFragments: [/{{.*?}}/]
33+
};
34+
2835
exports.path = {};
2936
for (const pathName in exports.paths) {
30-
if (exports.paths.hasOwnProperty(pathName)) {
31-
exports.path[pathName] = function pathJoin() {
37+
if (Object.prototype.hasOwnProperty.call(exports.paths, pathName)) {
38+
exports.path[pathName] = function () {
3239
const pathValue = exports.paths[pathName];
3340
const funcArgs = Array.prototype.slice.call(arguments);
3441
const joinArgs = [pathValue].concat(funcArgs);

conf/webpack-dist.conf.js

Lines changed: 65 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,77 @@ const conf = require('./gulp.conf');
33
const path = require('path');
44

55
const HtmlWebpackPlugin = require('html-webpack-plugin');
6-
const SplitByPathPlugin = require('webpack-split-by-path');
7-
const ExtractTextPlugin = require("extract-text-webpack-plugin");
6+
const FailPlugin = require('webpack-fail-plugin');
7+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
8+
const pkg = require('../package.json');
89
const autoprefixer = require('autoprefixer');
910
var DeclarationBundlerPlugin = require('declaration-bundler-webpack-plugin');
1011

1112
module.exports = {
12-
module: {
13-
// https://github.com/localForage/localForage#browserify-and-webpack
14-
noParse: /node_modules\/localforage\/dist\/localforage.js/,
13+
module: {
14+
// https://github.com/localForage/localForage#browserify-and-webpack
15+
noParse: /node_modules\/localforage\/dist\/localforage.js/,
1516

17+
loaders: [
18+
{
19+
test: /\.json$/,
1620
loaders: [
17-
{
18-
test: /\.ts$/,
19-
exclude: /node_modules/,
20-
loaders: [
21-
'ng-annotate',
22-
'ts'
23-
]
24-
}
21+
'json-loader'
2522
]
26-
},
27-
plugins: [
28-
new webpack.optimize.OccurrenceOrderPlugin(),
29-
new webpack.NoErrorsPlugin()
30-
// new webpack.optimize.UglifyJsPlugin({
31-
// compress: {unused: true, dead_code: true} // eslint-disable-line camelcase
32-
// })
33-
],
34-
output: {
35-
// https://webpack.github.io/docs/library-and-externals.html
36-
path: path.join(process.cwd(), conf.paths.dist),
37-
library: 'Jsonapi',
38-
libraryTarget: 'commonjs',
39-
filename: 'ts-angular-jsonapi.js'
40-
},
41-
externals: {
42-
'angular': 'angular'
43-
},
44-
resolve: {
45-
extensions: [
46-
'',
47-
'.webpack.js',
48-
'.web.js',
49-
'.js',
50-
'.ts'
23+
},
24+
{
25+
test: /\.ts$/,
26+
exclude: /node_modules/,
27+
loader: 'tslint-loader',
28+
enforce: 'pre'
29+
},
30+
{
31+
test: /\.(css|scss)$/,
32+
loaders: ExtractTextPlugin.extract({
33+
fallback: 'style-loader',
34+
use: 'css-loader?minimize!sass-loader!postcss-loader'
35+
})
36+
},
37+
{
38+
test: /\.ts$/,
39+
exclude: /node_modules/,
40+
loaders: [
41+
'ng-annotate-loader',
42+
'ts-loader'
43+
]
44+
},
45+
{
46+
test: /\.html$/,
47+
loaders: [
48+
'html-loader'
5149
]
52-
},
53-
entry: `./${conf.path.srcdist('index.ts')}`,
54-
ts: {
55-
configFileName: 'tsconfig.json'
56-
},
57-
tslint: {
58-
configuration: require('../tslint.json')
59-
}
50+
}
51+
]
52+
},
53+
plugins: [
54+
new webpack.optimize.OccurrenceOrderPlugin(),
55+
new webpack.NoEmitOnErrorsPlugin()
56+
// new webpack.optimize.UglifyJsPlugin({
57+
// compress: {unused: true, dead_code: true} // eslint-disable-line camelcase
58+
// })
59+
],
60+
output: {
61+
// https://webpack.github.io/docs/library-and-externals.html
62+
path: path.join(process.cwd(), conf.paths.dist),
63+
library: 'Jsonapi',
64+
libraryTarget: 'commonjs',
65+
filename: 'ts-angular-jsonapi.js'
66+
},
67+
externals: {
68+
'angular': 'angular'
69+
},
70+
resolve: {
71+
extensions: [
72+
'.webpack.js',
73+
'.web.js',
74+
'.js',
75+
'.ts'
76+
]
77+
},
78+
entry: `./${conf.path.srcdist('index.ts')}`
6079
};

conf/webpack.conf.js

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,79 +3,89 @@ const conf = require('./gulp.conf');
33
const path = require('path');
44

55
const HtmlWebpackPlugin = require('html-webpack-plugin');
6+
const FailPlugin = require('webpack-fail-plugin');
67
const autoprefixer = require('autoprefixer');
78

89
module.exports = {
910
module: {
1011
// https://github.com/localForage/localForage#browserify-and-webpack
1112
noParse: /node_modules\/localforage\/dist\/localforage.js/,
1213

13-
preLoaders: [
14-
{
15-
test: /\.ts$/,
16-
exclude: /node_modules/,
17-
loader: 'tslint'
18-
}
19-
],
20-
2114
loaders: [
2215
{
23-
test: /.json$/,
16+
test: /\.json$/,
2417
loaders: [
25-
'json'
18+
'json-loader'
2619
]
2720
},
21+
{
22+
test: /\.ts$/,
23+
exclude: /node_modules/,
24+
loader: 'tslint-loader',
25+
enforce: 'pre'
26+
},
2827
{
2928
test: /\.(css|scss)$/,
3029
loaders: [
31-
'style',
32-
'css',
33-
'sass',
34-
'postcss'
30+
'style-loader',
31+
'css-loader',
32+
'sass-loader',
33+
'postcss-loader'
3534
]
3635
},
3736
{
38-
test: /\.(eot|woff|woff2|svg|ttf)([\?]?.*)$/, loader: "file-loader"
37+
test: /\.(eot|woff|woff2|svg|ttf)([\?]?.*)$/, loader: "file-loader"
3938
},
4039
{
4140
test: /\.ts$/,
4241
exclude: /node_modules/,
4342
loaders: [
44-
'ng-annotate',
45-
'ts'
43+
'ng-annotate-loader',
44+
'ts-loader'
45+
]
46+
},
47+
{
48+
test: /\.html$/,
49+
loaders: [
50+
'html-loader'
4651
]
4752
}
4853
]
4954
},
5055
plugins: [
5156
new webpack.optimize.OccurrenceOrderPlugin(),
52-
new webpack.NoErrorsPlugin(),
57+
new webpack.NoEmitOnErrorsPlugin(),
58+
FailPlugin,
5359
new HtmlWebpackPlugin({
54-
template: conf.path.src('demo/index.html'),
55-
inject: true
60+
template: conf.path.src('demo/index.html') // ,
61+
// inject: true
62+
}),
63+
new webpack.LoaderOptionsPlugin({
64+
options: {
65+
postcss: () => [autoprefixer],
66+
resolve: {},
67+
ts: {
68+
configFileName: 'tsconfig.json'
69+
},
70+
tslint: {
71+
configuration: require('../tslint.json')
72+
}
73+
},
74+
debug: true
5675
})
5776
],
58-
postcss: () => [autoprefixer],
59-
debug: true,
60-
devtool: 'cheap-module-eval-source-map',
77+
devtool: 'source-map',
6178
output: {
6279
path: path.join(process.cwd(), conf.paths.tmp),
6380
filename: 'index.js'
6481
},
6582
resolve: {
6683
extensions: [
67-
'',
6884
'.webpack.js',
6985
'.web.js',
7086
'.js',
7187
'.ts'
7288
]
7389
},
74-
entry: `./${conf.path.src('demo/index')}`,
75-
ts: {
76-
configFileName: 'tsconfig.json'
77-
},
78-
tslint: {
79-
configuration: require('../tslint.json')
80-
}
90+
entry: `./${conf.path.src('demo/index')}`
8191
};

0 commit comments

Comments
 (0)