Skip to content

Commit 80c6643

Browse files
soswowzzarcon
authored andcommitted
Feature/convert to ts (from inside) (#168)
Migrate to Typescript
1 parent 4fd2b2b commit 80c6643

50 files changed

Lines changed: 3288 additions & 2269 deletions

Some content is hidden

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

.babelrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

.eslintrc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
{
2-
"extends": "airbnb-base"
3-
}
2+
"parser": "@typescript-eslint/parser",
3+
"parserOptions": {
4+
"ecmaVersion": 2018,
5+
"sourceType": "module"
6+
},
7+
"rules": {
8+
"indent": ["error", 2],
9+
"typescript/no-explicit-any": "off",
10+
"typescript/explicit-function-return-type": "off"
11+
}
12+
}

.flowconfig

Lines changed: 0 additions & 15 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ sftp-config.json
3333
lib
3434
package-lock.json
3535
coverage
36+
.vscode
37+
/.idea
38+
/examples/**/*.js

README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ import {Database, Router, Server} from 'Kakapo';
9797

9898
const db = new Database();
9999

100-
db.register('user', () => {
100+
db.register('user', () => ({
101101
firstName: 'Hector',
102102
lastName: 'Zarco'
103-
});
103+
}));
104104
db.create('user', 10);
105105

106106
const router = new Router();
@@ -109,7 +109,7 @@ router.get('/users', (request, db) => {
109109
return db.all('user');
110110
});
111111

112-
router.get('/users/:user_id', (request, db) =>
112+
router.get('/users/:user_id', (request, db) => {
113113
const userId = request.params.user_id;
114114
return db.findOne('user', userId);
115115
});
@@ -144,7 +144,7 @@ const router = new Router();
144144

145145
router.get('/users', (request) => {
146146
const currentPage = request.query.page;
147-
const count = request.query.count;
147+
let count = request.query.count;
148148
let users = []
149149

150150
while (--count) {
@@ -205,7 +205,7 @@ import {Router, Server} from 'Kakapo';
205205

206206
const router = new Router();
207207

208-
router.get('/users/', (request) => {
208+
router.get('/users/', () => {
209209
return 'meh';
210210
});
211211

@@ -428,7 +428,7 @@ $.ajax({
428428
url: '/posts/1/comments/5?page=1&count=10',
429429
data: {text: 'Foo comment'},
430430
headers: {'X-Access-token': '12345'}
431-
)
431+
})
432432
```
433433

434434
**Options**
@@ -611,7 +611,7 @@ server.use(xhrRouter);
611611

612612
The **scenario** concept is nothing else than the ability of having different presets of Kakapo, like router, database, etc... and later, allow the user to decide when he wants to use one of other.
613613

614-
Let's say you want to check how the spinners looks in your app, in that case you probably will put a higher value as a **requestDelay**, to make sure that the requests are intercepted late and you can check the UI... other good use case might be one in which you want to test the performance of a view when you have thousands of elements, in order to achieve that you will just need to pass a hight number to the **create** method of the **Database**:
614+
Let's say you want to check how the spinners looks in your app, in that case you probably will put a higher value as a **requestDelay**, to make sure that the requests are intercepted late and you can check the UI... other good use case might be one in which you want to test the performance of a view when you have thousands of elements, in order to achieve that you will just need to pass a high number to the **create** method of the **Database**:
615615

616616
```javascript
617617
import {Server, Router, Database} from 'kakapo';
@@ -666,18 +666,14 @@ db.register('user', faker => {
666666
});
667667
```
668668

669-
# Browser support
670-
671-
Kakapo.js relies on [WeakMap](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) but we don't ship a polyfill with the library because the [current support](http://kangax.github.io/compat-table/es6/#test-WeakMap) is fine and this library should only we used for development purposes **never for production usage**, anyways you can find a [WeakMap polyfill here](https://github.com/Benvie/WeakMap).
672-
673669
# ROADMAP
674670

675-
**Full suport for JSONApiSerializer**
671+
**Full support for JSONApiSerializer**
676672

677673
**Node.js compatibility**
678674

679675
**Node.js interceptors**
680676

681677
# Authors
682678

683-
[@rpunkfu](https://github.com/rpunkfu) - [@zzarcon](https://github.com/zzarcon)
679+
[@rpunkfu](https://github.com/rpunkfu) - [@zzarcon](https://github.com/zzarcon)
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
// @flow
2-
import Faker from "faker";
3-
import {
4-
type DataFactory,
5-
} from "../../src/Database";
1+
import * as Faker from 'faker';
62

7-
export opaque type UserId = string;
3+
export type UserId = string;
84

95
export type User = {
10-
+id: UserId,
6+
id: UserId,
117
firstName: string,
128
lastName: string,
139
age: number
@@ -18,7 +14,7 @@ export const userFactory = ({
1814
firstName = Faker.name.firstName(),
1915
lastName = Faker.name.lastName(),
2016
age = Faker.random.number()
21-
}: { ...User } = {}) => ({
17+
}: Partial<User> = {} as User) => ({
2218
id,
2319
firstName,
2420
lastName,

__tests__/database_spec.js

Lines changed: 0 additions & 234 deletions
This file was deleted.

0 commit comments

Comments
 (0)