Skip to content

Commit 069cc48

Browse files
authored
Replace ghooks, Add tests, license and support (#300)
* Replacing deprecated ghooks with husky for pre-commit hooks * Develop license and support (#298) * Add JWT test (#299) * Use del.sync instead of del (#301)
1 parent 1cf75a7 commit 069cc48

File tree

6 files changed

+55
-84
lines changed

6 files changed

+55
-84
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Kunal Kapadia
3+
Copyright (c) 2016-2017 Kunal Kapadia
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)
99
[![MIT License](https://img.shields.io/npm/l/stack-overflow-copy-paste.svg?style=flat-square)](http://opensource.org/licenses/MIT)
1010
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
11+
[![Support via Paypal](https://img.shields.io/badge/support-paypal-yellowgreen.svg?style=flat-square)](https://www.paypal.me/KunalKapadia)
1112

1213
# [![Express ES6 REST API Starter](https://cloud.githubusercontent.com/assets/4172932/12660610/90f5b856-c63a-11e5-878e-c9f0bbf33090.jpg)](https://github.com/KunalKapadia/express-mongoose-es6-rest-api)
1314

@@ -149,6 +150,14 @@ If you would prefer not to use any of our tooling, delete the following files fr
149150

150151
Contributions, questions and comments are all welcome and encouraged. For code contributions submit a pull request with unit test.
151152

153+
## License
154+
This project is licensed under the [MIT License](https://github.com/KunalKapadia/express-mongoose-es6-rest-api/blob/master/LICENSE)
155+
156+
## Support Development
157+
If this project saved your valuable time in getting your service up, and you feel like buying me coffee, you can donate either at my BTC address: `1LkW5UoERR1jjJsChMheKuo6vn95x2mzWg` or at [![Support via Paypal](https://img.shields.io/badge/support-paypal-yellowgreen.svg?style=flat-square)](https://www.paypal.me/KunalKapadia)
158+
159+
Your support is greatly appreciated.
160+
152161
## Meta
153162

154163
Kunal Kapadia – [@kunalkapadia12](https://twitter.com/KunalKapadia12)kunalkapadia12@gmail.com

gulpfile.babel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const paths = {
1414

1515
// Clean up dist and coverage directory
1616
gulp.task('clean', () =>
17-
del(['dist/**', 'coverage/**', '!dist', '!coverage'])
17+
del.sync(['dist/**', 'coverage/**', '!dist', '!coverage'])
1818
);
1919

2020
// Copy non-js files to dist

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"build": "gulp",
1717
"lint": "esw *.js server config --color",
1818
"lint:watch": "yarn lint -- --watch",
19+
"precommit": "yarn lint && yarn test",
1920
"test": "cross-env NODE_ENV=test ./node_modules/.bin/mocha --ui bdd --reporter spec --colors --compilers js:babel-core/register ./server/**/*.test.js",
2021
"test:watch": "yarn test -- --watch",
2122
"test:coverage": "cross-env NODE_ENV=test ./node_modules/.bin/istanbul cover _mocha -- --ui bdd --reporter spec --colors --compilers js:babel-core/register ./server/**/*.test.js",
@@ -75,14 +76,14 @@
7576
"eslint-config-airbnb-base": "7.1.0",
7677
"eslint-plugin-import": "1.16.0",
7778
"eslint-watch": "2.1.14",
78-
"ghooks": "^1.2.4",
7979
"gulp": "3.9.1",
8080
"gulp-babel": "6.1.2",
8181
"gulp-load-plugins": "^1.2.0",
8282
"gulp-newer": "^1.1.0",
8383
"gulp-nodemon": "^2.0.6",
8484
"gulp-sourcemaps": "^1.6.0",
8585
"gulp-util": "^3.0.7",
86+
"husky": "^0.13.1",
8687
"istanbul": "1.1.0-alpha.1",
8788
"mocha": "3.2.0",
8889
"run-sequence": "^1.1.5",
@@ -92,9 +93,6 @@
9293
},
9394
"license": "MIT",
9495
"config": {
95-
"ghooks": {
96-
"pre-commit": "yarn lint && yarn test"
97-
},
9896
"commitizen": {
9997
"path": "./node_modules/cz-conventional-changelog"
10098
}

server/tests/auth.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ describe('## Auth APIs', () => {
6363
.catch(done);
6464
});
6565

66+
it('should fail to get random number because of wrong token', (done) => {
67+
request(app)
68+
.get('/api/auth/random-number')
69+
.set('Authorization', 'Bearer inValidToken')
70+
.expect(httpStatus.UNAUTHORIZED)
71+
.then((res) => {
72+
expect(res.body.message).to.equal('Unauthorized');
73+
done();
74+
})
75+
.catch(done);
76+
});
77+
6678
it('should get a random number', (done) => {
6779
request(app)
6880
.get('/api/auth/random-number')

yarn.lock

Lines changed: 30 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,10 @@ chokidar@^1.0.0, chokidar@^1.4.3:
978978
optionalDependencies:
979979
fsevents "^1.0.0"
980980

981+
ci-info@^1.0.0:
982+
version "1.0.0"
983+
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.0.0.tgz#dc5285f2b4e251821683681c381c3388f46ec534"
984+
981985
circular-json@^0.3.1:
982986
version "0.3.1"
983987
resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.1.tgz#be8b36aefccde8b3ca7aa2d6afc07a37242c0d2d"
@@ -1198,13 +1202,6 @@ cross-env@3.1.3:
11981202
dependencies:
11991203
cross-spawn "^3.0.1"
12001204

1201-
cross-spawn-async@^2.1.1:
1202-
version "2.2.5"
1203-
resolved "https://registry.yarnpkg.com/cross-spawn-async/-/cross-spawn-async-2.2.5.tgz#845ff0c0834a3ded9d160daca6d390906bb288cc"
1204-
dependencies:
1205-
lru-cache "^4.0.0"
1206-
which "^1.2.8"
1207-
12081205
cross-spawn@^3.0.1:
12091206
version "3.0.1"
12101207
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-3.0.1.tgz#1256037ecb9f0c5f79e3d6ef135e30770184b982"
@@ -1662,17 +1659,6 @@ event-stream@^3.2.1, event-stream@~3.3.0:
16621659
stream-combiner "~0.0.4"
16631660
through "~2.3.1"
16641661

1665-
execa@^0.4.0:
1666-
version "0.4.0"
1667-
resolved "https://registry.yarnpkg.com/execa/-/execa-0.4.0.tgz#4eb6467a36a095fabb2970ff9d5e3fb7bce6ebc3"
1668-
dependencies:
1669-
cross-spawn-async "^2.1.1"
1670-
is-stream "^1.1.0"
1671-
npm-run-path "^1.0.0"
1672-
object-assign "^4.0.1"
1673-
path-key "^1.0.0"
1674-
strip-eof "^1.0.0"
1675-
16761662
exit-hook@^1.0.0:
16771663
version "1.1.1"
16781664
resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8"
@@ -1854,6 +1840,10 @@ find-node-modules@1.0.4:
18541840
findup-sync "0.4.2"
18551841
merge "^1.2.0"
18561842

1843+
find-parent-dir@^0.3.0:
1844+
version "0.3.0"
1845+
resolved "https://registry.yarnpkg.com/find-parent-dir/-/find-parent-dir-0.3.0.tgz#33c44b429ab2b2f0646299c5f9f718f376ff8d54"
1846+
18571847
find-root@1.0.0:
18581848
version "1.0.0"
18591849
resolved "https://registry.yarnpkg.com/find-root/-/find-root-1.0.0.tgz#962ff211aab25c6520feeeb8d6287f8f6e95807a"
@@ -2061,18 +2051,6 @@ getpass@^0.1.1:
20612051
dependencies:
20622052
assert-plus "^1.0.0"
20632053

2064-
ghooks@^1.2.4:
2065-
version "1.3.2"
2066-
resolved "https://registry.yarnpkg.com/ghooks/-/ghooks-1.3.2.tgz#bee29deec4283e23eb1ff37d94a8120acd4332e9"
2067-
dependencies:
2068-
execa "^0.4.0"
2069-
findup "0.1.5"
2070-
lodash.clone "4.3.2"
2071-
manage-path "2.0.0"
2072-
opt-cli "1.5.1"
2073-
path-exists "^2.0.0"
2074-
spawn-command "0.0.2"
2075-
20762054
glob-base@^0.3.0:
20772055
version "0.3.0"
20782056
resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4"
@@ -2486,6 +2464,15 @@ http-status@^0.2.0:
24862464
version "0.2.5"
24872465
resolved "https://registry.yarnpkg.com/http-status/-/http-status-0.2.5.tgz#976f91077ea7bfc15277cbcf8c80c4d5c51b49b0"
24882466

2467+
husky@^0.13.1:
2468+
version "0.13.1"
2469+
resolved "https://registry.yarnpkg.com/husky/-/husky-0.13.1.tgz#11efc6fc10e0ec4e789776f6582be37d71ba4ccf"
2470+
dependencies:
2471+
chalk "^1.1.3"
2472+
find-parent-dir "^0.3.0"
2473+
is-ci "^1.0.9"
2474+
normalize-path "^1.0.0"
2475+
24892476
iconv-lite@0.4.13:
24902477
version "0.4.13"
24912478
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2"
@@ -2597,6 +2584,12 @@ is-buffer@^1.0.2:
25972584
version "1.1.4"
25982585
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.4.tgz#cfc86ccd5dc5a52fa80489111c6920c457e2d98b"
25992586

2587+
is-ci@^1.0.9:
2588+
version "1.0.10"
2589+
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.0.10.tgz#f739336b2632365061a9d48270cd56ae3369318e"
2590+
dependencies:
2591+
ci-info "^1.0.0"
2592+
26002593
is-dotfile@^1.0.0:
26012594
version "1.0.2"
26022595
resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.2.tgz#2c132383f39199f8edc268ca01b9b007d205cc4d"
@@ -2704,7 +2697,7 @@ is-resolvable@^1.0.0:
27042697
dependencies:
27052698
tryit "^1.0.1"
27062699

2707-
is-stream@^1.0.0, is-stream@^1.1.0:
2700+
is-stream@^1.0.0:
27082701
version "1.1.0"
27092702
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
27102703

@@ -3041,10 +3034,6 @@ lodash._baseassign@^3.0.0:
30413034
lodash._basecopy "^3.0.0"
30423035
lodash.keys "^3.0.0"
30433036

3044-
lodash._baseclone@~4.5.0:
3045-
version "4.5.7"
3046-
resolved "https://registry.yarnpkg.com/lodash._baseclone/-/lodash._baseclone-4.5.7.tgz#ce42ade08384ef5d62fa77c30f61a46e686f8434"
3047-
30483037
lodash._basecopy@^3.0.0:
30493038
version "3.0.1"
30503039
resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36"
@@ -3109,12 +3098,6 @@ lodash.assignwith@^4.0.7:
31093098
version "4.2.0"
31103099
resolved "https://registry.yarnpkg.com/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz#127a97f02adc41751a954d24b0de17e100e038eb"
31113100

3112-
lodash.clone@4.3.2:
3113-
version "4.3.2"
3114-
resolved "https://registry.yarnpkg.com/lodash.clone/-/lodash.clone-4.3.2.tgz#e56b176b6823a7dde38f7f2bf58de7d5971200e9"
3115-
dependencies:
3116-
lodash._baseclone "~4.5.0"
3117-
31183101
lodash.cond@^4.3.0:
31193102
version "4.5.2"
31203103
resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5"
@@ -3267,17 +3250,13 @@ lru-cache@2:
32673250
version "2.7.3"
32683251
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952"
32693252

3270-
lru-cache@^4.0.0, lru-cache@^4.0.1:
3253+
lru-cache@^4.0.1:
32713254
version "4.0.2"
32723255
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.0.2.tgz#1d17679c069cda5d040991a09dbc2c0db377e55e"
32733256
dependencies:
32743257
pseudomap "^1.0.1"
32753258
yallist "^2.0.0"
32763259

3277-
manage-path@2.0.0:
3278-
version "2.0.0"
3279-
resolved "https://registry.yarnpkg.com/manage-path/-/manage-path-2.0.0.tgz#f4cf8457b926eeee2a83b173501414bc76eb9597"
3280-
32813260
map-cache@^0.2.0:
32823261
version "0.2.2"
32833262
resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf"
@@ -3552,16 +3531,14 @@ nopt@~1.0.10:
35523531
dependencies:
35533532
abbrev "1"
35543533

3534+
normalize-path@^1.0.0:
3535+
version "1.0.0"
3536+
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-1.0.0.tgz#32d0e472f91ff345701c15a8311018d3b0a90379"
3537+
35553538
normalize-path@^2.0.1:
35563539
version "2.0.1"
35573540
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.0.1.tgz#47886ac1662760d4261b7d979d241709d3ce3f7a"
35583541

3559-
npm-run-path@^1.0.0:
3560-
version "1.0.0"
3561-
resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-1.0.0.tgz#f5c32bf595fe81ae927daec52e82f8b000ac3c8f"
3562-
dependencies:
3563-
path-key "^1.0.0"
3564-
35653542
npmlog@^4.0.1:
35663543
version "4.0.2"
35673544
resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.0.2.tgz#d03950e0e78ce1527ba26d2a7592e9348ac3e75f"
@@ -3624,15 +3601,6 @@ onetime@^1.0.0:
36243601
version "1.1.0"
36253602
resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789"
36263603

3627-
opt-cli@1.5.1:
3628-
version "1.5.1"
3629-
resolved "https://registry.yarnpkg.com/opt-cli/-/opt-cli-1.5.1.tgz#04db447b13c96b992eb31685266f4ed0d9736dc2"
3630-
dependencies:
3631-
commander "2.9.0"
3632-
lodash.clone "4.3.2"
3633-
manage-path "2.0.0"
3634-
spawn-command "0.0.2-1"
3635-
36363604
optimist@^0.6.1:
36373605
version "0.6.1"
36383606
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
@@ -3742,10 +3710,6 @@ path-is-inside@^1.0.1:
37423710
version "1.0.2"
37433711
resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"
37443712

3745-
path-key@^1.0.0:
3746-
version "1.0.0"
3747-
resolved "https://registry.yarnpkg.com/path-key/-/path-key-1.0.0.tgz#5d53d578019646c0d68800db4e146e6bdc2ac7af"
3748-
37493713
path-parse@^1.0.5:
37503714
version "1.0.5"
37513715
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"
@@ -4335,14 +4299,6 @@ sparkles@^1.0.0:
43354299
version "1.0.0"
43364300
resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3"
43374301

4338-
spawn-command@0.0.2:
4339-
version "0.0.2"
4340-
resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2.tgz#9544e1a43ca045f8531aac1a48cb29bdae62338e"
4341-
4342-
spawn-command@0.0.2-1:
4343-
version "0.0.2-1"
4344-
resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0"
4345-
43464302
spawn-sync@^1.0.15:
43474303
version "1.0.15"
43484304
resolved "https://registry.yarnpkg.com/spawn-sync/-/spawn-sync-1.0.15.tgz#b00799557eb7fb0c8376c29d44e8a1ea67e57476"
@@ -4453,10 +4409,6 @@ strip-bom@^3.0.0:
44534409
version "3.0.0"
44544410
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
44554411

4456-
strip-eof@^1.0.0:
4457-
version "1.0.0"
4458-
resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf"
4459-
44604412
strip-json-comments@2.0.1:
44614413
version "2.0.1"
44624414
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
@@ -4788,7 +4740,7 @@ vinyl@^0.5.0:
47884740
clone-stats "^0.0.1"
47894741
replace-ext "0.0.1"
47904742

4791-
which@^1.1.1, which@^1.2.12, which@^1.2.8, which@^1.2.9:
4743+
which@^1.1.1, which@^1.2.12, which@^1.2.9:
47924744
version "1.2.12"
47934745
resolved "https://registry.yarnpkg.com/which/-/which-1.2.12.tgz#de67b5e450269f194909ef23ece4ebe416fa1192"
47944746
dependencies:

0 commit comments

Comments
 (0)