Skip to content

Commit e04da91

Browse files
author
hirsch88
committed
Merge branch 'release/1.6.0'
2 parents 5e537a8 + c7e42df commit e04da91

Some content is hidden

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

58 files changed

+1224
-1528
lines changed

.env.example

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@
44
APP_NAME=express-typescript-boilerplate
55
APP_ENV=local
66
APP_HOST=http://localhost
7+
APP_URL_PREFIX=/api/v1
78
APP_PORT=3000
8-
APP_URL_PREFIX=/api
99

1010
#
1111
# LOGGING
1212
#
1313
DEBUG=app*,api*,core*
1414
LOG_LEVEL=debug
15-
LOG_ADAPTER=debug
15+
LOG_ADAPTER=winston
16+
17+
#
18+
# API Info
19+
#
20+
API_INFO_ENABLED=true
21+
API_INFO_ROUTE=/info
1622

1723
#
1824
# Swagger Documentation
@@ -21,6 +27,12 @@ SWAGGER_ENABLED=true
2127
SWAGGER_ROUTE=/docs
2228
SWAGGER_FILE=/src/api/swagger.json
2329

30+
#
31+
# Monitor
32+
#
33+
MONITOR_ENABLED=true
34+
MONITOR_ROUTE=/status
35+
2436
#
2537
# DATABASE
2638
#
@@ -42,4 +54,5 @@ DB_SEEDS_DIR=./src/database/seeds
4254
#
4355
# Auth0
4456
#
57+
# AUTH0_HOST=https://w3tecch.auth0.com
4558
AUTH0_HOST=http://localhost:3333

.vscode/launch.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
{
88
"type": "node",
99
"request": "launch",
10-
"name": "Launch App",
11-
"stopOnEntry": true,
12-
"program": "${workspaceRoot}/src/index.ts",
13-
"cwd": "${workspaceRoot}",
14-
"sourceMaps": true,
10+
"name": "Debug",
11+
"program": "${workspaceRoot}/dist/index.js",
12+
"smartStep": true,
13+
"outFiles": [
14+
"../dist/**/*.js"
15+
],
16+
"protocol": "inspector",
1517
"preLaunchTask": "build",
1618
"env": {
1719
"NODE_ENV": "development"

.vscode/settings.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
{
22
"typescript.tsdk": "./node_modules/typescript/lib",
3-
"files.exclude": {
4-
"src/**/*.js": false,
5-
"test/**/*.js": true
6-
},
7-
"vsicons.presets.angular": false,
83
"cSpell.enabled": true
94
}

.vscode/tasks.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,6 @@
2222
"args": [
2323
"test"
2424
]
25-
},
26-
{
27-
// "npm run lint"
28-
"taskName": "lint",
29-
"args": [
30-
"run",
31-
"lint"
32-
]
33-
},
34-
{
35-
// "npm run clean"
36-
"taskName": "clean",
37-
"args": [
38-
"run",
39-
"clean"
40-
]
4125
}
4226
]
4327
}

README.md

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
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)
1+
# Express Typescript Boilerplate
2+
[![Dependency Status](https://david-dm.org/w3tecch/express-typescript-boilerplate/status.svg?style=flat)](https://david-dm.org/w3tecch/express-typescript-boilerplate) [![Build Status](https://travis-ci.org/w3tecch/express-typescript-boilerplate.svg?branch=master)](https://travis-ci.org/w3tecch/express-typescript-boilerplate)
23

34
A delightful way to building a RESTful API with NodeJs & TypeScript.
45
- **Beautiful Syntax** thanks to the awesome annotations from [Inversify Express Utils](https://github.com/inversify/inversify-express-utils).
@@ -12,6 +13,8 @@ A delightful way to building a RESTful API with NodeJs & TypeScript.
1213
- **Custom Commands** are also available in our setup and really easy to use.
1314
- **Smart Validation** thanks to [class-validator](https://github.com/pleerock/class-validator) with some nice annotations.
1415
- **API Documentation** thanks to [swagger](http://swagger.io/).
16+
- **API Monitoring** thanks to [express-status-monitor](https://github.com/RafalWilinski/express-status-monitor).
17+
- **Integrated Testing Tool** thanks to [Wallaby.js](https://wallabyjs.com/)
1518

1619
## Getting Started
1720
### Prerequisites
@@ -20,7 +23,7 @@ A delightful way to building a RESTful API with NodeJs & TypeScript.
2023
* on Windows use [chocolatey](https://chocolatey.org/) `choco install nodejs`
2124
* Install yarn globally `npm install yarn -g`
2225

23-
## Installing
26+
### Installing
2427
* `fork` this repo
2528
* `clone` your fork
2629
* `yarn install` to install all dependencies and typings
@@ -29,12 +32,14 @@ A delightful way to building a RESTful API with NodeJs & TypeScript.
2932
* `npm run db:seed` to insert some test data
3033
* `npm run serve` to start the dev server in another tab
3134

32-
## Running the app
35+
### Running the app
3336
After you have installed all dependencies you can now run the app.
3437
Run `npm run serve` to start a local server using `nodemon` which will watch for changes and then will restart the sever.
3538
The port will be displayed to you as `http://0.0.0.0:3000` (or if you prefer IPv6, if you're using `express` server, then it's `http://[::1]:3000/`).
3639

37-
## Scripts / Commands
40+
## Scripts / Tasks
41+
All script are defined in the package.json file, but the most important ones are listed here.
42+
3843
### Install
3944
* Install all dependencies with `yarn install`
4045

@@ -51,9 +56,6 @@ The port will be displayed to you as `http://0.0.0.0:3000` (or if you prefer IPv
5156
* Run `npm run serve` to start nodemon with ts-node, which will serve your app.
5257
* The server address will be displayed to you as `http://0.0.0.0:3000`
5358

54-
### Cleaning the project
55-
* Run `npm run clean` to remove all generated JavaScript files.
56-
5759
### Building the project and run it
5860
* Run `npm run build` to generated all JavaScript files from your TypeScript sources. After this step you can deploy the app on any server.
5961
* There is also a vscode task for this called build.
@@ -68,7 +70,51 @@ The port will be displayed to you as `http://0.0.0.0:3000` (or if you prefer IPv
6870
### Console
6971
* To run your own created cli script enter `npm run console <command-name>`
7072

73+
## Using the debugger in VS Code
74+
Just set a breakpoint and hit `F5` in your Visual Studio Code.
75+
76+
## API Routes
77+
The route prefix is by default `/api/v1`, but you can change this in the .env.example file.
78+
79+
| Route | Description |
80+
| ----------- | ----------- |
81+
| **/info** | Shows us the name, description and the version of the package.json |
82+
| **/docs** | This is the Swagger UI with our API Documentation |
83+
| **/status** | Shows a small monitor app for our API |
84+
85+
## Project Structure
86+
87+
| Name | Description |
88+
| ----------------------------- | ----------- |
89+
| **.vscode/** | VSCode tasks, launch configuration and some other settings |
90+
| **build/** | Task Runner configurations and tasks |
91+
| **dist/** | Compiled source files will be placed here |
92+
| **src/** | Source-Files |
93+
| **src/api/controllers/** | REST-API - Controllers |
94+
| **src/api/exceptions/** | Exceptions like 404 NotFound |
95+
| **src/api/middlewares/** | Express Middlewares like populateUser |
96+
| **src/api/models/** | Bookshelf Models |
97+
| **src/api/repositories/** | Repository Layer |
98+
| **src/api/requests/** | Request Bodys with Validations |
99+
| **src/api/services/** | Service Layer |
100+
| **src/api/** swagger.json | Swagger Documentation |
101+
| **src/console/** | Command Line scripts |
102+
| **src/constants/** | Global Constants |
103+
| **src/core/** | All the libraries configurations and our small framework |
104+
| **src/database/factories/** | Model Factories to generate database records |
105+
| **src/database/migrations/** | Migrations scripts to build up our database schema |
106+
| **src/database/seeds/** | Seed scripts to fake some data into our database |
107+
| **src/public/** | Static assets (fonts, css, js, img). |
108+
| **src/types/** *.d.ts | Custom Type Definitions and files that aren't on DefinitelyTyped |
109+
| **test** | All our test cases |
110+
| **test/setup/** | Some setup scripts to create a needed test environment |
111+
| **test/black-box/** *.test.ts | Black-Box Testing (like e2e) |
112+
| **test/unit/** *.test.t | Unit Testing |
113+
| .env.example | All environment configurations |
114+
| knexfile.ts | This file is used for the migrations and seed task of knex |
115+
71116
## Related Projects
117+
* [Microsoft/TypeScript-Node-Starter](https://github.com/Microsoft/TypeScript-Node-Starter) - A starter template for TypeScript and Node with a detailed README describing how to use the two together.
72118
* [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
73119
* [aurelia-typescript-boilerplate](https://github.com/w3tecch/aurelia-typescript-boilerplate) - An Aurelia starter kit with TypeScript
74120
* [Auth0 Mock Server](https://github.com/hirsch88/auth0-mock-server)

build/paths.js

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

build/tasks/build.js

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

build/tasks/clean.js

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

gulpfile.js

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

package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
{
22
"name": "express-typescript-boilerplate",
3-
"version": "1.5.3",
3+
"version": "1.6.0",
44
"description": "A delightful way to building a RESTful API with NodeJs & TypeScript",
55
"main": "src/index.ts",
66
"scripts": {
7-
"lint": "./node_modules/.bin/tslint -c ./tslint.json 'src/**/*.ts' --format stylish --force",
87
"test": "NODE_ENV=test ./node_modules/.bin/jest ./test/unit",
98
"test:pretty": "NODE_ENV=test ./node_modules/.bin/jest ./test/unit --verbose",
109
"test:coverage": "NODE_ENV=test ./node_modules/.bin/jest ./test/unit --coverage",
1110
"test:black-box": "NODE_ENV=test ./node_modules/.bin/jest ./test/black-box -i",
1211
"test:black-box:pretty": "NODE_ENV=test ./node_modules/.bin/jest ./test/black-box -i --verbose",
13-
"build": "./node_modules/.bin/gulp build",
14-
"clean": "./node_modules/.bin/gulp clean",
12+
"lint": "./node_modules/.bin/tslint -c ./tslint.json -p tsconfig.json 'src/**/*.ts' --format stylish",
13+
"build": "npm run lint && npm run clean:dist && npm run transpile && npm run copy:assets",
14+
"transpile": "./node_modules/.bin/tsc",
15+
"clean:dist": "./node_modules/.bin/rimraf ./dist",
16+
"copy:assets": "npm run copy:swagger && npm run copy:public",
17+
"copy:swagger": "./node_modules/.bin/copyup ./src/api/swagger.json ./dist",
18+
"copy:public": "./node_modules/.bin/copyup ./src/public/* ./dist",
1519
"db:migrate": "./node_modules/.bin/knex migrate:latest",
1620
"db:migrate:rollback": "./node_modules/.bin/knex migrate:rollback",
1721
"db:seed": "./node_modules/.bin/knex seed:run",
1822
"db:reset": "npm run console db:reset",
1923
"console": "./node_modules/.bin/ts-node ./src/console/commander.ts",
2024
"serve": "./node_modules/.bin/nodemon --watch 'src/**/*.ts' --watch 'src/**/*.json'",
21-
"start": "node src/index.js"
25+
"start": "node dist/index.js"
2226
},
2327
"repository": "git+ssh://git@github.com/w3tec/express-typescript-boilerplate.git",
2428
"engines": {
@@ -60,7 +64,7 @@
6064
"@types/helmet": "0.0.35",
6165
"@types/jest": "^19.2.3",
6266
"@types/jsonwebtoken": "^7.2.0",
63-
"@types/knex": "0.0.50",
67+
"@types/knex": "0.0.52",
6468
"@types/lodash": "^4.14.64",
6569
"@types/morgan": "^1.7.32",
6670
"@types/reflect-metadata": "0.0.5",
@@ -74,20 +78,15 @@
7478
"class-validator": "^0.7.0",
7579
"commander": "^2.9.0",
7680
"compression": "^1.6.2",
81+
"copyfiles": "^1.2.0",
7782
"cors": "^2.8.1",
7883
"debug": "^2.6.8",
7984
"dotenv": "^4.0.0",
8085
"express": "^4.15.3",
86+
"express-status-monitor": "^0.1.9",
8187
"faker": "^4.1.0",
82-
"gulp": "^3.9.1",
83-
"gulp-clean": "^0.3.2",
84-
"gulp-load-plugins": "^1.4.0",
85-
"gulp-plumber": "^1.1.0",
86-
"gulp-sourcemaps": "^2.6.0",
87-
"gulp-tslint": "^8.0.0",
88-
"gulp-typescript": "^3.1.4",
8988
"helmet": "^3.6.1",
90-
"inversify": "^4.1.0",
89+
"inversify": "^4.1.1",
9190
"inversify-express-utils": "^3.5.1",
9291
"jest": "^20.0.3",
9392
"jsonwebtoken": "^7.4.1",
@@ -101,6 +100,7 @@
101100
"request": "^2.81.0",
102101
"request-promise": "^4.2.1",
103102
"require-dir": "^0.3.1",
103+
"rimraf": "^2.6.1",
104104
"run-sequence": "^1.2.2",
105105
"serve-favicon": "^2.4.3",
106106
"swagger-jsdoc": "^1.9.4",

0 commit comments

Comments
 (0)