Skip to content

Commit 6f7163f

Browse files
author
hirsch88
committed
house cleaning
1 parent 3a10988 commit 6f7163f

File tree

18 files changed

+178
-367
lines changed

18 files changed

+178
-367
lines changed

.gitignore

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
# Node files #
99
node_modules/
10-
bower_components/
1110
npm-debug.log
1211
yarn-error.log
1312
.env
@@ -21,14 +20,6 @@ typings/
2120

2221
# Dist #
2322
dist/
24-
releases/
25-
26-
# Cordova #
27-
cordova/plugins/
28-
cordova/platforms/
29-
www/
30-
plugins/
31-
platforms/
3223

3324
# IDE #
3425
.idea/
@@ -39,7 +30,3 @@ platforms/
3930
src/**/*.js
4031
test/**/*.js
4132
coverage/
42-
43-
# Generated documentation #
44-
docs/
45-
old/

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ language: node_js
22
node_js:
33
- "7.7.3"
44
install:
5-
- npm run install:dev
5+
- npm run install
66
scripts:
77
- npm test
88
notifications:

README.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Express Typescript Boilerplate
22

3-
> Boilerplate for an restful express-application written in TypeScript
3+
Delightful building a RESTful API in TypeScript.
4+
- *Beautiful Syntax* thanks to the awesome annotations from [Inversify Express Utils](https://github.com/inversify/inversify-express-utils).
5+
- *Easy API Testing* with included black-box testing.
6+
- *Dependency Injection* done with the nice framework from [Inversify](http://inversify.io/).
7+
- *Fast Database Building* with simple migration and seeding from [Knex](http://knexjs.org/).
8+
- *Simplified Database Query* with the ORM of [Knex](http://knexjs.org/) called [Bookshelf](http://bookshelfjs.org/).
9+
- *Clear Structure* with controllers, services, repositories, models, middlewares...
10+
- *Easy Exception Handling* with our own simple classes. You will see.
11+
- *Easy Data Seeding* with our own factories.
12+
- *Custom Commands* are also available in our setup and really easy to use.
13+
- *Smart Validation* thanks to [class-validator](https://github.com/pleerock/class-validator) with some nice annotations.
414

515
## Getting Started
616
### Prerequisites
@@ -12,8 +22,8 @@
1222
## Installing
1323
* `fork` this repo
1424
* `clone` your fork
15-
* `install:dev` to install all dependencies and typings
16-
* Create new database. You will find the name in the `src/config.ts` file.
25+
* `yarn install` to install all dependencies and typings
26+
* Create new database. You will find the name in the .env files.
1727
* `npm run db:migrate` to create the schema
1828
* `npm run db:seed` to insert some test data
1929
* `npm run serve` to start the dev server in another tab
@@ -26,16 +36,14 @@ The port will be displayed to you as `http://0.0.0.0:3000` (or if you prefer IPv
2636
## Scripts / Commands
2737
### Install
2838
* Install all dependencies with `yarn install`
29-
* Install all typings with `npm run install:typings`
30-
* To install all dependencies and typings use `npm run install:dev`
31-
* Remove not needed libraries with `npm run install:clean`
3239

3340
### Linting
3441
* Run code analysis using `npm run lint`. This runs tslint.
3542
* There is also a vscode task for this called lint.
3643

3744
### Tests
3845
* Run the unit tests using `npm test`.
46+
* Run the black-box tests using `npm run test:black-box`.
3947
* There is also a vscode task for this called test.
4048

4149
### Running in dev mode
@@ -50,12 +58,14 @@ The port will be displayed to you as `http://0.0.0.0:3000` (or if you prefer IPv
5058
* There is also a vscode task for this called build.
5159
* To start the builded app use `npm start`.
5260

53-
### Seed
54-
* Run `npm run db:seed` to seed some data into the database
55-
56-
### Migration
61+
### Database
5762
* Run `npm run db:migrate` to migration the new schema to the database
5863
* Run `npm run db:migrate:rollback` to rollback one version
64+
* Run `npm run db:seed` to seed some data into the database
65+
* Run `npm run db:reset` to clean the database and migrate again
66+
67+
### Console
68+
* To run your own created cli script enter `npm run console <command-name>`
5969

6070
## Related Projects
6171
* [express-graphql-typescript-boilerplate](https://github.com/w3tecch/express-graphql-typescript-boilerplate) - A starter kit for building amazing GraphQL API's with TypeScript and express by @w3tecch
@@ -68,6 +78,8 @@ The port will be displayed to you as `http://0.0.0.0:3000` (or if you prefer IPv
6878
* [Bookshelf Cheatsheet](http://ricostacruz.com/cheatsheets/bookshelf.html)
6979
* [Inversify](http://inversify.io/)
7080
* [Inversify Express Utils](https://github.com/inversify/inversify-express-utils)
81+
* [class-validator](https://github.com/pleerock/class-validator)
82+
* [Jest](http://facebook.github.io/jest/)
7183
* [Auth0 API Documentation](https://auth0.com/docs/api/management/v2#!/Users/get_users)
7284

7385
## License

build/paths.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ module.exports = {
88
main: 'index.ts',
99
src: 'src',
1010
test: 'test',
11-
docs: 'docs',
1211
dist: 'dist'
1312
};

build/tasks/build.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ function transpiler(filePath, isTest, files) {
4545
let tsProject = !!isTest ? tsProjectTest : tsProjectSource;
4646
return gulp
4747
.src([
48-
'./typings/index.d.ts',
49-
'./typings_custom/**/*.d.ts',
48+
'./typings/*.d.ts',
5049
path.join(filePath, files)
5150
])
5251
.pipe($.plumber({ errorHandler: $.notify.onError('Error: <%= error.message %>') }))

build/tasks/clean.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const $ = require('gulp-load-plugins')({
99
});
1010

1111
gulp.task('clean', [
12-
'clean:docs',
1312
'clean:build'
1413
]);
1514

@@ -20,7 +19,6 @@ gulp.task('clean:build', [
2019
'clean:test:map'
2120
]);
2221

23-
gulp.task('clean:docs', () => cleaner(paths.docs));
2422
gulp.task('clean:src:src', () => cleaner(paths.src, 'js'));
2523
gulp.task('clean:src:map', () => cleaner(paths.src, 'map'));
2624
gulp.task('clean:test:src', () => cleaner(paths.test, 'js'));

build/tasks/lint.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ function lint(files) {
2323

2424
gulp.task('lint', () => lint([
2525
'./typings/index.d.ts',
26-
'./typings_custom/**/*.d.ts',
2726
path.join(paths.src, '/**/*.ts'),
2827
path.join(paths.test, '/**/*.ts')
2928
]));

build/util.js

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,16 @@
11
'use strict';
22

3-
const gulp = require('gulp'),
4-
path = require('path'),
5-
paths = require('./paths'),
6-
$ = require('gulp-load-plugins')({
7-
lazy: true
8-
});
3+
const gulp = require('gulp');
4+
const notifier = require('node-notifier');
95

106
var util = {
11-
notify: notify,
12-
getPkg: getPkg,
13-
getJs: getJs,
14-
buildConfig: buildConfig
7+
notify: function notify(title, message) {
8+
notifier.notify({
9+
'title': title || 'Gulp',
10+
'message': message || 'Please check your log or open your browser.',
11+
icon: process.cwd() + '/icon.png'
12+
});
13+
}
1514
};
1615

1716
module.exports = util;
18-
19-
function getPkg() {
20-
return require(path.join(process.cwd(), 'package.json'));
21-
}
22-
23-
function notify(title, message) {
24-
var notifier = require('node-notifier');
25-
notifier.notify({
26-
'title': title || 'Gulp',
27-
'message': message || 'Please check your log or open your browser.',
28-
icon: process.cwd() + '/icon.png'
29-
});
30-
}
31-
32-
function getJs(filename) {
33-
return filename.replace('.ts', '.js');
34-
}
35-
36-
function buildConfig(target) {
37-
var env = $.util.env.environment || $.util.env.env || 'dev';
38-
var configBase = './config';
39-
var options = getPkg();
40-
options.env = env;
41-
return gulp
42-
.src(path.join(configBase, env + '.json'))
43-
.pipe($.rename('config.json'))
44-
.pipe($.template(options))
45-
.pipe(gulp.dest(target));
46-
}

knexfile.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
require('dotenv').config();
22

3+
/**
4+
* This is the database configuration for the migrations and
5+
* the seeders.
6+
*/
37
module.exports = {
48
client: process.env.DB_CLIENT,
59
connection: process.env.DB_CONNECTION,

package.json

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,17 @@
44
"description": "Boilerplate for an restful express-application written in TypeScript.",
55
"main": "src/index.ts",
66
"scripts": {
7-
"install:typings": "./node_modules/.bin/typings install",
8-
"install:dev": "yarn install && npm run install:typings",
9-
"install:clean": "npm prune && ./node_modules/.bin/typings prune",
10-
"serve": "./node_modules/.bin/nodemon --watch 'src/**/*.ts'",
11-
"serve:debug": "npm run serve -- --debug=6666",
127
"lint": "./node_modules/.bin/gulp lint",
138
"test": "NODE_ENV=test ./node_modules/.bin/jest ./test/unit --verbose --coverage",
149
"test:black-box": "NODE_ENV=test ./node_modules/.bin/jest ./test/black-box -i --verbose",
1510
"build": "./node_modules/.bin/gulp build",
1611
"clean": "./node_modules/.bin/gulp clean",
17-
"zip": "./node_modules/.bin/gulp zip",
1812
"db:migrate": "./node_modules/.bin/knex migrate:latest",
1913
"db:migrate:rollback": "./node_modules/.bin/knex migrate:rollback",
2014
"db:seed": "./node_modules/.bin/knex seed:run",
2115
"db:reset": "npm run console db:reset",
2216
"console": "./node_modules/.bin/ts-node ./src/console/commander.ts",
17+
"serve": "./node_modules/.bin/nodemon --watch 'src/**/*.ts'",
2318
"start": "node src/index.js"
2419
},
2520
"repository": "git+ssh://git@github.com/w3tec/express-typescript-boilerplate.git",
@@ -82,41 +77,32 @@
8277
"faker": "^4.1.0",
8378
"gulp": "^3.9.1",
8479
"gulp-clean": "^0.3.2",
85-
"gulp-concat": "^2.6.1",
86-
"gulp-copy": "^1.0.0",
87-
"gulp-filter": "^5.0.0",
88-
"gulp-json-editor": "^2.2.1",
8980
"gulp-load-plugins": "^1.4.0",
9081
"gulp-notify": "^3.0.0",
9182
"gulp-plumber": "^1.1.0",
92-
"gulp-rename": "^1.2.2",
9383
"gulp-sourcemaps": "^2.6.0",
9484
"gulp-tslint": "^8.0.0",
9585
"gulp-typescript": "^3.1.4",
96-
"gulp-zip": "^4.0.0",
9786
"helmet": "^3.6.0",
9887
"inversify": "^4.1.0",
9988
"inversify-express-utils": "^3.5.1",
10089
"jest": "^20.0.3",
101-
"knex": "^0.13.0",
90+
"knex": "^0.12.0",
10291
"lodash": "^4.17.4",
10392
"morgan": "^1.7.0",
10493
"mysql": "^2.13.0",
10594
"nodemon": "^1.11.0",
10695
"path": "^0.12.7",
107-
"pg": "^6.1.5",
10896
"reflect-metadata": "^0.1.10",
10997
"request": "^2.81.0",
11098
"request-promise": "^4.2.1",
11199
"require-dir": "^0.3.1",
112100
"run-sequence": "^1.2.2",
113101
"serve-favicon": "^2.4.3",
114-
"sqlite3": "^3.1.8",
115102
"ts-jest": "^20.0.4",
116103
"ts-node": "^3.0.4",
117104
"tslint": "^5.2.0",
118105
"typescript": "^2.3.2",
119-
"typings": "^2.1.0",
120106
"winston": "^2.3.1"
121107
},
122108
"jest": {

0 commit comments

Comments
 (0)