Skip to content

Commit 790f8ca

Browse files
author
hirsch88
committed
Merge branch 'release/2.0.0-beta.4'
2 parents e89f115 + 8224eb2 commit 790f8ca

File tree

14 files changed

+1614
-1085
lines changed

14 files changed

+1614
-1085
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Try it!! We are happy to hear your feedback or any kind of new features.
2727

2828
## Features
2929
- **Beautiful Syntax** thanks to the awesome annotations from [Inversify Express Utils](https://github.com/inversify/inversify-express-utils).
30-
- **Easy API Testing** with included black-box testing.
30+
- **Easy API Testing** with included e2e testing.
3131
- **Dependency Injection** done with the nice framework from [Inversify](http://inversify.io/).
3232
- **Fast Database Building** with simple migration and seeding from [Knex](http://knexjs.org/).
3333
- **Simplified Database Query** with the ORM of [Knex](http://knexjs.org/) called [Bookshelf](http://bookshelfjs.org/).
@@ -67,15 +67,15 @@ Create a new database with the name you have in your `.env`-file.
6767

6868
Then setup your application environment.
6969
```
70-
npm run setup
70+
nps setup
7171
```
7272

7373
> This installs all dependencies with yarn. After that it migrates the database and seeds some test data into it. So after that your development environment is ready to use.
7474
7575
### Step 3: Serve your App
7676
Go to the project dir and start your app with this npm script.
7777
```
78-
npm run serve
78+
nps serve
7979
```
8080

8181
> This starts a local server using `nodemon`, which will watch for any file changes and will restart the sever according to these changes.
@@ -148,26 +148,26 @@ All script are defined in the package.json file, but the most important ones are
148148
* Install all dependencies with `yarn install`
149149

150150
### Linting
151-
* Run code quality analysis using `npm run lint`. This runs tslint.
151+
* Run code quality analysis using `nps lint`. This runs tslint.
152152
* There is also a vscode task for this called `lint`.
153153

154154
### Tests
155155
* Run the unit tests using `npm test` (There is also a vscode task for this called `test`).
156-
* Run the black-box tests using `npm run test:black-box` and don't forget to start your application and your [Auth0 Mock Server](https://github.com/hirsch88/auth0-mock-server).
156+
* Run the e2e tests using `nps test:e2e` and don't forget to start your application and your [Auth0 Mock Server](https://github.com/hirsch88/auth0-mock-server).
157157

158158
### Running in dev mode
159-
* Run `npm run serve` to start nodemon with ts-node, to serve the app.
159+
* Run `nps serve` to start nodemon with ts-node, to serve the app.
160160
* The server address will be displayed to you as `http://0.0.0.0:3000`
161161

162162
### Building the project and run it
163-
* Run `npm run build` to generated all JavaScript files from the TypeScript sources (There is also a vscode task for this called `build`).
163+
* Run `nps build` to generated all JavaScript files from the TypeScript sources (There is also a vscode task for this called `build`).
164164
* To start the builded app located in `dist` use `npm start`.
165165

166166
### Database
167-
* Run `npm run db:migrate` to migrate schema changes to the database
168-
* Run `npm run db:migrate:rollback` to rollback one migration
169-
* Run `npm run db:seed` to seed sample data into the database
170-
* Run `npm run db:reset` to rollback all migrations and migrate any migration again
167+
* Run `nps db:migrate` to migrate schema changes to the database
168+
* Run `nps db:migrate:rollback` to rollback one migration
169+
* Run `nps db:seed` to seed sample data into the database
170+
* Run `nps db:reset` to rollback all migrations and migrate any migration again
171171

172172
### Console
173173
* To run your own created command enter `npm run console <command-name>`.
@@ -241,7 +241,7 @@ The route prefix is `/api` by default, but you can change this in the .env file.
241241
| **src/public/** | Static assets (fonts, css, js, img). |
242242
| **src/types/** *.d.ts | Custom type definitions and files that aren't on DefinitelyTyped |
243243
| **test** | Tests |
244-
| **test/black-box/** *.test.ts | Black-Box tests (like e2e) |
244+
| **test/e2e/** *.test.ts | End-2-End tests (like e2e) |
245245
| **test/unit/** *.test.ts | Unit tests |
246246
| .env.example | Environment configurations |
247247
| knexfile.ts | This file is used for the migrations and seed task of knex |
@@ -250,7 +250,7 @@ The route prefix is `/api` by default, but you can change this in the .env file.
250250
* [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.
251251
* [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
252252
* [aurelia-typescript-boilerplate](https://github.com/w3tecch/aurelia-typescript-boilerplate) - An Aurelia starter kit with TypeScript
253-
* [Auth0 Mock Server](https://github.com/hirsch88/auth0-mock-server) - Useful for black-box testing or faking an oAuth server
253+
* [Auth0 Mock Server](https://github.com/hirsch88/auth0-mock-server) - Useful for e2e testing or faking an oAuth server
254254

255255
## Documentations of our main dependencies
256256
* [Express](https://expressjs.com/)

package-scripts.js

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
const { series, crossEnv, concurrent, rimraf, runInNewWindow } = require('nps-utils');
2+
3+
module.exports = {
4+
scripts: {
5+
/**
6+
* Starts the builded app from the dist directory
7+
*/
8+
start: {
9+
script: 'node dist/app.js'
10+
},
11+
/**
12+
* Serves the current app and watches for changes to restart it
13+
*/
14+
serve: {
15+
script: series(
16+
'nps banner.serve',
17+
'\"./node_modules/.bin/nodemon\" --watch src --watch .env'
18+
)
19+
},
20+
/**
21+
* Setup's the development environment and the database
22+
*/
23+
setup: {
24+
script: series(
25+
'yarn install',
26+
'nps db.migrate',
27+
'nps db.seed'
28+
)
29+
},
30+
/**
31+
* Builds the app into the dist directory
32+
*/
33+
build: {
34+
script: series(
35+
'nps banner.build',
36+
'nps lint',
37+
'nps clean.dist',
38+
'nps transpile',
39+
'nps copy'
40+
)
41+
},
42+
/**
43+
* These run various kinds of tests. Default is unit.
44+
*/
45+
test: {
46+
default: 'nps test.unit',
47+
unit: {
48+
default: {
49+
script: series(
50+
'nps banner.test',
51+
'nps test.unit.pretest',
52+
'nps test.unit.run'
53+
)
54+
},
55+
pretest: {
56+
script: './node_modules/.bin/tslint -c ./tslint.json -t stylish "./test/unit/**/*.ts"'
57+
},
58+
run: {
59+
script: './node_modules/.bin/cross-env NODE_ENV=test \"./node_modules/.bin/jest\" --testPathPattern=unit'
60+
},
61+
verbose: {
62+
script: 'nps "test --verbose"'
63+
},
64+
coverage: {
65+
script: 'nps "test --coverage"'
66+
},
67+
},
68+
e2e: {
69+
default: {
70+
script: series(
71+
'nps banner.test',
72+
'nps test.e2e.pretest',
73+
runInNewWindow(series('nps build', 'nps start')),
74+
'nps test.e2e.run',
75+
)
76+
},
77+
pretest: {
78+
script: './node_modules/.bin/tslint -c ./tslint.json -t stylish "./test/e2e/**/*.ts"'
79+
},
80+
verbose: {
81+
script: 'nps "test.e2e --verbose"'
82+
},
83+
run: series(
84+
`wait-on --timeout 120000 http-get://localhost:3000/api/info`,
85+
'./node_modules/.bin/cross-env NODE_ENV=test \"./node_modules/.bin/jest\" --testPathPattern=e2e -i'
86+
),
87+
}
88+
},
89+
/**
90+
* Runs TSLint over your project
91+
*/
92+
lint: {
93+
script: `./node_modules/.bin/tslint -c ./tslint.json -p tsconfig.json 'src/**/*.ts' --format stylish`
94+
},
95+
/**
96+
* Transpile your app into javascript
97+
*/
98+
transpile: {
99+
script: `./node_modules/.bin/tsc`
100+
},
101+
/**
102+
* Clean files and folders
103+
*/
104+
clean: {
105+
default: {
106+
script: series(`nps banner.clean`, `nps clean.dist`)
107+
},
108+
dist: {
109+
script: `./node_modules/.bin/trash './dist'`
110+
}
111+
},
112+
/**
113+
* Copies static files to the build folder
114+
*/
115+
copy: {
116+
default: {
117+
script: `nps copy.swagger && nps copy.public`
118+
},
119+
swagger: {
120+
script: copy('./src/api/swagger.json', './dist')
121+
},
122+
public: {
123+
script: copy('./src/public/*', './dist')
124+
}
125+
},
126+
/**
127+
* This our scaffold api
128+
* @example > nps "console update:targets"
129+
*/
130+
console: {
131+
default: {
132+
script: runFast('./src/console/lib/console.ts')
133+
},
134+
dev: run('./src/console/lib/console.ts'),
135+
help: runFast('./src/console/lib/console.ts --help')
136+
},
137+
/**
138+
* All database related scripts are here
139+
*/
140+
db: {
141+
migrate: {
142+
default: {
143+
script: series('nps banner.migrate', '\"./node_modules/.bin/knex\" migrate:latest')
144+
},
145+
rollback: series('nps banner.rollback', '\"./node_modules/.bin/knex\" migrate:rollback')
146+
},
147+
seed: {
148+
script: series('nps banner.seed', '\"./node_modules/.bin/knex\" seed:run')
149+
},
150+
reset: {
151+
script: series('nps banner.dbReset', 'nps console db:reset')
152+
}
153+
},
154+
/**
155+
* This creates pretty banner to the terminal
156+
*/
157+
banner: {
158+
build: banner('build'),
159+
serve: banner('serve'),
160+
test: banner('test'),
161+
migrate: banner('db.migrate'),
162+
rollback: banner('db.migrate.rollback'),
163+
dbReset: banner('db.reset'),
164+
seed: banner('seed'),
165+
clean: banner('clean')
166+
},
167+
}
168+
};
169+
170+
function banner(name) {
171+
return {
172+
hiddenFromHelp: true,
173+
silent: true,
174+
logLevel: 'error',
175+
description: `Shows ${name} banners to the console`,
176+
script: runFast(`./src/console/lib/banner.ts ${name}`)
177+
}
178+
}
179+
180+
function copy(source, target) {
181+
return `./node_modules/.bin/copyup ${source} ${target}`
182+
}
183+
184+
function run(path) {
185+
return `./node_modules/.bin/ts-node ${path}`
186+
}
187+
188+
function runFast(path) {
189+
return run(`-F ${path}`)
190+
}

0 commit comments

Comments
 (0)