Skip to content

Commit e3b84ed

Browse files
authored
Merge pull request #7 from duynghiadev/dev
Add some feature for project
2 parents 96bd00f + 5467a9d commit e3b84ed

File tree

553 files changed

+277389
-2845
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

553 files changed

+277389
-2845
lines changed

shopapp-angular/.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ root = true
44
[*]
55
charset = utf-8
66
indent_style = space
7-
indent_size = 4
7+
indent_size = 2
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3+
"recommendations": ["angular.ng-template"]
4+
}

shopapp-angular/.vscode/launch.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3+
"version": "0.2.0",
4+
"configurations": [
5+
{
6+
"name": "ng serve",
7+
"type": "chrome",
8+
"request": "launch",
9+
"preLaunchTask": "npm: start",
10+
"url": "http://localhost:4200/"
11+
},
12+
{
13+
"name": "ng test",
14+
"type": "chrome",
15+
"request": "launch",
16+
"preLaunchTask": "npm: test",
17+
"url": "http://localhost:9876/debug.html"
18+
}
19+
]
20+
}

shopapp-angular/.vscode/tasks.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
3+
"version": "2.0.0",
4+
"tasks": [
5+
{
6+
"type": "npm",
7+
"script": "start",
8+
"isBackground": true,
9+
"problemMatcher": {
10+
"owner": "typescript",
11+
"pattern": "$tsc",
12+
"background": {
13+
"activeOnStart": true,
14+
"beginsPattern": {
15+
"regexp": "(.*?)"
16+
},
17+
"endsPattern": {
18+
"regexp": "bundle generation complete"
19+
}
20+
}
21+
}
22+
},
23+
{
24+
"type": "npm",
25+
"script": "test",
26+
"isBackground": true,
27+
"problemMatcher": {
28+
"owner": "typescript",
29+
"pattern": "$tsc",
30+
"background": {
31+
"activeOnStart": true,
32+
"beginsPattern": {
33+
"regexp": "(.*?)"
34+
},
35+
"endsPattern": {
36+
"regexp": "bundle generation complete"
37+
}
38+
}
39+
}
40+
}
41+
]
42+
}

shopapp-angular/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ShopappAngular
22

3-
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.1.3.
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.0.6.
44

55
## Development server
66

shopapp-angular/angular.json

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
"prefix": "app",
1616
"architect": {
1717
"build": {
18-
"builder": "@angular-devkit/build-angular:browser",
18+
"builder": "@angular-devkit/build-angular:application",
1919
"options": {
2020
"outputPath": "dist/shopapp-angular",
2121
"index": "src/index.html",
22-
"main": "src/main.ts",
22+
"browser": "src/main.ts",
2323
"polyfills": [
2424
"zone.js"
2525
],
@@ -29,12 +29,18 @@
2929
"src/favicon.ico",
3030
"src/assets"
3131
],
32-
"styles": [
32+
"styles": [
3333
"node_modules/bootstrap/dist/css/bootstrap.min.css",
3434
"node_modules/@fortawesome/fontawesome-free/css/all.min.css",
35-
"src/styles.scss"
35+
"src/styles.scss",
36+
"node_modules/font-awesome/css/font-awesome.min.css"
3637
],
37-
"scripts": []
38+
"scripts": [],
39+
"server": "src/main.server.ts",
40+
"prerender": true,
41+
"ssr": {
42+
"entry": "server.ts"
43+
}
3844
},
3945
"configurations": {
4046
"production": {
@@ -53,12 +59,9 @@
5359
"outputHashing": "all"
5460
},
5561
"development": {
56-
"buildOptimizer": false,
5762
"optimization": false,
58-
"vendorChunk": true,
5963
"extractLicenses": false,
60-
"sourceMap": true,
61-
"namedChunks": true
64+
"sourceMap": true
6265
}
6366
},
6467
"defaultConfiguration": "production"
@@ -67,18 +70,18 @@
6770
"builder": "@angular-devkit/build-angular:dev-server",
6871
"configurations": {
6972
"production": {
70-
"browserTarget": "shopapp-angular:build:production"
73+
"buildTarget": "shopapp-angular:build:production"
7174
},
7275
"development": {
73-
"browserTarget": "shopapp-angular:build:development"
76+
"buildTarget": "shopapp-angular:build:development"
7477
}
7578
},
7679
"defaultConfiguration": "development"
7780
},
7881
"extract-i18n": {
7982
"builder": "@angular-devkit/build-angular:extract-i18n",
8083
"options": {
81-
"browserTarget": "shopapp-angular:build"
84+
"buildTarget": "shopapp-angular:build"
8285
}
8386
},
8487
"test": {
@@ -95,8 +98,7 @@
9598
"src/assets"
9699
],
97100
"styles": [
98-
"src/styles.scss",
99-
"node_modules/bootstrap/dist/css/bootstrap.min.css"
101+
"src/styles.scss"
100102
],
101103
"scripts": []
102104
}
@@ -105,6 +107,6 @@
105107
}
106108
},
107109
"cli": {
108-
"analytics": "12eead7c-ea1a-4218-9ebd-51ba7ffceaee"
110+
"analytics": "dac30cc0-5522-4d2b-a4f8-560fe105be5a"
109111
}
110112
}

shopapp-angular/package.json

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,51 @@
55
"ng": "ng",
66
"start": "ng serve",
77
"build": "ng build",
8+
"build:production": "ng build --configuration=production",
9+
"start:dev": "ng serve --port 4300",
10+
"build:dev": "ng build --port 4300",
811
"watch": "ng build --watch --configuration development",
9-
"test": "ng test"
12+
"test": "ng test",
13+
"serve:ssr:shopapp-angular": "node dist/shopapp-angular/server/server.mjs"
1014
},
1115
"private": true,
1216
"dependencies": {
13-
"@angular/animations": "^16.1.0",
14-
"@angular/common": "^16.1.0",
15-
"@angular/compiler": "^16.1.0",
16-
"@angular/core": "^16.1.0",
17-
"@angular/forms": "^16.1.0",
18-
"@angular/platform-browser": "^16.1.0",
19-
"@angular/platform-browser-dynamic": "^16.1.0",
20-
"@angular/router": "^16.1.0",
21-
"@fortawesome/fontawesome-free": "^6.4.0",
22-
"bootstrap": "^5.3.0",
17+
"@angular/animations": "^17.0.0",
18+
"@angular/common": "^17.0.0",
19+
"@angular/compiler": "^17.0.0",
20+
"@angular/core": "^17.0.0",
21+
"@angular/forms": "^17.0.0",
22+
"@angular/platform-browser": "^17.0.0",
23+
"@angular/platform-browser-dynamic": "^17.0.0",
24+
"@angular/platform-server": "^17.0.0",
25+
"@angular/router": "^17.0.0",
26+
"@angular/ssr": "^17.0.6",
27+
"@auth0/angular-jwt": "^5.2.0",
28+
"@fortawesome/fontawesome-free": "^6.5.1",
29+
"@ng-bootstrap/ng-bootstrap": "^16.0.0",
30+
"@popperjs/core": "^2.11.8",
31+
"bootstrap": "^5.3.2",
32+
"class-transformer": "^0.5.1",
33+
"class-validator": "^0.14.0",
34+
"express": "^4.18.2",
35+
"font-awesome": "^4.7.0",
2336
"rxjs": "~7.8.0",
2437
"tslib": "^2.3.0",
25-
"zone.js": "~0.13.0"
38+
"zone.js": "~0.14.2"
2639
},
2740
"devDependencies": {
28-
"@angular-devkit/build-angular": "^16.1.3",
29-
"@angular/cli": "~16.1.3",
30-
"@angular/compiler-cli": "^16.1.0",
31-
"@types/jasmine": "~4.3.0",
32-
"jasmine-core": "~4.6.0",
41+
"@angular-devkit/build-angular": "^17.0.6",
42+
"@angular/cli": "^17.0.6",
43+
"@angular/compiler-cli": "^17.0.0",
44+
"@types/express": "^4.17.17",
45+
"@types/jasmine": "~5.1.0",
46+
"@types/node": "^18.18.0",
47+
"jasmine-core": "~5.1.0",
3348
"karma": "~6.4.0",
3449
"karma-chrome-launcher": "~3.2.0",
3550
"karma-coverage": "~2.2.0",
3651
"karma-jasmine": "~5.1.0",
3752
"karma-jasmine-html-reporter": "~2.1.0",
38-
"typescript": "~5.1.3"
53+
"typescript": "~5.2.2"
3954
}
4055
}

shopapp-angular/server.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { APP_BASE_HREF } from '@angular/common';
2+
import { CommonEngine } from '@angular/ssr';
3+
import express from 'express';
4+
import { fileURLToPath } from 'node:url';
5+
import { dirname, join, resolve } from 'node:path';
6+
import bootstrap from './src/main.server';
7+
8+
// The Express app is exported so that it can be used by serverless Functions.
9+
export function app(): express.Express {
10+
const server = express();
11+
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
12+
const browserDistFolder = resolve(serverDistFolder, '../browser');
13+
const indexHtml = join(serverDistFolder, 'index.server.html');
14+
15+
const commonEngine = new CommonEngine();
16+
17+
server.set('view engine', 'html');
18+
server.set('views', browserDistFolder);
19+
20+
// Example Express Rest API endpoints
21+
// server.get('/api/**', (req, res) => { });
22+
// Serve static files from /browser
23+
server.get('*.*', express.static(browserDistFolder, {
24+
maxAge: '1y'
25+
}));
26+
27+
// All regular routes use the Angular engine
28+
server.get('*', (req, res, next) => {
29+
const { protocol, originalUrl, baseUrl, headers } = req;
30+
31+
commonEngine
32+
.render({
33+
bootstrap,
34+
documentFilePath: indexHtml,
35+
url: `${protocol}://${headers.host}${originalUrl}`,
36+
publicPath: browserDistFolder,
37+
providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }],
38+
})
39+
.then((html) => res.send(html))
40+
.catch((err) => next(err));
41+
});
42+
43+
return server;
44+
}
45+
46+
function run(): void {
47+
const port = process.env['PORT'] || 4000;
48+
49+
// Start up the Node server
50+
const server = app();
51+
server.listen(port, () => {
52+
console.log(`Node Express server listening on http://localhost:${port}`);
53+
});
54+
}
55+
56+
run();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
2+
import { provideServerRendering } from '@angular/platform-server';
3+
import { appConfig } from './app.config';
4+
5+
const serverConfig: ApplicationConfig = {
6+
providers: [
7+
provideServerRendering()
8+
]
9+
};
10+
11+
export const config = mergeApplicationConfig(appConfig, serverConfig);

shopapp-angular/src/app/app.config.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { ApplicationConfig } from '@angular/core';
2+
import { provideRouter } from '@angular/router';
3+
import { provideHttpClient } from '@angular/common/http';
4+
import { withFetch } from '@angular/common/http';
5+
6+
import { routes } from './app.routes';
7+
import { provideClientHydration } from '@angular/platform-browser';
8+
import { Provider } from '@angular/core';
9+
import { HTTP_INTERCEPTORS } from '@angular/common/http';
10+
import { TokenInterceptor } from './interceptors/token.interceptor';
11+
import { importProvidersFrom } from '@angular/core';
12+
import { HttpClientModule } from '@angular/common/http';
13+
import { adminRoutes } from './components/admin/admin-routes';
14+
import { RouterModule } from '@angular/router';
15+
16+
const tokenInterceptorProvider: Provider =
17+
{ provide: HTTP_INTERCEPTORS, useClass: TokenInterceptor, multi: true };
18+
19+
20+
export const appConfig: ApplicationConfig = {
21+
providers: [
22+
provideRouter(routes),
23+
//importProvidersFrom(RouterModule.forRoot(routes)),
24+
importProvidersFrom(RouterModule.forChild(adminRoutes)),
25+
provideHttpClient(withFetch()),
26+
//provideHttpClient(),
27+
tokenInterceptorProvider,
28+
provideClientHydration(),
29+
importProvidersFrom(HttpClientModule),
30+
]
31+
};

shopapp-angular/src/app/app.module.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)