You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A delightful way to building a RESTful API with NodeJs & TypeScript.
4
+
> A delightful way to building a RESTful API with NodeJs & TypeScript.
5
+
6
+
> An Node.js RESTful API boilerplate featuring
7
+
[Express](https://expressjs.com/),
8
+
[Inversify](http://inversify.io/),
9
+
[Winston](https://github.com/winstonjs/winston),
10
+
[TypeScript](https://www.typescriptlang.org/),
11
+
[TsLint](http://palantir.github.io/tslint/),
12
+
[@types](https://www.npmjs.com/~types),
13
+
[Jest](https://facebook.github.io/jest/),
14
+
[Swagger](http://swagger.io/),
15
+
[validatejs](https://validatejs.org/),
16
+
[knex](http://knexjs.org/) and
17
+
[bookshelf](http://bookshelfjs.org/)
18
+
by [w3tech](https://github.com/w3tecch)
19
+
20
+
## Why
21
+
Our main goal with this project is a feature complete server application.
22
+
We like you to be focused on your business and not spending hours in project configuration.
23
+
24
+
Try it!! We are happy to hear your feedback or any kind of new features.
25
+
26
+
## Features
5
27
-**Beautiful Syntax** thanks to the awesome annotations from [Inversify Express Utils](https://github.com/inversify/inversify-express-utils).
6
28
-**Easy API Testing** with included black-box testing.
7
29
-**Dependency Injection** done with the nice framework from [Inversify](http://inversify.io/).
8
30
-**Fast Database Building** with simple migration and seeding from [Knex](http://knexjs.org/).
9
31
-**Simplified Database Query** with the ORM of [Knex](http://knexjs.org/) called [Bookshelf](http://bookshelfjs.org/).
10
32
-**Clear Structure** with controllers, services, repositories, models, middlewares...
11
-
-**Easy Exception Handling** with our own simple classes. You will see.
33
+
-**Easy Exception Handling** with our own simple and easy to adopt logic. You will love it.
12
34
-**Easy Data Seeding** with our own factories.
13
-
-**Custom Commands** are also available in our setup and really easy to use.
35
+
-**Custom Commands** are also available in our setup and really easy to use or even extend.
36
+
-**Scaffolding Commands** will speed up your development tremendously as you should focus on business code and not scaffolding.
14
37
-**Smart Validation** thanks to [class-validator](https://github.com/pleerock/class-validator) with some nice annotations.
15
38
-**API Documentation** thanks to [swagger](http://swagger.io/).
16
39
-**API Monitoring** thanks to [express-status-monitor](https://github.com/RafalWilinski/express-status-monitor).
@@ -26,16 +49,18 @@ A delightful way to building a RESTful API with NodeJs & TypeScript.
26
49
### Installing
27
50
*`fork` this repo
28
51
*`clone` your fork
29
-
*`yarn install` to install all dependencies and typings
30
-
* Create new database. You will find the name in the .env files.
31
-
*`npm run db:migrate` to create the schema
32
-
*`npm run db:seed` to insert some test data
33
-
*`npm run serve` to start the dev server in another tab
52
+
*`cp .env.example .env` to copy the example .env file and enter your database connection
53
+
* Create a new database. You will find the name in the .env file.
54
+
* Run `npm run setup` or enter the following commands manually:
55
+
*`yarn install` to install all dependencies and typings.
56
+
*`npm run db:migrate` to create the schema.
57
+
*`npm run db:seed` to insert some test data.
58
+
*`npm run serve` to start the application.
34
59
35
60
### Running the app
36
-
After you have installed all dependencies you can now run the app.
37
-
Run`npm run serve` to start a local server using `nodemon` which will watch for changes and then will restart the sever.
38
-
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/`).
61
+
After you have installed all dependencies you can run the app.
62
+
Enter`npm run serve` to start a local server using `nodemon`, which will watch for any file changes and will restart the sever according to these changes.
63
+
The server address will be displayed to you as `http://0.0.0.0:3000`.
39
64
40
65
## Scripts / Tasks
41
66
All script are defined in the package.json file, but the most important ones are listed here.
@@ -44,91 +69,111 @@ All script are defined in the package.json file, but the most important ones are
44
69
* Install all dependencies with `yarn install`
45
70
46
71
### Linting
47
-
* Run code analysis using `npm run lint`. This runs tslint.
48
-
* There is also a vscode task for this called lint.
72
+
* Run code quality analysis using `npm run lint`. This runs tslint.
73
+
* There is also a vscode task for this called `lint`.
49
74
50
75
### Tests
51
-
* Run the unit tests using `npm test`.
76
+
* Run the unit tests using `npm test` (There is also a vscode task for this called `test`).
52
77
* 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).
53
-
* There is also a vscode task for this called test.
54
78
55
79
### Running in dev mode
56
-
* Run `npm run serve` to start nodemon with ts-node, which will serve your app.
80
+
* Run `npm run serve` to start nodemon with ts-node, to serve the app.
57
81
* The server address will be displayed to you as `http://0.0.0.0:3000`
58
82
59
83
### Building the project and run it
60
-
* Run `npm run build` to generated all JavaScript files from your TypeScript sources. After this step you can deploy the app on any server.
61
-
* There is also a vscode task for this called build.
62
-
* To start the builded app use `npm start`.
84
+
* Run `npm run build` to generated all JavaScript files from the TypeScript sources (There is also a vscode task for this called `build`).
85
+
* To start the builded app located in `dist` use `npm start`.
63
86
64
87
### Database
65
-
* Run `npm run db:migrate` to migration the new schema to the database
66
-
* Run `npm run db:migrate:rollback` to rollback one version
67
-
* Run `npm run db:seed` to seed some data into the database
68
-
* Run `npm run db:reset` to clean the database and migrate again
88
+
* Run `npm run db:migrate` to migrate schema changes to the database
89
+
* Run `npm run db:migrate:rollback` to rollback one migration
90
+
* Run `npm run db:seed` to seed sample data into the database
91
+
* Run `npm run db:reset` to rollback all migrations and migrate any migration again
69
92
70
93
### Console
71
-
* To run your own created cli script enter `npm run console <command-name>`
94
+
* To run your own created command enter `npm run console <command-name>`.
95
+
* This list all your created commands `npm run console:help`.
96
+
97
+
### Scaffolding Commands
98
+
All the templates for the commands are located in `src/console/templates`.
99
+
100
+
*`npm run console make:resource <file>` - Generates a controller, service, requests, repo, model and a migration with CRUD operations.
101
+
*`npm run console make:controller <file>` - Generates a controller.
102
+
*`npm run console make:service <file>` - Generates a service.
103
+
*`npm run console make:repo <file>` - Generates a repository.
104
+
*`npm run console make:model <file>` - Generates a model with the props and configurations.
105
+
*`npm run console make:middleware <file>` - Generates a basic middleware.
106
+
*`npm run console make:request <file>` - Generates a basic request.
107
+
*`npm run console make:listener <file>` - Generates a basic listener.
108
+
*`npm run console make:exception <file>` - Generates a basic exception.
109
+
*`npm run console update:targets <file>` - Reads all the API files and generate a new `constants/Targets.ts` file out of it.
| knexfile.ts | This file is used for the migrations and seed task of knex |
124
169
125
170
## Related Projects
126
171
*[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.
127
172
*[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
128
173
*[aurelia-typescript-boilerplate](https://github.com/w3tecch/aurelia-typescript-boilerplate) - An Aurelia starter kit with TypeScript
*[Auth0 API Documentation](https://auth0.com/docs/api/management/v2#!/Users/get_users)
185
+
*[Auth0 API Documentation](https://auth0.com/docs/api/management/v2)
141
186
*[swagger Documentation](http://swagger.io/)
142
187
143
188
## License
144
189
[MIT](/LICENSE)
145
190
146
191
---
147
-
Made with ♥ by Gery Hirschfeld ([@GeryHirschfeld1](https://twitter.com/GeryHirschfeld1)) and [contributors](https://github.com/w3tecch/express-typescript-boilerplate/graphs/contributors)
192
+
Made with ♥ by w3tech ([w3tech](https://github.com/w3tecch)), Gery Hirschfeld ([@GeryHirschfeld1](https://twitter.com/GeryHirschfeld1)) and [contributors](https://github.com/w3tecch/express-typescript-boilerplate/graphs/contributors)
0 commit comments