Skip to content

Commit c1852d9

Browse files
author
hirsch88
committed
Merge branch 'release/1.3.0'
2 parents aa3b700 + d5da4d7 commit c1852d9

38 files changed

+1187
-1355
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+
- yarn install
66
scripts:
77
- npm test
88
notifications:

README.md

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
# Express Typescript Boilerplate
2-
3-
> Boilerplate for an restful express-application written in TypeScript
1+
# Express Typescript Boilerplate [![Build Status](https://travis-ci.org/w3tecch/express-typescript-boilerplate.svg?branch=master)](https://travis-ci.org/w3tecch/express-typescript-boilerplate)
2+
3+
A delightful way to building a RESTful API with NodeJs & 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
@@ -44,19 +52,20 @@ The port will be displayed to you as `http://0.0.0.0:3000` (or if you prefer IPv
4452

4553
### Cleaning the project
4654
* Run `npm run clean` to remove all generated JavaScript files.
47-
* Run `npm run db:clean` to drop all tables of the database.
4855

4956
### Building the project and run it
5057
* Run `npm run build` to generated all JavaScript files from your TypeScript sources. After this step you can deploy the app on any server.
5158
* There is also a vscode task for this called build.
5259
* To start the builded app use `npm start`.
5360

54-
### Seed
55-
* Run `npm run db:seed` to seed some data into the database
56-
57-
### Migration
61+
### Database
5862
* Run `npm run db:migrate` to migration the new schema to the database
5963
* 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>`
6069

6170
## Related Projects
6271
* [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
@@ -69,6 +78,8 @@ The port will be displayed to you as `http://0.0.0.0:3000` (or if you prefer IPv
6978
* [Bookshelf Cheatsheet](http://ricostacruz.com/cheatsheets/bookshelf.html)
7079
* [Inversify](http://inversify.io/)
7180
* [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/)
7283
* [Auth0 API Documentation](https://auth0.com/docs/api/management/v2#!/Users/get_users)
7384

7485
## 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/docs.js

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

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,

0 commit comments

Comments
 (0)