Skip to content

Commit

Permalink
✨ Added nest app to workspace.
Browse files Browse the repository at this point in the history
  • Loading branch information
servrox committed May 27, 2019
1 parent bf2e581 commit fea1eb6
Show file tree
Hide file tree
Showing 19 changed files with 10,308 additions and 15 deletions.
90 changes: 77 additions & 13 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
},
"configurations": {
"production": {
"fileReplacements": [{
"replace": "apps/ng-test-app/src/environments/environment.ts",
"with": "apps/ng-test-app/src/environments/environment.prod.ts"
}],
"fileReplacements": [
{
"replace": "apps/ng-test-app/src/environments/environment.ts",
"with": "apps/ng-test-app/src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
Expand All @@ -47,11 +49,13 @@
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}]
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
Expand Down Expand Up @@ -101,10 +105,12 @@
},
"configurations": {
"production": {
"fileReplacements": [{
"replace": "apps/ng-test-app/src/environments/environment.ts",
"with": "apps/ng-test-app/src/environments/environment.prod.ts"
}]
"fileReplacements": [
{
"replace": "apps/ng-test-app/src/environments/environment.ts",
"with": "apps/ng-test-app/src/environments/environment.prod.ts"
}
]
}
}
}
Expand Down Expand Up @@ -138,6 +144,64 @@
}
}
}
},
"nest-test-app": {
"root": "apps/nest-test-app",
"sourceRoot": "apps/nest-test-app/src",
"projectType": "application",
"prefix": "nest-test-app",
"schematics": {},
"architect": {
"build": {
"builder": "@nrwl/builders:node-build",
"options": {
"outputPath": "dist/apps/nest-test-app",
"main": "apps/nest-test-app/src/main.ts",
"tsConfig": "apps/nest-test-app/tsconfig.app.json",
"assets": [
"apps/nest-test-app/src/assets"
]
},
"configurations": {
"production": {
"optimization": true,
"extractLicenses": true,
"inspect": false,
"fileReplacements": [
{
"replace": "apps/nest-test-app/src/environments/environment.ts",
"with": "apps/nest-test-app/src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@nrwl/builders:node-execute",
"options": {
"buildTarget": "nest-test-app:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"apps/nest-test-app/tsconfig.app.json",
"apps/nest-test-app/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"test": {
"builder": "@nrwl/builders:jest",
"options": {
"jestConfig": "apps/nest-test-app/jest.config.js",
"tsConfig": "apps/nest-test-app/tsconfig.spec.json"
}
}
}
}
},
"cli": {
Expand Down
5 changes: 5 additions & 0 deletions apps/nest-test-app/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
name: 'nest-test-app',
preset: '../../jest.config.js',
coverageDirectory: '../../coverage/apps/nest-test-app'
};
Empty file.
22 changes: 22 additions & 0 deletions apps/nest-test-app/src/app/app.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Test, TestingModule } from '@nestjs/testing';

import { AppController } from './app.controller';
import { AppService } from './app.service';

describe('AppController', () => {
let app: TestingModule;

beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
});

describe('getData', () => {
it('should return "Welcome to nest-test-app!"', () => {
const appController = app.get<AppController>(AppController);
expect(appController.getData()).toEqual({message: 'Welcome to nest-test-app!'});
});
});
});
13 changes: 13 additions & 0 deletions apps/nest-test-app/src/app/app.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Controller, Get } from '@nestjs/common';

import { AppService } from './app.service';

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}

@Get()
getData() {
return this.appService.getData();
}
}
11 changes: 11 additions & 0 deletions apps/nest-test-app/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';

import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
21 changes: 21 additions & 0 deletions apps/nest-test-app/src/app/app.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Test } from '@nestjs/testing';

import { AppService } from './app.service';

describe('AppService', () => {
let service: AppService;

beforeAll(async () => {
const app = await Test.createTestingModule({
providers: [AppService],
}).compile();

service = app.get<AppService>(AppService);
});

describe('getData', () => {
it('should return "Welcome to nest-test-app!"', () => {
expect(service.getData()).toEqual({message: 'Welcome to nest-test-app!'});
});
});
});
8 changes: 8 additions & 0 deletions apps/nest-test-app/src/app/app.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class AppService {
getData(): { message: string } {
return ({ message: 'Welcome to nest-test-app!' });
}
}
Empty file.
3 changes: 3 additions & 0 deletions apps/nest-test-app/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const environment = {
production: true
};
7 changes: 7 additions & 0 deletions apps/nest-test-app/src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.

export const environment = {
production: false
};
20 changes: 20 additions & 0 deletions apps/nest-test-app/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* This is not a production server yet!
* This is only a minimal backend to get started.
**/

import { NestFactory } from '@nestjs/core';

import { AppModule } from './app/app.module';

async function bootstrap() {
const app = await NestFactory.create(AppModule);
const globalPrefix = 'api';
app.setGlobalPrefix(globalPrefix);
const port = process.env.port || 3333;
await app.listen(port, () => {
console.log(`Listening at http://localhost:${port}/${globalPrefix}`);
});
}

bootstrap();
9 changes: 9 additions & 0 deletions apps/nest-test-app/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc/apps/nest-test-app",
"types": ["node"]
},
"exclude": ["**/*.spec.ts"],
"include": ["**/*.ts"]
}
12 changes: 12 additions & 0 deletions apps/nest-test-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": [
"node",
"jest"
]
},
"include": [
"**/*.ts"
]
}
12 changes: 12 additions & 0 deletions apps/nest-test-app/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc/apps/nest-test-app",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
4 changes: 4 additions & 0 deletions apps/nest-test-app/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tslint.json",
"rules": {}
}
3 changes: 3 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
},
"ng-test-app-e2e": {
"tags": []
},
"nest-test-app": {
"tags": []
}
}
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
},
"private": true,
"dependencies": {
"@nestjs/common": "^6.2.4",
"@nestjs/core": "^6.2.4",
"@angular/animations": "^7.2.15",
"@angular/common": "^7.2.15",
"@angular/compiler": "^7.2.15",
Expand All @@ -44,8 +46,6 @@
"@angular/platform-browser-dynamic": "^7.2.15",
"@angular/platform-server": "^7.2.15",
"@angular/router": "^7.2.15",
"@nestjs/common": "^6.2.4",
"@nestjs/core": "^6.2.4",
"@nestjs/ng-universal": "^1.1.1",
"@nestjs/platform-express": "^6.2.4",
"@nguniversal/express-engine": "^7.1.1",
Expand All @@ -57,6 +57,9 @@
"zone.js": "^0.9.1"
},
"devDependencies": {
"ts-jest": "24.0.0",
"@nestjs/schematics": "5.11.2",
"@nestjs/testing": "5.5.0",
"@angular-devkit/build-angular": "~0.13.9",
"@angular/cli": "7.3.9",
"@angular/compiler-cli": "~7.2.15",
Expand Down
Loading

0 comments on commit fea1eb6

Please sign in to comment.