Documentation 🤟
This page will guide you through the different steps to start with TeanJS
Description ✍️
TeanJS is a starter that provides you all the keys to be able to start writing your code as quickly as possible 🚀
Built with 🔨
NestJS 6 - The server framework used
ng-universal - Nestjs module to work with Angular universal (SSR)
Angular 8 - The client framework used
TypeORM (in association with @nestjs-typeorm) - Database management
Passport (in association with @nestjs-passport and @nestjs-jwt) - Authentication management
Jest - A test framework for the client/server units tests
Jasmine - A test framework for client side E2E
Prerequisites 🤖
To be able to start the project right a way, the only thing you will have to do is update the server environments of your database in the file ./server/environments/local/database.ts.
Then, your next action will be to run the following command npm run migration:run
. This will result in the creation of your first users table base on the migration file located in the migrations directory ./server/migrations.
Features
Often, when you start a new project, you will have a look on the existing start. But the major problem is that there is too many features that you don't need or not enough. So you have to deal with something you don't really want.
That's why, the amount of features in that starter stay limited (to avoid forcing you to use something you don't want) but enough to be ready to code.
Server
For start, let see the modules available
The Users module provide you some basic features such as
Create a new user
Find a user by Id
To achieve that, you have in your possession a users.service.ts file that encapsulate the logic to manage the users.
You will find also a user.entity.ts that describe your users and along it, a custom user.repository.ts (will see that later) and a user.subscriber-entity.ts that separate the entity behavior logic from the entity itself. The subscriber as one purpose which is to hash/Salt the user password during the creation process.
Beside these modules, the common directory comes with some useful features
EntityNotFoundExceptionHandler
These decorator only wrap a method that use TypeORM to make some action. If that action result in an error of type EntityNotFound it will catch it and redirect that error as an EntityNotFoundException which will be handle by a custom filter. It's an example that show how to handle error and unified them to get a common error output.
LoggedInUser
When a user has been logged in your api, you will have it ready on your Request object. This decorator is made to be able to grab it into your controller method as an argument.
It's the perfect example of usage of customDecorator in NestJS.
Environments ⚙️
Server
All the environments for the server are stored in the ./server/environments. In that directory there is the root files used in the application (e. g. to setup the database connection) and the local directory where you will be able to set the default values of all the environment configurations. That way, you can have a generic configuration file that will use the env variables if possible or the default values provided by the files situated in the local directory.
In the .gitignore file, there is the following statement: # /server/environments/local/
Please remove the # to avoid pushing your password and other sensitive environment configurations anywhere. You must never push your ./server/environments/local directory at any point.
Scripts 🛰️
Here is a non exhaustive list of the main commands available:
Scripts | Descriptions |
| To lint and format code (used in pre-commit hook as well) |
| Run the server side unit tests |
| Run the server side e2e tests |
| Run all the server side tests |
| Run the client side unit tests |
| Run the client side unit tests |
| Run all the client side tests |
| Create a new migration file (./server/migrations) |
| Apply migrations |
| Revert migrations |
| Build client side |
| Build server side |
| Build client and server |
| Start client only |
| Start all the project using SSR |
| Start SSR using ng-universal LiveReloadCompiler |
Last updated