Skip to content

Commit 271729c

Browse files
authored
Angular upgrade 18 (#13)
* angular upgrade * Angular upgrade and data seed fix * fixing issues * Angular upgrade
1 parent c61e826 commit 271729c

File tree

162 files changed

+8450
-10395
lines changed

Some content is hidden

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

162 files changed

+8450
-10395
lines changed

.DS_Store

6 KB
Binary file not shown.

Api/WebApi/Program.cs

+2-27
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,8 @@ public static async Task Main(string[] args)
2525
.ReadFrom.Configuration(config)
2626
.CreateLogger();
2727
var host = CreateHostBuilder(args).Build();
28-
29-
using (var scope = host.Services.CreateScope())
30-
{
31-
var services = scope.ServiceProvider;
32-
33-
var loggerFactory = services.GetRequiredService<ILoggerFactory>();
34-
try
35-
{
36-
var userManager = services.GetRequiredService<UserManager<ApplicationUser>>();
37-
var roleManager = services.GetRequiredService<RoleManager<IdentityRole>>();
38-
39-
await Infrastructure.Identity.Seeds.DefaultRoles.SeedAsync(userManager, roleManager);
40-
await Infrastructure.Identity.Seeds.DefaultSuperAdmin.SeedAsync(userManager, roleManager);
41-
await Infrastructure.Identity.Seeds.DefaultBasicUser.SeedAsync(userManager, roleManager);
42-
Log.Information("Finished Seeding Default Data");
43-
Log.Information("Application Starting");
44-
host.Run();
45-
}
46-
catch (Exception ex)
47-
{
48-
Log.Warning(ex, "An error occurred seeding the DB");
49-
}
50-
finally
51-
{
52-
Log.CloseAndFlush();
53-
}
54-
}
28+
host.Run();
29+
5530
}
5631

5732
public static IHostBuilder CreateHostBuilder(string[] args) =>

Api/WebApi/Startup.cs

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1+
using System;
12
using Application;
23
using Application.Interfaces;
34
using Infrastructure.Identity;
45
using Infrastructure.Identity.Contexts;
6+
using Infrastructure.Identity.Models;
57
using Infrastructure.Persistence;
68
using Infrastructure.Persistence.Contexts;
79
using Infrastructure.Shared;
810
using Microsoft.AspNetCore.Builder;
911
using Microsoft.AspNetCore.Hosting;
12+
using Microsoft.AspNetCore.Identity;
1013
using Microsoft.EntityFrameworkCore;
1114
using Microsoft.Extensions.Configuration;
1215
using Microsoft.Extensions.DependencyInjection;
1316
using Microsoft.Extensions.Hosting;
17+
using Microsoft.Extensions.Logging;
1418
using WebApi.Extensions;
1519
using WebApi.Services;
1620

@@ -36,7 +40,7 @@ public void ConfigureServices(IServiceCollection services)
3640
services.AddScoped<IAuthenticatedUserService, AuthenticatedUserService>();
3741
}
3842

39-
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
43+
public async void Configure(IApplicationBuilder app, IWebHostEnvironment env)
4044
{
4145
if (env.IsDevelopment())
4246
{
@@ -71,5 +75,30 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
7175
var context = serviceScope.ServiceProvider.GetService<IdentityContext>();
7276
context.Database.Migrate();
7377
}
78+
79+
using (var scope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())
80+
{
81+
var services = scope.ServiceProvider;
82+
83+
var loggerFactory = services.GetRequiredService<ILoggerFactory>();
84+
try
85+
{
86+
var userManager = services.GetRequiredService<UserManager<ApplicationUser>>();
87+
var roleManager = services.GetRequiredService<RoleManager<IdentityRole>>();
88+
89+
await Infrastructure.Identity.Seeds.DefaultRoles.SeedAsync(userManager, roleManager);
90+
await Infrastructure.Identity.Seeds.DefaultSuperAdmin.SeedAsync(userManager, roleManager);
91+
await Infrastructure.Identity.Seeds.DefaultBasicUser.SeedAsync(userManager, roleManager);
92+
93+
}
94+
catch (Exception ex)
95+
{
96+
97+
}
98+
finally
99+
{
100+
101+
}
102+
}
74103
}
75104
}

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Full Stack (dotnet, angular and postgres) boilerplate with Docker
22
### About (Dotnet - Angular - PostgresSQL)
3-
This project is intended to provide a starting point for building full-stack web applicatioin. The stack is made of Dotnet(7) WebApi, Angular (17.0.3), PostgresSQL. The focus of this project to show case the possible way to run a real application (Dotnet, Angular and PostgresSQL) using docker for development enviornment and produciton mode.
3+
This project is intended to provide a starting point for building full-stack web applicatioin. The stack is made of Dotnet(7) WebApi, Angular (18.1.0), PostgresSQL. The focus of this project to show case the possible way to run a real application (Dotnet, Angular and PostgresSQL) using docker for development enviornment and produciton mode.
44

55
This is a simple web application. It has working user registration, login page and there is a complete example of CRUD which contains example for Angular Routing and dotnet rest api samples. Also, rest services are secure using JWT.
66

@@ -27,7 +27,7 @@ The apps written in the following JavaScript frameworks/libraries:
2727
| **WebApi** | [Rest Api using **dotnet**](https://github.com/nitin27may/angular-dotnet-core-docker/tree/master/WebApi) |
2828

2929
### Built With
30-
#### Angular (17.0.3)
30+
#### Angular (18.1.0)
3131

3232
The fronend of this project is developed in Angular. As we are using Server Side Rendering (SSR) we have used Nodejs alpine image in place of other lightweight docker image like nginx to run Angular app.
3333

frontend/.browserslistrc

-18
This file was deleted.

frontend/.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ insert_final_newline = true
99
trim_trailing_whitespace = true
1010

1111
[*.ts]
12-
quote_type = double
12+
quote_type = single
1313

1414
[*.md]
1515
max_line_length = off

frontend/.gitignore

+11-16
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,42 @@
1-
# See http://help.github.com/ignore-files/ for more about ignoring files.
1+
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
22

3-
# compiled output
3+
# Compiled output
44
/dist
55
/tmp
66
/out-tsc
7-
# Only exists if Bazel was run
87
/bazel-out
9-
*/cache/
10-
# dependencies
11-
/node_modules
128

13-
# profiling files
14-
chrome-profiler-events*.json
15-
speed-measure-plugin*.json
9+
# Node
10+
/node_modules
11+
npm-debug.log
12+
yarn-error.log
1613

1714
# IDEs and editors
18-
/.idea
15+
.idea/
1916
.project
2017
.classpath
2118
.c9/
2219
*.launch
2320
.settings/
2421
*.sublime-workspace
2522

26-
# IDE - VSCode
23+
# Visual Studio Code
2724
.vscode/*
2825
!.vscode/settings.json
2926
!.vscode/tasks.json
3027
!.vscode/launch.json
3128
!.vscode/extensions.json
3229
.history/*
3330

34-
# misc
31+
# Miscellaneous
3532
/.angular/cache
36-
/.sass-cache
33+
.sass-cache/
3734
/connect.lock
3835
/coverage
3936
/libpeerconnection.log
40-
npm-debug.log
41-
yarn-error.log
4237
testem.log
4338
/typings
4439

45-
# System Files
40+
# System files
4641
.DS_Store
4742
Thumbs.db

frontend/.prettierignore

-3
This file was deleted.

frontend/.prettierrc

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
2-
"useTabs": false,
3-
"printWidth": 140,
4-
"tabWidth": 2,
5-
"singleQuote": false,
6-
"trailingComma": "none",
7-
"semi": true
2+
"printWidth": 80,
3+
"semi": true,
4+
"bracketSameLine": false,
5+
"trailingComma": "es5",
6+
"tabWidth": 4,
7+
"singleQuote": true,
8+
"bracketSpacing": true,
9+
"arrowParens": "always",
10+
"plugins": ["prettier-plugin-organize-imports", "prettier-plugin-tailwindcss"]
811
}

frontend/.vscode/extensions.json

+4
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+
}

frontend/.vscode/launch.json

+20
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+
}

frontend/.vscode/settings.json

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

frontend/.vscode/tasks.json

+42
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+
}

frontend/Dockerfile

+30-29
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
# Create image based off of the official Node 10 image
2-
FROM node:21-alpine as builder
3-
4-
# Copy dependency definitions
5-
COPY package.json package-lock.json ./
6-
7-
## installing and Storing node modules on a separate layer will prevent unnecessary npm installs at each build
8-
RUN npm i --legacy-peer-deps && mkdir /app && mv ./node_modules ./app
9-
10-
# Change directory so that our commands run inside this new directory
11-
WORKDIR /app
12-
13-
# Get all the code needed to run the app
14-
COPY . /app/
15-
16-
# Build bundles
17-
RUN npm run build:output
18-
19-
FROM node:21-alpine
20-
## From 'builder' copy published folder
21-
COPY --from=builder /app /app
22-
23-
WORKDIR /app
24-
# Expose the port the app runs in
25-
EXPOSE 4000
26-
27-
USER node
28-
29-
CMD ["node", "dist/frontend/server/main.js"]
1+
# Create image based off of the official Node 10 image
2+
FROM node:21-alpine as builder
3+
4+
# Copy dependency definitions
5+
COPY package.json package-lock.json ./
6+
7+
## installing and Storing node modules on a separate layer will prevent unnecessary npm installs at each build
8+
## --legacy-peer-deps as ngx-bootstrap still depends on Angular 14
9+
RUN npm i && mkdir /app && mv ./node_modules ./app
10+
11+
# Change directory so that our commands run inside this new directory
12+
WORKDIR /app
13+
14+
# Get all the code needed to run the app
15+
COPY . /app/
16+
17+
# Build server side bundles
18+
RUN npm run build
19+
20+
FROM node:21-alpine
21+
## From 'builder' copy published folder
22+
COPY --from=builder /app /app
23+
24+
WORKDIR /app
25+
# Expose the port the app runs in
26+
EXPOSE 4000
27+
28+
USER node
29+
30+
CMD ["node", "dist/contacts/server/server.mjs"]

0 commit comments

Comments
 (0)