Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 refactor #58

Open
wants to merge 61 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
f140a81
Add initial refactor
drewjbartlett Feb 28, 2018
47b2998
Add basic store. Add basic ts config
drewjbartlett Feb 28, 2018
c792fcb
Fix broke ts configs
drewjbartlett Feb 28, 2018
5a29e4a
Start to refactor all files into ts files
drewjbartlett Mar 1, 2018
9bdced4
WIP. Convert files to ts and setup tsconfig
drewjbartlett Mar 1, 2018
1ca76fc
Add lots of refactoring to move to ts. WIP. Not working at all right …
drewjbartlett Mar 1, 2018
a26c8cd
Continue to refactor
drewjbartlett Mar 1, 2018
2c6106d
Add a ton more refactoring. Add http adapter interface. Fix lots of e…
drewjbartlett Mar 1, 2018
141b753
Sort of add tslint setup. WIP. Refactor lots more including moving to…
drewjbartlett Mar 1, 2018
5b44724
Add tests to ts. More refactoring. WIP
drewjbartlett Mar 2, 2018
88e5c7d
Add lots more refactoring. Remove store, rename declarations. Get tes…
drewjbartlett Mar 2, 2018
dcf415c
Add a few changes to attempt to pass tests
drewjbartlett Mar 3, 2018
cecf147
Cleanup store files that are no longer needed. Fix a few tslint error…
drewjbartlett Apr 5, 2018
76f90b0
Update README to please lint gods
ctsstc Apr 10, 2018
d280e50
Generate d.ts files automatically
ctsstc Apr 10, 2018
67547d3
Auth and AuthConfig Implemented
ctsstc Apr 10, 2018
01b1c3b
Core might be implemented
ctsstc Apr 10, 2018
875ba98
Implements Custom Route
ctsstc Apr 10, 2018
96c9d92
Requests implemented
ctsstc Apr 10, 2018
0cdd4f1
Implements Url
ctsstc Apr 10, 2018
e8e904f
Debugger needs some TLC still!
ctsstc Apr 10, 2018
8ce4b44
Fix library main exports
ctsstc Apr 10, 2018
5bf36db
Quick random aesthetic and spelling
ctsstc Apr 14, 2018
f39fdd7
Merge pull request #42 from ctsstc/v2-refactor
drewjbartlett Apr 15, 2018
52e9c4c
Merge branch 'upstream' into v2-refactor
Apr 15, 2018
5163691
change to use local binaryiesinstead of depending on global node_modu…
Apr 15, 2018
97699ce
Ignore IDE config files and possibly log and cache files generated wh…
Apr 15, 2018
5e0921a
change `module.exports` to `es6 export`
Apr 15, 2018
dc03d43
Merge branch 'v2-upstream' into HEAD
Apr 16, 2018
473c314
Ignore IDE config files and possibly log and cache files generated wh…
Apr 15, 2018
9736bee
add .editorconfig to standardize code-style through out all editors
Apr 15, 2018
13e8dc3
Merge branch 'merge-v2' into v2-refactor
Apr 16, 2018
3167751
refactor(typings): rename CustomRoute Interface
mgred Apr 30, 2018
bc806f2
refactor(typings): merge auth config into config
mgred Apr 30, 2018
9803f37
refactor(typings): relocate RequestType, RequestData
mgred Apr 30, 2018
74ec10b
refactor(typings): relocate Config
mgred Apr 30, 2018
f2d02fb
refactor(typings): relocate routes.d.ts
mgred Apr 30, 2018
0615af6
refactor(typings): relocate config
mgred Apr 30, 2018
c83cc74
refactor(typings): relocate routes.d.ts
mgred Apr 30, 2018
d65e476
Merge branch 'rapid.js-41' of github.com:mgred/rapid.js into rapid.js-41
mgred Apr 30, 2018
567e10b
remove prefix path for npm scripts
May 1, 2018
2901b30
remove @babel/preset-es2015 and use @babel/preset-env instead due to …
May 1, 2018
66ca6c9
ci: set noEmit to true
mgred May 2, 2018
1b6ef34
ci: add types to package.json
mgred May 2, 2018
d46a999
ci: add dist folder
mgred May 2, 2018
1cad392
ci: compile to commonjs module
mgred May 2, 2018
a6c2964
ci: upload dist directory
mgred May 2, 2018
fe8f49e
Merge pull request #44 from yihou/v2-refactor
drewjbartlett May 9, 2018
d3aa2a8
refactor(typings): make Config members optional
mgred May 22, 2018
0d0e3dc
test(gdpr): fix the auth test to pass as example
mgred May 22, 2018
55137c5
Merge branch 'v2-refactor' into rapid.js-41
drewjbartlett May 22, 2018
cf39b70
Merge pull request #45 from mgred/rapid.js-41
drewjbartlett May 22, 2018
9d89ac3
Add v1 folder for reference
drewjbartlett May 22, 2018
ff594a7
Start actual v2 refactor
drewjbartlett Nov 27, 2019
2e2587a
Start to rewrite v2
drewjbartlett Nov 27, 2019
4af295c
start to flesh out API
drewjbartlett Nov 28, 2019
a677999
Fix gitignore
drewjbartlett Nov 28, 2019
3564d96
Remove outdated dist
drewjbartlett Nov 28, 2019
f9ec48e
Remove DS_Store
drewjbartlett Nov 28, 2019
26e1264
Remove legacy code
drewjbartlett Nov 28, 2019
b99277b
Continue adding to API
drewjbartlett Nov 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_size = 2

[{package.json}]
indent_style = space
indent_size = 2
128 changes: 97 additions & 31 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,101 @@
const restrictedGlobals = require('eslint-restricted-globals')
.filter(name => name !== 'self');

module.exports = {
'parser': 'babel-eslint',
'extends': 'airbnb-base',
'rules': {
'indent': ['error', 2],
'padded-blocks': 0,
'class-methods-use-this': ['error', { 'exceptMethods': ['boot'] }],
'no-useless-constructor': 0,
'no-param-reassign': 0,
'no-console': 0,
'no-return-assign': 0,
'prefer-rest-params': 0,
parserOptions: {
parser: '@typescript-eslint/parser',
sourceType: 'module',
ecmaVersion: 2018,
},
extends: [
'airbnb-base',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
globals: {
chrome: true,
it: true,
xit: true,
describe: true,
beforeAll: true,
beforeEach: true,
afterEach: true,
afterAll: true,
before: true,
after: true,
chai: true,
sinon: true,
expect: true,
jest: true,
test: true,
cy: true,
Cypress: true,
},
env: {
browser: true,
node: true,
},
rules: {
'arrow-parens': ['error', 'as-needed'],
'class-methods-use-this': 0,
'comma-dangle': ['error', 'always-multiline'],
'curly': ['error', 'all'],
'consistent-return': 0,
'space-before-function-paren': 0,
'valid-jsdoc': ['error', {
'prefer': { 'return': 'return' },
'preferType': { 'Boolean': 'Boolean', 'Number': 'Number', 'object': 'Object', 'String': 'String' },
'requireReturn': false,
'requireParamDescription': false,
'requireReturnDescription': false
}]
'dot-notation': [2, { allowPattern: '^[a-z]+(_[a-z]+)+$' }],
'func-names':2,
'function-paren-newline': 0,
'func-style': [ 'error', 'declaration', { 'allowArrowFunctions': false } ],
'global-require': 0,
'import/extensions': 0,
'import/export': 0,
'import/named': 2,
'import/no-default-export': 0,
'import/no-extraneous-dependencies': 0,
'import/no-unresolved': 0,
'import/prefer-default-export': 0,
'import/order': 2,
'implicit-arrow-linebreak': 0,
'linebreak-style': process.env.NODE_ENV !== 'production' ? 'off' : ['error', 'unix'],
'max-len': ['error', {
code: 150,
ignoreUrls: true,
ignoreStrings: true,
ignoreComments: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
ignorePattern: '<p>|<p|<span>|<small>'
}],
'max-params': ['error', 3],
'no-console': 2,
'no-debugger': 1,
'no-nested-ternary': 0,
'no-plusplus': 0,
'no-mixed-operators': 0,
'no-param-reassign': ['error', { props: false }],
'no-use-before-define': 0,
'no-restricted-syntax': ['error', 'WithStatement'],
'no-return-assign': 0,
'no-restricted-globals': ['error'].concat(restrictedGlobals),
'operator-linebreak': [2, 'after', { 'overrides': { '?': 'before', ':': 'before' } }],
'object-curly-newline': 0,
'operator-linebreak': 0,
'prefer-destructuring': 0,
'require-jsdoc': 0,
'space-before-function-paren': ['error', 'never'],
'spaced-comment': 0,
'sort-keys': 0,
'@typescript-eslint/camelcase': 0,
'@typescript-eslint/indent': 0,
'@typescript-eslint/array-type': ['error', 'array'],
'@typescript-eslint/interface-name': [true, 'never'],
'@typescript-eslint/no-angle-bracket-type-assertion': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-namespace': 0,
'@typescript-eslint/no-object-literal-type-assertion': 0,
'@typescript-eslint/no-unused-vars': ['error'],
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/explicit-function-return-type': 0,
'valid-jsdoc': 0,
},
'globals': {
'it': true,
'describe': true,
'beforeAll': true,
'beforeEach': true,
'afterEach': true,
'afterAll': true,
'before': true,
'after': true,
'expect': true,
'jest': true
}
};
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,33 @@
/node_modules
.nyc_output
npm-debug.log
# reference: https://github.com/github/gitignore/blob/master/Node.gitignore

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# IDEs config files
.vscode/
.idea/

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Yarn Integrity file
.yarn-integrity

# Others
demo/node_modules
/demo

legacy
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

{
"printWidth": 120,
"trailingComma": "all",
"singleQuote": true
}
36 changes: 26 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,36 @@
[![npm](https://img.shields.io/npm/dt/rapid.js.svg?style=flat-square)](https://www.npmjs.com/package/rapid.js)
[![npm](https://img.shields.io/travis/rapidjs/rapid.js.svg?branch=master&style=flat-square)](https://www.npmjs.com/package/rapid.js)

##### An ORM-like Interface and a Router For Your API Requests
###### Create simple, reusable, and cleaner wrappers, define custom routes, and more for your API requests.
# r**api**d.js

An ORM-like Interface and a Router For Your API Requests

Create simple, reusable, and cleaner wrappers, define custom routes, and more for your API requests.

## Documentation

Read the official docs at [https://rapidjs.io](https://rapidjs.io).

## Installation

Pick your poison:

```
```shell
yarn add rapid.js
npm i -S rapid.js
npm install --save rapid.js
```

## Overview
- [Define Simple Models](#define-simple-models)
- [Easily Customize Your API Requests](#easily-customize-your-api-requests)
- [Create Reusable Base Models](#create-reusable-base-models)
- [Write API Wrappers For Your Endpoints](#write-api-wrappers-for-your-endpoints)
- [Define Custom Routes (New!)](#define-custom-routes)

- [Define Simple Models](#define-simple-models)
- [Easily Customize Your API Requests](#easily-customize-your-api-requests)
- [Create Reusable Base Models](#create-reusable-base-models)
- [Write API Wrappers For Your Endpoints](#write-api-wrappers-for-your-endpoints)
- [Define Custom Routes (New!)](#define-custom-routes)

### Define Simple Models

```js
const post = new Rapid({ modelName: 'Post' });

Expand All @@ -51,11 +58,13 @@ post.destroy(9)
// POST => /api/posts/9/destroy

post.restore(9)
// POST => /api/posts/9/restore
// POST => /api/posts/9/restore
```

Read more about [Rapid Basics](https://rapidjs.io/docs#usage).

### Easily Customize Your API Requests

```js
const post = new Rapid({
modelName: 'Post',
Expand All @@ -75,9 +84,11 @@ post.update(25, { title: 'Rapid JS Is Awesome!' })
post.destroy(9)
// DELETE => /api/posts/9/
```

Read more about [Customizing Your Requests](https://rapidjs.io/docs#config-builder).

### Create Reusable Base Models

```js
class Base extends Rapid {
boot () {
Expand All @@ -99,9 +110,11 @@ tag.collection.findBy('color', 'red')
gallery.id(23).get('tags', 'nature')
// GET => https://myapp.com/api/gallery/23/tag/nature?key=MY_API_KEY
```

Read more about [Base Models](https://rapidjs.io/docs#extending-base-models).

### Write API Wrappers For Your Endpoints

```js
class GalleryWrapper extends Rapid {
boot () {
Expand All @@ -125,7 +138,8 @@ const gallery = new GalleryWrapper({
gallery.tagSearch('nature').json().get().then(...);
// GET https://myapp.com/gallery/api/tagsearch/json?query=nature&key=MY_API_KEY
// GET https://myapp.com/gallery/api/tagsearch/json?query=nature&key=MY_API_KEY
```
```

Read more about [Making a Wrapper](https://rapidjs.io/docs#extending-making-a-wrapper).

### Define Custom Routes
Expand Down Expand Up @@ -155,6 +169,7 @@ router.route('web_save_user_preferences', { id: 12 }, /* { request data } */).th
```

#### Using Your Own HTTP Service

```js
import http from 'some-http-service';

Expand All @@ -178,6 +193,7 @@ rapid.generate('web_login')
// use your own service
http.post(rapid.generate('api_save_user_preferences', { id: 1 }), { data }).then()...
```

Read more about [Custom Routes](https://rapidjs.io/docs#custom-routes).

Read the official docs at [https://rapidjs.io](https://rapidjs.io).
91 changes: 0 additions & 91 deletions dist/auth.js

This file was deleted.

Loading