Skip to content

Commit

Permalink
chore(doc): added architecture documentation, This connected to #9 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
NarHakobyan committed Oct 15, 2019
1 parent 53c4111 commit 35a8d9d
Show file tree
Hide file tree
Showing 15 changed files with 171 additions and 55 deletions.
34 changes: 17 additions & 17 deletions .vuepress/config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/* tslint:disable */
module.exports = {
title: 'Awesome nest boilerplate 🎉',
description: `An ultimate and awesome nodejs boilerplate wrote in typescript`,
base: process.env.DEPLOY_ENV === 'gh-pages' ? '/awesome-nest-boilerplate/': '/',
themeConfig: {
sidebar: [
['/', 'Introduction'],
'/docs/development',
// '/docs/architecture',
// '/docs/tech',
// '/docs/routing',
// '/docs/state',
// '/docs/linting',
// '/docs/editors',
// '/docs/production',
// '/docs/troubleshooting',
],
},
title: 'Awesome nest boilerplate 🎉',
description: `An ultimate and awesome nodejs boilerplate wrote in typescript`,
base: process.env.DEPLOY_ENV === 'gh-pages' ? '/awesome-nest-boilerplate/' : '/',
themeConfig: {
sidebar: [
['/', 'Introduction'],
'/docs/development',
'/docs/architecture',
// '/docs/tech',
// '/docs/routing',
// '/docs/state',
// '/docs/linting',
// '/docs/editors',
// '/docs/production',
// '/docs/troubleshooting',
],
},
};
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,28 @@ yarn start:dev
## Features

<dl>
<dt>Quick scaffolding</dt>
<dt><b>Quick scaffolding</b></dt>
<dd>Create modules, services, controller - right from the CLI!</dd>

<dt>Instant feedback</dt>
<dt><b>Instant feedback</b></dt>
<dd>Enjoy the best DX (Developer eXperience) and code your app at the speed of thought! Your saved changes are reflected instantaneously.</dd>

<dt>JWT Authentication</dt>
<dt><b>JWT Authentication</b></dt>
<dd>Installed and configured JWT authentication.</dd>

<dt>Next generation Typescript</dt>
<dt><b>Next generation Typescript</b></dt>
<dd>Always up to date typescript version.</dd>

<dt>Industry-standard routing</dt>
<dd>It's natural to want to add pages (e.g. `/about`) to your application, and routing makes this possible.</dd>
<dt><b>Industry-standard routing</b></dt>
<dd>It's natural to want to add pages (e.g. /about`) to your application, and routing makes this possible.</dd>

<dt>Linter</dt>
<dt><b>Environment Configuration</b></dt>
<dd>development, staging and production environment configurations</dd>

<dt><b>Swagger Api Documentation</b></dt>
<dd>Already integrated API documentation. To see all available endpoints visit http://localhost:3000/documentation</dd>

<dt><b>Linter</b></dt>
<dd>tslint + eslint + prettier = ❤️</dd>
</dl>

Expand Down
109 changes: 109 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Architecture

- [Architecture](#architecture)
- [`.vscode`](#vscode)
- [`docs`](#docs)
- [`.vuepress`](#vuepress)
- [`src`](#src)
- [`common`](#common)
- [`decorators`](#decorators)
- [`interceptors`](#interceptors)
- [`exception-filters`](#exception-filters)
- [`guards`](#guards)
- [`interfaces`](#interfaces)
- [`migrations`](#migrations)
- [`providers`](#providers)
- [`shared`](#shared)
- [`modules`](#modules)
- [`app.module.ts`](#appmodulets)
- [`boilerplate.polyfill.ts`](#boilerplatepolyfillts)
- [`snake-naming.strategy.ts`](#snake-namingstrategyts)
- [`.*.env`](#env)
- [`.eslintrc.json`](#eslintrcjson)
- [`tslint.json`](#tslintjson)

## `.vscode`

Settings and extensions specific to this project, for Visual Studio Code. See [the editors doc](editors.md#visual-studio-code) for more.

## `docs`

You found me! :wink:

## `.vuepress`

Documentation config and destination folder See [VuePress doc](https://vuepress.vuejs.org) for more

## `src`

Where we keep all our source files.

### `common`

Where we keep common typescript files, e.g. constants and DTOs.

### `decorators`

This folder contains all global [decorators](https://www.typescriptlang.org/docs/handbook/decorators.html).

### `interceptors`

Where we are keep [interceptors](https://docs.nestjs.com/interceptors)

### `exception-filters`

In this folder you can find app level [exception-filters](https://docs.nestjs.com/exception-filters).

### `guards`

You can store all guards here

### `interfaces`

This folder contains typescript [interfaces](https://www.typescriptlang.org/docs/handbook/interfaces.html)

### `migrations`

Folder to store application migrations which will be generated by typeorm.

### `providers`

These are utility functions you may want to share between many files in your application. They will always be pure and never have side effects, meaning if you provide a function the same arguments, it will always return the same result.

### `shared`

Shared module with global singleton services.

### `modules`

Where all our NestJS modules lives. See [NestJS modules documentation](https://docs.nestjs.com/modules) for more.

### `app.module.ts`

The root application module.

### `boilerplate.polyfill.ts`

We extend built in classes so you can use helper function anywhere.

```typescript
const users: UserEntity[] = ...;

const userDtos = users.toDtos();
```

### `snake-naming.strategy.ts`

We are using snake naming strategy for typeorm, so when you will generate migration it automatically will set snake_case column name from entity fields.

## `.*.env`

Environment variables which will load before app start and will be stored in `process.env`, (*) is a env name (development, staging, production, ...)

## `.eslintrc.json`

Eslint configuration file, See [the eslint doc](https://eslint.org/) for more.

## `tslint.json`

Tslint configuration file, See [the tslint doc](https://palantir.github.io/tslint/) for more.
10 changes: 5 additions & 5 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import './boilerplate.polyfill';

import { TypeOrmModule } from '@nestjs/typeorm';
import { Module, NestModule, MiddlewareConsumer } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

import { ConfigService } from './shared/services/config.service';
import { AuthModule } from './modules/auth/auth.module';
import { UserModule } from './modules/user/user.module';
import { contextMiddleware } from './middlewares';
import { AuthModule } from './modules/auth/auth.module';
import { MathModule } from './modules/math/math.module';
import { SharedModule } from './shared.module';
import { UserModule } from './modules/user/user.module';
import { ConfigService } from './shared/services/config.service';
import { SharedModule } from './shared/shared.module';

@Module({
imports: [
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/common/dto/PageOptionsDto.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Type } from 'class-transformer';
import { ApiModelPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsEnum, IsInt, Min, IsOptional, Max, IsString, IsNotEmpty } from 'class-validator';

import { Order } from '../enum/order';
import { Order } from '../constants/order';

export class PageOptionsDto {
@ApiModelPropertyOptional({
Expand Down
3 changes: 2 additions & 1 deletion src/decorators/roles.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SetMetadata } from '@nestjs/common';
import { RoleType } from '../constants/role-type';

import { RoleType } from '../common/constants/role-type';

export const Roles = (...roles: RoleType[]) => SetMetadata('roles', roles);
6 changes: 3 additions & 3 deletions src/filters/bad-request.filter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as _ from 'lodash';
import { Reflector } from '@nestjs/core';
import { Response } from 'express';
import { ExceptionFilter, Catch, ArgumentsHost, BadRequestException, HttpStatus } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { ValidationError } from 'class-validator';
import { Response } from 'express';
import * as _ from 'lodash';

@Catch(BadRequestException)
export class HttpExceptionFilter implements ExceptionFilter {
Expand Down
18 changes: 9 additions & 9 deletions src/main.hmr.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import * as morgan from 'morgan';
import * as helmet from 'helmet';
import * as compression from 'compression';
import * as RateLimit from 'express-rate-limit';
import { Transport } from '@nestjs/microservices';
import { ValidationPipe, ClassSerializerInterceptor } from '@nestjs/common';
import { NestFactory, Reflector } from '@nestjs/core';
import { Transport } from '@nestjs/microservices';
import { NestExpressApplication } from '@nestjs/platform-express';
import { ValidationPipe, ClassSerializerInterceptor } from '@nestjs/common';
import * as compression from 'compression';
import * as RateLimit from 'express-rate-limit';
import * as helmet from 'helmet';
import * as morgan from 'morgan';

import { AppModule } from './app.module';
import { setupSwagger } from './viveo-swagger';
import { ConfigService } from './shared/services/config.service';
import { HttpExceptionFilter } from './filters/bad-request.filter';
import { SharedModule } from './shared.module';
import { ConfigService } from './shared/services/config.service';
import { SharedModule } from './shared/shared.module';
import { setupSwagger } from './viveo-swagger';

declare const module: any;

Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { initializeTransactionalContext, patchTypeORMRepositoryWithBaseRepositor
import { AppModule } from './app.module';
import { HttpExceptionFilter } from './filters/bad-request.filter';
import { QueryFailedFilter } from './filters/query-failed.filter';
import { SharedModule } from './shared.module';
import { ConfigService } from './shared/services/config.service';
import { SharedModule } from './shared/shared.module';
import { setupSwagger } from './viveo-swagger';

async function bootstrap() {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/user/dto/UserDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import { ApiModelPropertyOptional } from '@nestjs/swagger';

import { UserEntity } from '../user.entity';
import { RoleType } from '../../../common/constants/role-type';
import { AbstractDto } from '../../../common/dto/AbstractDto';
import { RoleType } from '../../../constants/role-type';
import { UserEntity } from '../user.entity';

export class UserDto extends AbstractDto {

Expand Down
2 changes: 1 addition & 1 deletion src/modules/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@nestjs/common';
import { ApiBearerAuth, ApiResponse, ApiUseTags } from '@nestjs/swagger';

import { RoleType } from '../../constants/role-type';
import { RoleType } from '../../common/constants/role-type';
import { AuthUser } from '../../decorators/auth-user.decorator';
import { Roles } from '../../decorators/roles.decorator';
import { AuthGuard } from '../../guards/auth.guard';
Expand Down
4 changes: 2 additions & 2 deletions src/modules/user/user.entity.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Entity, Column } from 'typeorm';

import { UserDto } from './dto/UserDto';
import { RoleType } from '../../constants/role-type';
import { AbstractEntity } from '../../common/abstract.entity';
import { RoleType } from '../../common/constants/role-type';
import { UserDto } from './dto/UserDto';
import { PasswordTransformer } from './password.transformer';

@Entity({ name: 'users' })
Expand Down
10 changes: 5 additions & 5 deletions src/shared.module.ts → src/shared/shared.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { JwtModule } from '@nestjs/jwt';
import { Module, Global, HttpModule } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';

import { ConfigService } from './shared/services/config.service';
import { ValidatorService } from './shared/services/validator.service';
import { AwsS3Service } from './shared/services/aws-s3.service';
import { GeneratorService } from './shared/services/generator.service';
import { AwsS3Service } from './services/aws-s3.service';
import { ConfigService } from './services/config.service';
import { GeneratorService } from './services/generator.service';
import { ValidatorService } from './services/validator.service';

const providers = [ConfigService, ValidatorService, AwsS3Service, GeneratorService];

Expand Down

0 comments on commit 35a8d9d

Please sign in to comment.