├── .editorconfig
├── .gitignore
├── .prettierrc
├── Dockerfile
├── Dockerfile.build
├── LICENSE
├── README.md
├── angular.json
├── apps
├── .dockerignore
├── .gitkeep
├── admin-e2e
│ ├── protractor.conf.js
│ ├── src
│ │ ├── app.e2e-spec.ts
│ │ └── app.po.ts
│ └── tsconfig.e2e.json
├── admin
│ ├── browserslist
│ ├── karma.conf.js
│ ├── src
│ │ ├── app
│ │ │ ├── app.component.spec.ts
│ │ │ ├── app.component.ts
│ │ │ ├── app.module.ts
│ │ │ ├── app.server.module.ts
│ │ │ ├── app.service.ts
│ │ │ └── home
│ │ │ │ ├── containers
│ │ │ │ └── home
│ │ │ │ │ ├── home.component.css
│ │ │ │ │ ├── home.component.html
│ │ │ │ │ ├── home.component.spec.ts
│ │ │ │ │ └── home.component.ts
│ │ │ │ ├── home.module.spec.ts
│ │ │ │ └── home.module.ts
│ │ ├── assets
│ │ │ ├── .gitkeep
│ │ │ ├── angular.svg
│ │ │ ├── nestjs.svg
│ │ │ └── universal.svg
│ │ ├── environments
│ │ │ ├── environment.prod.ts
│ │ │ └── environment.ts
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── main.server.ts
│ │ ├── main.ts
│ │ ├── polyfills.ts
│ │ ├── styles.css
│ │ └── test.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.server.json
│ ├── tsconfig.spec.json
│ └── tslint.json
└── api
│ ├── jest.config.js
│ ├── src
│ ├── app
│ │ ├── .gitkeep
│ │ ├── server-app.controller.ts
│ │ └── server-app.module.ts
│ ├── assets
│ │ └── .gitkeep
│ ├── environments
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ └── main.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── jest.config.js
├── karma.conf.js
├── libs
├── .gitkeep
└── core
│ ├── karma.conf.js
│ ├── src
│ ├── index.ts
│ ├── lib
│ │ ├── core.module.spec.ts
│ │ ├── core.module.ts
│ │ └── sample-data.ts
│ └── test.ts
│ ├── tsconfig.lib.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── now.json
├── nx.json
├── package.json
├── tools
├── generate-version.ts
├── schematics
│ └── .gitkeep
└── tsconfig.tools.json
├── tsconfig.json
├── tslint.json
└── yarn.lock
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # We use yarn, so let's leave package-lock.json out
4 | .package-lock.json
5 |
6 | # compiled output
7 | /dist
8 | /tmp
9 | /out-tsc
10 |
11 | # dependencies
12 | /node_modules
13 |
14 | # IDEs and editors
15 | /.idea
16 | .project
17 | .classpath
18 | .c9/
19 | *.launch
20 | .settings/
21 | *.sublime-workspace
22 |
23 | # IDE - VSCode
24 | .vscode/*
25 | !.vscode/settings.json
26 | !.vscode/tasks.json
27 | !.vscode/launch.json
28 | !.vscode/extensions.json
29 |
30 | # misc
31 | /.sass-cache
32 | /connect.lock
33 | /coverage
34 | /libpeerconnection.log
35 | npm-debug.log
36 | yarn-error.log
37 | testem.log
38 | /typings
39 |
40 | # System Files
41 | .DS_Store
42 | Thumbs.db
43 | libs/core/src/version.ts
44 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "semi": false,
4 | "trailingComma": "all"
5 | }
6 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM gcr.io/distroless/nodejs
2 |
3 | WORKDIR /opt/app
4 |
5 | COPY dist /opt/app/dist
6 |
7 | CMD [ "/opt/app/dist/apps/api/main.js" ]
8 |
--------------------------------------------------------------------------------
/Dockerfile.build:
--------------------------------------------------------------------------------
1 | # This is the build environment
2 | FROM node:10-alpine as build-env
3 |
4 | # Base packages and utils
5 | RUN apk add --update --no-cache git tar curl vim python python-dev make gcc g++ automake autoconf linux-headers libgcc libstdc++
6 |
7 | # Use yarn as package manager
8 | RUN npm install -g yarn@latest
9 |
10 | # Set cache for mounting docker volumes
11 | RUN yarn config set cache-folder ~/.yarn
12 |
13 | # Install build dependencies
14 | RUN yarn global add node-sass @angular/cli
15 |
16 | # Create build environment
17 | RUN mkdir -p /opt/build
18 | WORKDIR /opt/build
19 |
20 | # Only do a reinstall if package.json changed.
21 | COPY package.json .
22 |
23 | # Copy the project
24 | COPY . .
25 |
26 | # Install deps
27 | RUN yarn install
28 |
29 | # Run build
30 | RUN yarn build
31 |
32 | # Create the final image
33 | FROM node:10-alpine
34 |
35 | # Set the working directory
36 | WORKDIR /opt/app
37 |
38 | # Selectively copy the app to the new image
39 | COPY --from=build-env /opt/build/dist /opt/app/dist
40 |
41 | # And go 🚀
42 | CMD [ "node", "/opt/app/dist/apps/api/main" ]
43 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2018 Bram Borggreve
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # angular-nest-universal-starter
2 |
3 | A simple starter repo based on [Nrwl Nx](https://github.com/nrwl/nx).
4 |
5 | It features a API built with Nest and an Angular app. It includes a Docker configuration that can be deployed to [now.sh](https://zeit.co/now).
6 |
7 | ## Installation
8 |
9 | ```
10 | git clone https://github.com/colmena/angular-nest-universal-starter my-app
11 | cd my-app
12 | # This project uses yarn, npm will most likely work just as fine :)
13 | yarn
14 | ```
15 |
16 | ## Running
17 |
18 | ```
19 | yarn dev:api
20 | yarn dev:admin
21 | ```
22 |
23 | ## Building
24 |
25 | ```
26 | # Build the whole stack
27 | yarn build
28 |
29 | # Build an individual app
30 | yarn api:build
31 | yarn admin:build
32 | ```
33 |
34 |
35 | ## Building in watch mode
36 |
37 | You can rebuild the admin in watch mode. This is a great way Angular Universal to get almost instant compilation of server side rendered code.
38 |
39 | First, you should start the build process of the admin in watch mode:
40 |
41 | ```markdown
42 | # Build the admin app in watch mode
43 | yarn build:watch
44 | ```
45 |
46 | Leave that process running, and start the api in a second terminal, in dev mode.
47 |
48 | ```markdown
49 | yarn dev:api
50 | ```
51 |
52 | This will picks up the changes in the `dist` folder and restarts the server. When you now refresh the page, you will get the new server side rendered output.
53 |
54 | ## Docker
55 |
56 | There is a Docker configuration (defined in `Dockerfile.build`) that builds the app and creates a container that contains the minimal assets to run.
57 |
58 | The docker image name is defined in `package.json`, you probably want to change that from `colmena/angular-nest-universal` to something else.
59 |
60 | ```
61 | # Build and run the docker image
62 | yarn docker
63 |
64 | # Build the docker image
65 | yarn docker:build
66 |
67 | # Run the docker image
68 | yarn docker:run
69 |
70 | # Push the docker image
71 | yarn docker:push
72 | ```
73 |
74 | ## Deployment
75 |
76 | The project is configured to deploy builds to [now.sh](https://zeit.co/now). We don't build the project on now.sh, instead we deploy the assets that are built somewhere else, for instance a CI process.
77 |
78 | `now` is not installed as dependency as it's rather large, people who use it generally have it installed globally.
79 |
80 | The `now` team name used for the deployment is defined in the `deploy` script in `package.json`, you should update it to your team or username. The `now` alias and deployment name are defined in `now.json`.
81 |
82 | ```
83 | # Make sure to build the app
84 | yarn build
85 |
86 | # Deploy to now
87 | yarn deploy
88 | ```
89 |
90 | ## MIT Licensed
91 |
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "",
5 | "projects": {
6 | "admin": {
7 | "root": "apps/admin/",
8 | "sourceRoot": "apps/admin/src",
9 | "projectType": "application",
10 | "prefix": "app",
11 | "schematics": {},
12 | "architect": {
13 | "build": {
14 | "builder": "@angular-devkit/build-angular:browser",
15 | "options": {
16 | "outputPath": "dist/apps/admin",
17 | "index": "apps/admin/src/index.html",
18 | "main": "apps/admin/src/main.ts",
19 | "polyfills": "apps/admin/src/polyfills.ts",
20 | "tsConfig": "apps/admin/tsconfig.app.json",
21 | "assets": [
22 | "apps/admin/src/favicon.ico",
23 | "apps/admin/src/assets"
24 | ],
25 | "styles": [
26 | "apps/admin/src/styles.css"
27 | ],
28 | "scripts": []
29 | },
30 | "configurations": {
31 | "production": {
32 | "fileReplacements": [
33 | {
34 | "replace": "apps/admin/src/environments/environment.ts",
35 | "with": "apps/admin/src/environments/environment.prod.ts"
36 | }
37 | ],
38 | "optimization": true,
39 | "outputHashing": "all",
40 | "sourceMap": false,
41 | "extractCss": true,
42 | "namedChunks": false,
43 | "aot": true,
44 | "extractLicenses": true,
45 | "vendorChunk": false,
46 | "buildOptimizer": true
47 | }
48 | }
49 | },
50 | "serve": {
51 | "builder": "@angular-devkit/build-angular:dev-server",
52 | "options": {
53 | "browserTarget": "admin:build"
54 | },
55 | "configurations": {
56 | "production": {
57 | "browserTarget": "admin:build:production"
58 | }
59 | }
60 | },
61 | "extract-i18n": {
62 | "builder": "@angular-devkit/build-angular:extract-i18n",
63 | "options": {
64 | "browserTarget": "admin:build"
65 | }
66 | },
67 | "test": {
68 | "builder": "@angular-devkit/build-angular:karma",
69 | "options": {
70 | "main": "apps/admin/src/test.ts",
71 | "polyfills": "apps/admin/src/polyfills.ts",
72 | "tsConfig": "apps/admin/tsconfig.spec.json",
73 | "karmaConfig": "apps/admin/karma.conf.js",
74 | "styles": [
75 | "apps/admin/src/styles.css"
76 | ],
77 | "scripts": [],
78 | "assets": [
79 | "apps/admin/src/favicon.ico",
80 | "apps/admin/src/assets"
81 | ]
82 | }
83 | },
84 | "lint": {
85 | "builder": "@angular-devkit/build-angular:tslint",
86 | "options": {
87 | "tsConfig": [
88 | "apps/admin/tsconfig.app.json",
89 | "apps/admin/tsconfig.spec.json"
90 | ],
91 | "exclude": [
92 | "**/node_modules/**"
93 | ]
94 | }
95 | },
96 | "server": {
97 | "builder": "@angular-devkit/build-angular:server",
98 | "options": {
99 | "outputPath": "dist/apps/admin-server",
100 | "main": "apps/admin/src/main.server.ts",
101 | "tsConfig": "apps/admin/tsconfig.server.json"
102 | },
103 | "configurations": {
104 | "production": {
105 | "fileReplacements": [
106 | {
107 | "replace": "apps/admin/src/environments/environment.ts",
108 | "with": "apps/admin/src/environments/environment.prod.ts"
109 | }
110 | ]
111 | }
112 | }
113 | }
114 | }
115 | },
116 | "admin-e2e": {
117 | "root": "apps/admin-e2e/",
118 | "projectType": "application",
119 | "architect": {
120 | "e2e": {
121 | "builder": "@angular-devkit/build-angular:protractor",
122 | "options": {
123 | "protractorConfig": "apps/admin-e2e/protractor.conf.js",
124 | "devServerTarget": "admin:serve"
125 | },
126 | "configurations": {
127 | "production": {
128 | "devServerTarget": "admin:serve:production"
129 | }
130 | }
131 | },
132 | "lint": {
133 | "builder": "@angular-devkit/build-angular:tslint",
134 | "options": {
135 | "tsConfig": "apps/admin-e2e/tsconfig.e2e.json",
136 | "exclude": [
137 | "**/node_modules/**"
138 | ]
139 | }
140 | }
141 | }
142 | },
143 | "api": {
144 | "root": "apps/api",
145 | "sourceRoot": "apps/api/src",
146 | "projectType": "application",
147 | "prefix": "api",
148 | "schematics": {},
149 | "architect": {
150 | "build": {
151 | "builder": "@nrwl/builders:node-build",
152 | "options": {
153 | "externalDependencies": "none",
154 | "outputPath": "dist/apps/api",
155 | "main": "apps/api/src/main.ts",
156 | "tsConfig": "apps/api/tsconfig.app.json"
157 | },
158 | "configurations": {
159 | "production": {
160 | "optimization": true,
161 | "extractLicenses": true,
162 | "fileReplacements": [
163 | {
164 | "replace": "apps/api/src/environments/environment.ts",
165 | "with": "apps/api/src/environments/environment.prod.ts"
166 | }
167 | ]
168 | }
169 | }
170 | },
171 | "serve": {
172 | "builder": "@nrwl/builders:node-execute",
173 | "options": {
174 | "buildTarget": "api:build"
175 | }
176 | },
177 | "lint": {
178 | "builder": "@angular-devkit/build-angular:tslint",
179 | "options": {
180 | "tsConfig": [
181 | "apps/api/tsconfig.app.json",
182 | "apps/api/tsconfig.spec.json"
183 | ],
184 | "exclude": [
185 | "**/node_modules/**"
186 | ]
187 | }
188 | },
189 | "test": {
190 | "builder": "@nrwl/builders:jest",
191 | "options": {
192 | "jestConfig": "apps/api/jest.config.js",
193 | "tsConfig": "apps/api/tsconfig.spec.json"
194 | }
195 | }
196 | }
197 | },
198 | "core": {
199 | "root": "libs/core",
200 | "sourceRoot": "libs/core/src",
201 | "projectType": "library",
202 | "prefix": "core",
203 | "architect": {
204 | "test": {
205 | "builder": "@angular-devkit/build-angular:karma",
206 | "options": {
207 | "main": "libs/core/src/test.ts",
208 | "tsConfig": "libs/core/tsconfig.spec.json",
209 | "karmaConfig": "libs/core/karma.conf.js"
210 | }
211 | },
212 | "lint": {
213 | "builder": "@angular-devkit/build-angular:tslint",
214 | "options": {
215 | "tsConfig": [
216 | "libs/core/tsconfig.lib.json",
217 | "libs/core/tsconfig.spec.json"
218 | ],
219 | "exclude": [
220 | "**/node_modules/**"
221 | ]
222 | }
223 | }
224 | }
225 | }
226 | },
227 | "cli": {
228 | "warnings": {
229 | "typescriptMismatch": false,
230 | "versionMismatch": false
231 | },
232 | "defaultCollection": "@nrwl/schematics",
233 | "packageManager": "yarn"
234 | },
235 | "defaultProject": "admin"
236 | }
237 |
--------------------------------------------------------------------------------
/apps/.dockerignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 |
--------------------------------------------------------------------------------
/apps/.gitkeep:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/apps/admin-e2e/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './src/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: require('path').join(__dirname, './tsconfig.e2e.json')
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
--------------------------------------------------------------------------------
/apps/admin-e2e/src/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po'
2 |
3 | describe('workspace-project App', () => {
4 | let page: AppPage
5 |
6 | beforeEach(() => {
7 | page = new AppPage()
8 | })
9 |
10 | it('should display welcome message', () => {
11 | page.navigateTo()
12 | expect(page.getParagraphText()).toEqual('Welcome to admin!')
13 | })
14 | })
15 |
--------------------------------------------------------------------------------
/apps/admin-e2e/src/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor'
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get('/')
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('colmena-root h1')).getText()
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/apps/admin-e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc/apps/admin-e2e",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "jasminewd2",
10 | "node"
11 | ]
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/apps/admin/browserslist:
--------------------------------------------------------------------------------
1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 | #
5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
6 |
7 | > 0.5%
8 | last 2 versions
9 | Firefox ESR
10 | not dead
11 | not IE 9-11
--------------------------------------------------------------------------------
/apps/admin/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | const { join } = require('path');
5 | const getBaseKarmaConfig = require('../../karma.conf');
6 |
7 | module.exports = function(config) {
8 | const baseConfig = getBaseKarmaConfig();
9 | config.set({
10 | ...baseConfig,
11 | coverageIstanbulReporter: {
12 | ...baseConfig.coverageIstanbulReporter,
13 | dir: join(__dirname, '../../coverage/apps/admin')
14 | }
15 | });
16 | };
17 |
--------------------------------------------------------------------------------
/apps/admin/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing'
2 | import { AppComponent } from './app.component'
3 |
4 | describe('AppComponent', () => {
5 | beforeEach(async(() => {
6 | TestBed.configureTestingModule({
7 | declarations: [AppComponent],
8 | }).compileComponents()
9 | }))
10 |
11 | it('should create the app', () => {
12 | const fixture = TestBed.createComponent(AppComponent)
13 | const app = fixture.debugElement.componentInstance
14 | expect(app).toBeTruthy()
15 | })
16 |
17 | it(`should have as title 'admin'`, () => {
18 | const fixture = TestBed.createComponent(AppComponent)
19 | const app = fixture.debugElement.componentInstance
20 | expect(app.title).toEqual('admin')
21 | })
22 |
23 | it('should render title in a h1 tag', () => {
24 | const fixture = TestBed.createComponent(AppComponent)
25 | fixture.detectChanges()
26 | const compiled = fixture.debugElement.nativeElement
27 | expect(compiled.querySelector('h1').textContent).toContain(
28 | 'Welcome to admin!',
29 | )
30 | })
31 | })
32 |
--------------------------------------------------------------------------------
/apps/admin/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core'
2 |
3 | @Component({
4 | selector: 'app-root',
5 | template: ``,
6 | })
7 | export class AppComponent {}
8 |
--------------------------------------------------------------------------------
/apps/admin/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser'
2 | import { NgModule } from '@angular/core'
3 | import { HttpClientModule } from '@angular/common/http'
4 | import { RouterModule, Routes } from '@angular/router'
5 | import { TransferHttpCacheModule } from '@nguniversal/common'
6 |
7 | import { AppComponent } from './app.component'
8 |
9 | const routes: Routes = [
10 | { path: '', pathMatch: 'full', redirectTo: 'home' },
11 | {
12 | path: 'home',
13 | loadChildren: './home/home.module#HomeModule',
14 | },
15 | ]
16 |
17 | @NgModule({
18 | declarations: [AppComponent],
19 | imports: [
20 | BrowserModule.withServerTransition({ appId: 'serverApp' }),
21 | TransferHttpCacheModule,
22 | HttpClientModule,
23 | RouterModule.forRoot(routes, { initialNavigation: true }),
24 | ],
25 | providers: [],
26 | bootstrap: [AppComponent],
27 | })
28 | export class AppModule {
29 | }
30 |
--------------------------------------------------------------------------------
/apps/admin/src/app/app.server.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { ServerModule, ServerTransferStateModule } from '@angular/platform-server'
3 | import { ModuleMapLoaderModule } from '@nguniversal/module-map-ngfactory-loader';
4 |
5 | import { AppModule } from './app.module';
6 | import { AppComponent } from './app.component';
7 |
8 | @NgModule({
9 | imports: [
10 | AppModule,
11 | ServerModule,
12 | ServerTransferStateModule,
13 | ModuleMapLoaderModule,
14 | ],
15 | bootstrap: [AppComponent],
16 | })
17 | export class AppServerModule {}
18 |
--------------------------------------------------------------------------------
/apps/admin/src/app/app.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core'
2 | import { HttpClient } from '@angular/common/http'
3 | import { environment } from '../environments/environment'
4 |
5 | @Injectable({ providedIn: 'root' })
6 | export class AppService {
7 | constructor(private http: HttpClient) {}
8 |
9 | public getStatus() {
10 | return this.http.get(environment.apiUrl + '/status')
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/apps/admin/src/app/home/containers/home/home.component.css:
--------------------------------------------------------------------------------
1 | .items {
2 | text-align: center;
3 | margin: 40px;
4 | min-height: 300px;
5 | }
6 |
7 | .item {
8 | width: 33%;
9 | float: left;
10 | }
11 |
12 | .data-block {
13 | margin: 40px;
14 | width: 40%;
15 | float: left;
16 | }
17 |
--------------------------------------------------------------------------------
/apps/admin/src/app/home/containers/home/home.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |

5 |
6 | Angular
7 |
8 |
9 |
10 |

12 |
13 | Nest
14 |
15 |
16 |
17 |

19 |
20 | Universal
21 |
22 |
23 |
24 |
25 |
26 |
Client
27 |
This data comes from the libraries, imported by Angular
28 |
{{ client | json }}
29 |
30 |
31 |
Server
32 |
This data comes from the server, importing the same libraries.
33 |
{{ server | json }}
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/apps/admin/src/app/home/containers/home/home.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { HomeComponent } from './home.component';
4 |
5 | describe('HomeComponent', () => {
6 | let component: HomeComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ HomeComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(HomeComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/apps/admin/src/app/home/containers/home/home.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnDestroy, OnInit } from '@angular/core'
2 | import { stack, VERSION } from '@colmena/core'
3 | import { Subscription } from 'rxjs'
4 | import { AppService } from '../../../app.service'
5 |
6 | @Component({
7 | selector: 'app-home',
8 | templateUrl: './home.component.html',
9 | styleUrls: ['./home.component.css']
10 | })
11 | export class HomeComponent implements OnInit, OnDestroy {
12 | public client = {
13 | version: VERSION,
14 | stack: stack,
15 | }
16 | public server = {}
17 |
18 | private sub: Subscription
19 |
20 | constructor(private service: AppService) {}
21 |
22 | ngOnInit() {
23 | this.sub = this.service.getStatus()
24 | .subscribe(status => this.server = status)
25 | }
26 |
27 | ngOnDestroy() {
28 | this.sub.unsubscribe()
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/apps/admin/src/app/home/home.module.spec.ts:
--------------------------------------------------------------------------------
1 | import { HomeModule } from './home.module';
2 |
3 | describe('HomeModule', () => {
4 | let homeModule: HomeModule;
5 |
6 | beforeEach(() => {
7 | homeModule = new HomeModule();
8 | });
9 |
10 | it('should create an instance', () => {
11 | expect(homeModule).toBeTruthy();
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/apps/admin/src/app/home/home.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core'
2 | import { CommonModule } from '@angular/common'
3 | import { HomeComponent } from './containers/home/home.component'
4 | import { RouterModule, Routes } from '@angular/router'
5 |
6 |
7 | const routes: Routes = [
8 | {
9 | path: '',
10 | component: HomeComponent,
11 | },
12 | ]
13 |
14 | @NgModule({
15 | imports: [
16 | CommonModule,
17 | RouterModule.forChild(routes),
18 | ],
19 | declarations: [HomeComponent],
20 | })
21 | export class HomeModule {
22 | }
23 |
--------------------------------------------------------------------------------
/apps/admin/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/colmena/angular-nest-universal-starter/eae52f8957801040d346a0b93e91eed3a045ed87/apps/admin/src/assets/.gitkeep
--------------------------------------------------------------------------------
/apps/admin/src/assets/angular.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
--------------------------------------------------------------------------------
/apps/admin/src/assets/nestjs.svg:
--------------------------------------------------------------------------------
1 |
2 |
44 |
--------------------------------------------------------------------------------
/apps/admin/src/assets/universal.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/apps/admin/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true,
3 | apiUrl: 'https://angular-nest-universal.now.sh/api',
4 | }
5 |
--------------------------------------------------------------------------------
/apps/admin/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false,
7 | apiUrl: 'http://localhost:3000/api',
8 | }
9 |
10 | /*
11 | * For easier debugging in development mode, you can import the following file
12 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
13 | *
14 | * This import should be commented out in production mode because it will have a negative impact
15 | * on performance if an error is thrown.
16 | */
17 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
18 |
--------------------------------------------------------------------------------
/apps/admin/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/colmena/angular-nest-universal-starter/eae52f8957801040d346a0b93e91eed3a045ed87/apps/admin/src/favicon.ico
--------------------------------------------------------------------------------
/apps/admin/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Admin
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/apps/admin/src/main.server.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 |
3 | import { environment } from './environments/environment';
4 |
5 | if (environment.production) {
6 | enableProdMode();
7 | }
8 |
9 | export { AppServerModule } from './app/app.server.module';
10 |
--------------------------------------------------------------------------------
/apps/admin/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core'
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
3 |
4 | import { AppModule } from './app/app.module'
5 | import { environment } from './environments/environment'
6 |
7 | if (environment.production) {
8 | enableProdMode()
9 | }
10 |
11 | document.addEventListener('DOMContentLoaded', () => {
12 | platformBrowserDynamic()
13 | .bootstrapModule(AppModule)
14 | .catch(err => console.error(err))
15 | });
16 |
--------------------------------------------------------------------------------
/apps/admin/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/
22 | // import 'core-js/es6/symbol';
23 | // import 'core-js/es6/object';
24 | // import 'core-js/es6/function';
25 | // import 'core-js/es6/parse-int';
26 | // import 'core-js/es6/parse-float';
27 | // import 'core-js/es6/number';
28 | // import 'core-js/es6/math';
29 | // import 'core-js/es6/string';
30 | // import 'core-js/es6/date';
31 | // import 'core-js/es6/array';
32 | // import 'core-js/es6/regexp';
33 | // import 'core-js/es6/map';
34 | // import 'core-js/es6/weak-map';
35 | // import 'core-js/es6/set';
36 |
37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
38 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
39 |
40 | /** IE10 and IE11 requires the following for the Reflect API. */
41 | // import 'core-js/es6/reflect';
42 |
43 | /** Evergreen browsers require these. **/
44 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
45 | import 'core-js/es7/reflect'
46 |
47 | /**
48 | * Web Animations `@angular/platform-browser/animations`
49 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
50 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
51 | **/
52 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
53 |
54 | /**
55 | * By default, zone.js will patch all possible macroTask and DomEvents
56 | * user can disable parts of macroTask/DomEvents patch by setting following flags
57 | */
58 |
59 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
60 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
61 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
62 |
63 | /*
64 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
65 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
66 | */
67 | // (window as any).__Zone_enable_cross_context_check = true;
68 |
69 | /***************************************************************************************************
70 | * Zone JS is required by default for Angular itself.
71 | */
72 | import 'zone.js/dist/zone' // Included with Angular CLI.
73 |
74 | /***************************************************************************************************
75 | * APPLICATION IMPORTS
76 | */
77 |
--------------------------------------------------------------------------------
/apps/admin/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/apps/admin/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone-testing'
4 | import { getTestBed } from '@angular/core/testing'
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting,
8 | } from '@angular/platform-browser-dynamic/testing'
9 |
10 | declare const require: any
11 |
12 | // First, initialize the Angular testing environment.
13 | getTestBed().initTestEnvironment(
14 | BrowserDynamicTestingModule,
15 | platformBrowserDynamicTesting(),
16 | )
17 | // Then we find all the tests.
18 | const context = require.context('./', true, /\.spec\.ts$/)
19 | // And load the modules.
20 | context.keys().map(context)
21 |
--------------------------------------------------------------------------------
/apps/admin/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc/apps/admin",
5 | "types": []
6 | },
7 | "exclude": [
8 | "test.ts",
9 | "**/*.spec.ts"
10 | ],
11 | "include": [
12 | "**/*.ts"
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/apps/admin/tsconfig.server.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.app.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc/apps/admin-server",
5 | "baseUrl": "../../"
6 | },
7 | "angularCompilerOptions": {
8 | "entryModule": "src/app/app.server.module#AppServerModule"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/apps/admin/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc/apps/admin",
5 | "types": [
6 | "jasmine",
7 | "node"
8 | ]
9 | },
10 | "files": [
11 | "src/test.ts",
12 | "src/polyfills.ts"
13 | ],
14 | "include": [
15 | "**/*.spec.ts",
16 | "**/*.d.ts"
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/apps/admin/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "app",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "app",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/apps/api/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: 'api',
3 | preset: '../../jest.config.js',
4 | coverageDirectory: '../../coverage/apps/api'
5 | };
6 |
--------------------------------------------------------------------------------
/apps/api/src/app/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/colmena/angular-nest-universal-starter/eae52f8957801040d346a0b93e91eed3a045ed87/apps/api/src/app/.gitkeep
--------------------------------------------------------------------------------
/apps/api/src/app/server-app.controller.ts:
--------------------------------------------------------------------------------
1 | import { Controller, Get } from '@nestjs/common'
2 | import { stack, VERSION } from '@colmena/core'
3 |
4 | @Controller()
5 | export class ServerAppController {
6 |
7 | @Get('status')
8 | status(): any {
9 | const { uptime, arch, version, platform } = process
10 | return {
11 | version: VERSION,
12 | stack,
13 | server: {
14 | uptime: uptime(),
15 | arch,
16 | version,
17 | platform,
18 | },
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/apps/api/src/app/server-app.module.ts:
--------------------------------------------------------------------------------
1 | import { Module } from '@nestjs/common';
2 | import { join } from 'path';
3 | import { AngularUniversalModule, applyDomino } from '@nestjs/ng-universal';
4 | import { ServerAppController } from './server-app.controller'
5 |
6 | @Module({
7 | controllers: [ServerAppController],
8 | imports: [
9 | AngularUniversalModule.forRoot({
10 | viewsPath: join(process.cwd(), 'dist', 'apps', 'admin'),
11 | bundle: require('../../../../dist/apps/admin-server/main.js'),
12 | }),
13 | ],
14 | })
15 | export class ServerAppModule {}
16 |
--------------------------------------------------------------------------------
/apps/api/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/colmena/angular-nest-universal-starter/eae52f8957801040d346a0b93e91eed3a045ed87/apps/api/src/assets/.gitkeep
--------------------------------------------------------------------------------
/apps/api/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/apps/api/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false
7 | };
8 |
--------------------------------------------------------------------------------
/apps/api/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { NestFactory } from '@nestjs/core';
3 | import { Logger } from '@nestjs/common';
4 | import { ServerAppModule } from './app/server-app.module';
5 |
6 | const PORT = process.env.PORT || 3000;
7 | const HOST = process.env.HOST || '0.0.0.0';
8 |
9 | enableProdMode();
10 |
11 | async function bootstrap() {
12 | const app = await NestFactory.create(ServerAppModule, { cors: true });
13 | app.setGlobalPrefix('api')
14 | await app.listen(PORT, HOST);
15 | }
16 |
17 | bootstrap()
18 | .then(() => Logger.log(`Server listening on http://${HOST}:${PORT}`))
19 | .catch(err => console.error(err));
20 |
--------------------------------------------------------------------------------
/apps/api/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "target": "es2017",
5 | "module": "commonjs",
6 | "outDir": "../../dist/out-tsc/apps/api",
7 | "types": [],
8 | "baseUrl": "../../"
9 | },
10 | "exclude": ["**/*.spec.ts"],
11 | "include": ["**/*.ts"]
12 | }
13 |
--------------------------------------------------------------------------------
/apps/api/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc/apps/api",
5 | "module": "commonjs",
6 | "types": ["jest", "node"]
7 | },
8 |
9 | "include": ["**/*.spec.ts", "**/*.d.ts"]
10 | }
11 |
--------------------------------------------------------------------------------
/apps/api/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json",
3 | "rules": {}
4 | }
5 |
--------------------------------------------------------------------------------
/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
3 | transform: {
4 | '^.+\\.(ts|js|html)$': 'jest-preset-angular/preprocessor.js'
5 | },
6 | resolver: '@nrwl/builders/plugins/jest/resolver',
7 | moduleFileExtensions: ['ts', 'js', 'html'],
8 | collectCoverage: true,
9 | coverageReporters: ['html']
10 | };
11 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | const { join } = require('path');
5 | const { constants } = require('karma');
6 |
7 | module.exports = () => {
8 | return {
9 | basePath: '',
10 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
11 | plugins: [
12 | require('karma-jasmine'),
13 | require('karma-chrome-launcher'),
14 | require('karma-jasmine-html-reporter'),
15 | require('karma-coverage-istanbul-reporter'),
16 | require('@angular-devkit/build-angular/plugins/karma')
17 | ],
18 | client: {
19 | clearContext: false // leave Jasmine Spec Runner output visible in browser
20 | },
21 | coverageIstanbulReporter: {
22 | dir: join(__dirname, '../../coverage'),
23 | reports: ['html', 'lcovonly'],
24 | fixWebpackSourcePaths: true
25 | },
26 | reporters: ['progress', 'kjhtml'],
27 | port: 9876,
28 | colors: true,
29 | logLevel: constants.LOG_INFO,
30 | autoWatch: false,
31 | browsers: ['Chrome'],
32 | singleRun: true
33 | };
34 | };
35 |
--------------------------------------------------------------------------------
/libs/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/colmena/angular-nest-universal-starter/eae52f8957801040d346a0b93e91eed3a045ed87/libs/.gitkeep
--------------------------------------------------------------------------------
/libs/core/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | const { join } = require('path');
5 | const getBaseKarmaConfig = require('../../karma.conf');
6 |
7 | module.exports = function(config) {
8 | const baseConfig = getBaseKarmaConfig();
9 | config.set({
10 | ...baseConfig,
11 | coverageIstanbulReporter: {
12 | ...baseConfig.coverageIstanbulReporter,
13 | dir: join(__dirname, '../../coverage/libs/core')
14 | }
15 | });
16 | };
17 |
--------------------------------------------------------------------------------
/libs/core/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './lib/sample-data'
2 | export * from './lib/core.module'
3 | export * from './version'
4 |
--------------------------------------------------------------------------------
/libs/core/src/lib/core.module.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, TestBed } from '@angular/core/testing'
2 | import { CoreModule } from './core.module'
3 |
4 | describe('CoreModule', () => {
5 | beforeEach(async(() => {
6 | TestBed.configureTestingModule({
7 | imports: [CoreModule],
8 | }).compileComponents()
9 | }))
10 |
11 | it('should create', () => {
12 | expect(CoreModule).toBeDefined()
13 | })
14 | })
15 |
--------------------------------------------------------------------------------
/libs/core/src/lib/core.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core'
2 | import { CommonModule } from '@angular/common'
3 |
4 | @NgModule({
5 | imports: [CommonModule],
6 | })
7 | export class CoreModule {}
8 |
--------------------------------------------------------------------------------
/libs/core/src/lib/sample-data.ts:
--------------------------------------------------------------------------------
1 | export const stack = [
2 | {
3 | name: 'Angular',
4 | description: 'Angular is a platform to build apps.',
5 | },
6 | {
7 | name: 'NestJS',
8 | description: 'NestJS is a framework to build api`s.',
9 | },
10 | {
11 | name: 'Nx',
12 | description: 'Nx is a toolkit for enterprise Angular apps.',
13 | },
14 | {
15 | name: 'Universal',
16 | description: 'Universal adds Server Side Rendering to Angular apps.',
17 | }
18 | ]
19 |
--------------------------------------------------------------------------------
/libs/core/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'core-js/es7/reflect'
4 | import 'zone.js/dist/zone'
5 | import 'zone.js/dist/zone-testing'
6 | import { getTestBed } from '@angular/core/testing'
7 | import {
8 | BrowserDynamicTestingModule,
9 | platformBrowserDynamicTesting,
10 | } from '@angular/platform-browser-dynamic/testing'
11 |
12 | declare const require: any
13 |
14 | // First, initialize the Angular testing environment.
15 | getTestBed().initTestEnvironment(
16 | BrowserDynamicTestingModule,
17 | platformBrowserDynamicTesting(),
18 | )
19 | // Then we find all the tests.
20 | const context = require.context('./', true, /\.spec\.ts$/)
21 | // And load the modules.
22 | context.keys().map(context)
23 |
--------------------------------------------------------------------------------
/libs/core/tsconfig.lib.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc/libs/core",
5 | "target": "es2015",
6 | "module": "es2015",
7 | "moduleResolution": "node",
8 | "declaration": true,
9 | "sourceMap": true,
10 | "inlineSources": true,
11 | "emitDecoratorMetadata": true,
12 | "experimentalDecorators": true,
13 | "importHelpers": true,
14 | "types": [],
15 | "lib": [
16 | "dom",
17 | "es2015"
18 | ]
19 | },
20 | "angularCompilerOptions": {
21 | "annotateForClosureCompiler": true,
22 | "skipTemplateCodegen": true,
23 | "strictMetadataEmit": true,
24 | "fullTemplateTypeCheck": true,
25 | "strictInjectionParameters": true,
26 | "enableResourceInlining": true
27 | },
28 | "exclude": [
29 | "src/test.ts",
30 | "**/*.spec.ts"
31 | ]
32 | }
33 |
--------------------------------------------------------------------------------
/libs/core/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc/libs/core",
5 | "types": [
6 | "jasmine",
7 | "node"
8 | ]
9 | },
10 | "files": [
11 | "src/test.ts"
12 | ],
13 | "include": [
14 | "**/*.spec.ts",
15 | "**/*.d.ts"
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/libs/core/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "core",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "core",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/now.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-nest-universal",
3 | "alias": "angular-nest-universal",
4 | "type": "npm",
5 | "public": true,
6 | "scale": {
7 | "sfo1": {
8 | "min": 1,
9 | "max": 1
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/nx.json:
--------------------------------------------------------------------------------
1 | {
2 | "npmScope": "colmena",
3 | "implicitDependencies": {
4 | "angular.json": "*",
5 | "package.json": "*",
6 | "tsconfig.json": "*",
7 | "tslint.json": "*",
8 | "nx.json": "*"
9 | },
10 | "projects": {
11 | "admin": {
12 | "tags": []
13 | },
14 | "admin-e2e": {
15 | "tags": []
16 | },
17 | "api": {
18 | "tags": []
19 | },
20 | "core": {
21 | "tags": []
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@colmena/angular-nest-universal",
3 | "description": "NestJS API with Angular Universal in a Nx Workspace",
4 | "version": "0.0.0",
5 | "license": "MIT",
6 | "repository": {
7 | "type" : "git",
8 | "url" : "https://github.com/colmena/angular-nest-universal-starter.git"
9 | },
10 | "homepage": "https://angular-nest-universal.now.sh/",
11 | "scripts": {
12 | "dev:api": "ng serve api",
13 | "dev:admin": "ng serve admin",
14 | "build": "npm-run-all build:admin build:admin:universal build:api",
15 | "build:api": "ng build api --prod",
16 | "build:admin": "ng build admin --prod",
17 | "build:admin:watch": "ng build admin --watch",
18 | "build:admin:universal": "ng run admin:server --configuration=production",
19 | "build:admin:universal:watch": "ng run admin:server --watch",
20 | "build:watch": "npm-run-all -p build:admin:watch build:admin:universal:watch",
21 | "docker": "npm run docker:build && npm run docker:run",
22 | "docker:build": "docker build -f Dockerfile.build -t colmena/angular-nest-universal:latest --rm .",
23 | "docker:build:dist": "docker build -f Dockerfile -t colmena/angular-nest-universal-dist:latest --rm .",
24 | "docker:run": "docker run -it --rm -p 8080:8080 -e PORT=8080 --name angular_nest_universal colmena/angular-nest-universal:latest",
25 | "docker:run:dist": "docker run -it --rm -p 8080:8080 -e PORT=8080 --name angular_nest_universal colmena/angular-nest-universal-dist:latest",
26 | "docker:push": "docker push colmena/angular-nest-universal:latest",
27 | "deploy": "now --team colmena && now alias",
28 | "start": "node dist/apps/api/main",
29 | "postinstall": "ts-node tools/generate-version",
30 | "test": "ng test",
31 | "lint": "./node_modules/.bin/nx lint && ng lint",
32 | "e2e": "ng e2e",
33 | "affected:apps": "./node_modules/.bin/nx affected:apps",
34 | "affected:libs": "./node_modules/.bin/nx affected:libs",
35 | "affected:build": "./node_modules/.bin/nx affected:build",
36 | "affected:e2e": "./node_modules/.bin/nx affected:e2e",
37 | "affected:test": "./node_modules/.bin/nx affected:test",
38 | "affected:lint": "./node_modules/.bin/nx affected:lint",
39 | "affected:dep-graph": "./node_modules/.bin/nx affected:dep-graph",
40 | "format": "./node_modules/.bin/nx format:write",
41 | "format:write": "./node_modules/.bin/nx format:write",
42 | "format:check": "./node_modules/.bin/nx format:check",
43 | "update": "ng update @nrwl/schematics",
44 | "update:check": "ng update",
45 | "pretty": "yarn format:write",
46 | "workspace-schematic": "./node_modules/.bin/nx workspace-schematic",
47 | "dep-graph": "./node_modules/.bin/nx dep-graph",
48 | "help": "./node_modules/.bin/nx help"
49 | },
50 | "private": true,
51 | "dependencies": {
52 | "@angular/animations": "^6.1.0",
53 | "@angular/common": "^6.1.0",
54 | "@angular/compiler": "^6.1.0",
55 | "@angular/core": "^6.1.0",
56 | "@angular/forms": "^6.1.0",
57 | "@angular/http": "^6.1.10",
58 | "@angular/platform-browser": "^6.1.0",
59 | "@angular/platform-browser-dynamic": "^6.1.0",
60 | "@angular/platform-server": "^6.1.0",
61 | "@angular/router": "^6.1.0",
62 | "@nestjs/common": "^5.3.11",
63 | "@nestjs/core": "^5.3.11",
64 | "@nestjs/ng-universal": "^0.1.1",
65 | "@ngrx/effects": "6.1.0",
66 | "@ngrx/router-store": "6.1.0",
67 | "@ngrx/store": "6.1.0",
68 | "@nguniversal/common": "^6.1.0",
69 | "@nguniversal/express-engine": "^6.1.0",
70 | "@nguniversal/module-map-ngfactory-loader": "^6.1.0",
71 | "@nrwl/nx": "6.4.0",
72 | "core-js": "^2.5.4",
73 | "express": "4.16.3",
74 | "npm-run-all": "^4.1.3",
75 | "reflect-metadata": "^0.1.12",
76 | "rxjs": "^6.0.0",
77 | "zone.js": "^0.8.26"
78 | },
79 | "devDependencies": {
80 | "@angular-devkit/build-angular": "~0.8.0",
81 | "@angular/cli": "6.2.4",
82 | "@angular/compiler-cli": "^6.1.0",
83 | "@angular/language-service": "^6.1.0",
84 | "@ngrx/store-devtools": "6.1.0",
85 | "@nrwl/builders": "6.4.0",
86 | "@nrwl/schematics": "6.4.0",
87 | "@types/express": "4.16.0",
88 | "@types/jasmine": "~2.8.6",
89 | "@types/jasminewd2": "~2.0.3",
90 | "@types/jest": "^23.0.0",
91 | "@types/node": "~8.9.4",
92 | "codelyzer": "~4.2.1",
93 | "git-describe": "latest",
94 | "jasmine-core": "~2.99.1",
95 | "jasmine-marbles": "0.3.1",
96 | "jasmine-spec-reporter": "~4.2.1",
97 | "jest": "^23.0.0",
98 | "jest-preset-angular": "6.0.1",
99 | "karma": "~3.0.0",
100 | "karma-chrome-launcher": "~2.2.0",
101 | "karma-coverage-istanbul-reporter": "~2.0.1",
102 | "karma-jasmine": "~1.1.0",
103 | "karma-jasmine-html-reporter": "^0.2.2",
104 | "ngrx-store-freeze": "0.2.4",
105 | "prettier": "1.13.7",
106 | "protractor": "~5.4.0",
107 | "ts-node": "~7.0.0",
108 | "tslint": "~5.11.0",
109 | "typescript": "~2.9.2"
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/tools/generate-version.ts:
--------------------------------------------------------------------------------
1 | import { gitDescribeSync } from 'git-describe'
2 | import { join, relative } from 'path'
3 | import { writeFileSync } from 'fs-extra'
4 |
5 | const { version, name, description, repository, homepage } = require('../package.json')
6 |
7 | // On now we don't have access to .git :/
8 | const git = process.env.NOW
9 | ? { raw: 'now.sh build'}
10 | : gitDescribeSync({ dirtyMark: false, dirtySemver: false })
11 |
12 | const result = {
13 | name,
14 | description,
15 | repository,
16 | homepage,
17 | version,
18 | ...git,
19 | }
20 |
21 | const file = join(process.cwd(), 'libs', 'core', 'src', 'version.ts')
22 |
23 | writeFileSync(file,
24 | `// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
25 | /* tslint:disable */
26 | export const VERSION = ${JSON.stringify(result, null, 4)};
27 | /* tslint:enable */
28 | `, { encoding: 'utf-8' })
29 |
30 | console.log(`Wrote version info ${result.raw || 'unknown' } to ${relative(process.cwd(), file)}`)
31 |
--------------------------------------------------------------------------------
/tools/schematics/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/colmena/angular-nest-universal-starter/eae52f8957801040d346a0b93e91eed3a045ed87/tools/schematics/.gitkeep
--------------------------------------------------------------------------------
/tools/tsconfig.tools.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../dist/out-tsc/tools",
5 | "rootDir": ".",
6 | "module": "commonjs",
7 | "target": "es5",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "include": [
14 | "**/*.ts"
15 | ]
16 | }
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "sourceMap": true,
5 | "declaration": false,
6 | "moduleResolution": "node",
7 | "emitDecoratorMetadata": true,
8 | "experimentalDecorators": true,
9 | "target": "es5",
10 | "typeRoots": [
11 | "node_modules/@types"
12 | ],
13 | "lib": [
14 | "es2017",
15 | "dom"
16 | ],
17 | "baseUrl": ".",
18 | "paths": {
19 | "@colmena/core": [
20 | "libs/core/src/index.ts"
21 | ]
22 | }
23 | },
24 | "exclude": [
25 | "node_modules",
26 | "tmp"
27 | ]
28 | }
29 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer",
4 | "node_modules/@nrwl/schematics/src/tslint"
5 | ],
6 | "rules": {
7 | "arrow-return-shorthand": true,
8 | "callable-types": true,
9 | "class-name": true,
10 | "deprecation": {
11 | "severity": "warn"
12 | },
13 | "forin": true,
14 | "import-blacklist": [
15 | true,
16 | "rxjs/Rx"
17 | ],
18 | "interface-over-type-literal": true,
19 | "member-access": false,
20 | "member-ordering": [
21 | true,
22 | {
23 | "order": [
24 | "static-field",
25 | "instance-field",
26 | "static-method",
27 | "instance-method"
28 | ]
29 | }
30 | ],
31 | "no-arg": true,
32 | "no-bitwise": true,
33 | "no-console": [
34 | true,
35 | "debug",
36 | "info",
37 | "time",
38 | "timeEnd",
39 | "trace"
40 | ],
41 | "no-construct": true,
42 | "no-debugger": true,
43 | "no-duplicate-super": true,
44 | "no-empty": false,
45 | "no-empty-interface": true,
46 | "no-eval": true,
47 | "no-inferrable-types": [
48 | true,
49 | "ignore-params"
50 | ],
51 | "no-misused-new": true,
52 | "no-non-null-assertion": true,
53 | "no-shadowed-variable": true,
54 | "no-string-literal": false,
55 | "no-string-throw": true,
56 | "no-switch-case-fall-through": true,
57 | "no-unnecessary-initializer": true,
58 | "no-unused-expression": true,
59 | "no-use-before-declare": true,
60 | "no-var-keyword": true,
61 | "object-literal-sort-keys": false,
62 | "prefer-const": true,
63 | "radix": true,
64 | "triple-equals": [
65 | true,
66 | "allow-null-check"
67 | ],
68 | "unified-signatures": true,
69 | "variable-name": false,
70 | "directive-selector": [
71 | true,
72 | "attribute",
73 | "app",
74 | "camelCase"
75 | ],
76 | "component-selector": [
77 | true,
78 | "element",
79 | "app",
80 | "kebab-case"
81 | ],
82 | "no-output-on-prefix": true,
83 | "use-input-property-decorator": true,
84 | "use-output-property-decorator": true,
85 | "use-host-property-decorator": true,
86 | "no-input-rename": true,
87 | "no-output-rename": true,
88 | "use-life-cycle-interface": true,
89 | "use-pipe-transform-interface": true,
90 | "component-class-suffix": true,
91 | "directive-class-suffix": true,
92 |
93 | "nx-enforce-module-boundaries": [
94 | true,
95 | {
96 | "allow": [],
97 | "depConstraints": [
98 | { "sourceTag": "*", "onlyDependOnLibsWithTags": ["*"] }
99 | ]
100 | }
101 | ]
102 | }
103 | }
104 |
--------------------------------------------------------------------------------