Skip to content

Commit 5d40e8f

Browse files
author
Florin Mateescu
committed
migrate to angular 17, migrate to payloadcms v2
1 parent ef23c71 commit 5d40e8f

File tree

124 files changed

+4935
-3636
lines changed

Some content is hidden

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

124 files changed

+4935
-3636
lines changed

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ Thumbs.db
4545
.env
4646
env.json
4747
infrastructure.json
48-
.npmrc
4948
yarn-error*
5049
yarn-log*
51-
.pnpm-store
50+
.pnpm-store
51+
mongodata
52+
.nx

apps/express/.eslintrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": ["../../.eslintrc.json"],
33
"ignorePatterns": ["!**/*"],
4+
"rules": { "@typescript-eslint/no-var-requires": "off" },
45
"overrides": [
56
{
67
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],

apps/express/payload.config.ts

+34-18
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,26 @@ import {
99
ReturnToWebComponent,
1010
TagsCollection,
1111
UsersCollection,
12-
} from '@binarystarter-angular/backend-only/payloadcms';
13-
import dotenv from 'dotenv';
12+
} from 'apps/express/src/payloadcms/src';
13+
import { webpackBundler } from '@payloadcms/bundler-webpack';
14+
import { slateEditor } from '@payloadcms/richtext-slate';
15+
import { mongooseAdapter } from '@payloadcms/db-mongodb';
1416

15-
dotenv.config({
17+
require('dotenv').config({
1618
path: '../../.env',
1719
});
1820

1921
export default buildConfig({
2022
serverURL: process.env.api_url,
23+
db: mongooseAdapter({
24+
url: process.env.mongo_url,
25+
connectOptions: {
26+
user: process.env.mongo_username,
27+
pass: process.env.mongo_password,
28+
dbName: process.env.mongo_db,
29+
},
30+
}),
31+
editor: slateEditor({}),
2132
collections: [
2233
UsersCollection,
2334
CategoriesCollection,
@@ -48,38 +59,43 @@ export default buildConfig({
4859
logout: {
4960
Button: RedirectToFrontendLogoutButton,
5061
},
51-
routes: [
52-
{
62+
views: {
63+
'redirect-to-frontend-login': {
5364
Component: RedirectToFrontendLogin,
5465
path: '/login',
5566
},
56-
],
67+
},
5768
},
69+
bundler: webpackBundler(),
5870
webpack: (config) => ({
5971
...config,
6072
resolve: {
6173
...config.resolve,
6274
alias: {
6375
...config?.resolve?.alias,
64-
'@binarystarter-angular/backend-only/crypto': [
65-
path.resolve('../../libs/backend-only/crypto/src'),
66-
],
67-
'@binarystarter-angular/backend-only/payloadcms': [
68-
path.resolve('../../libs/backend-only/payloadcms/src'),
69-
],
70-
'@binarystarter-angular/shared-types': [
71-
path.resolve('../../libs/shared-types/src'),
72-
],
73-
'@binarystarter-angular/backend-only/utils': [
74-
path.resolve('../../libs/backend-only/utils/src'),
75-
],
76+
// '@binarystarter-angular/backend-only/crypto': [
77+
// path.resolve('../../libs/backend-only/crypto/src'),
78+
// ],
79+
// '@binarystarter-angular/backend-only/payloadcms': [
80+
// path.resolve('../../libs/backend-only/payloadcms/src'),
81+
// ],
82+
// '@binarystarter-angular/shared-types': [
83+
// path.resolve('../../libs/shared-types/src'),
84+
// ],
85+
// '@binarystarter-angular/shared-constants': [
86+
// path.resolve('../../libs/shared-constants/src'),
87+
// ],
88+
// '@binarystarter-angular/backend-only/utils': [
89+
// path.resolve('../../libs/backend-only/utils/src'),
90+
// ],
7691
},
7792
},
7893
}),
7994
},
8095
cors: [process.env.web_url, process.env.api_url],
8196
csrf: [process.env.web_url],
8297
typescript: {
98+
declare: false,
8399
outputFile: path.resolve(
84100
'../',
85101
'../',

apps/express/project.json

+29
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,36 @@
5050
"codeCoverage": true
5151
}
5252
}
53+
},
54+
"payload": {
55+
"executor": "nx:run-commands",
56+
"options": {
57+
"command": "npx payload",
58+
"cwd": "apps/express"
59+
}
60+
},
61+
"payload:migrate": {
62+
"executor": "nx:run-commands",
63+
"options": {
64+
"command": "npx payload migrate",
65+
"cwd": "apps/express"
66+
}
67+
},
68+
"payload:build": {
69+
"executor": "nx:run-commands",
70+
"options": {
71+
"command": "npx payload build",
72+
"cwd": "apps/express"
73+
}
74+
},
75+
"payload:types": {
76+
"executor": "nx:run-commands",
77+
"options": {
78+
"command": "npx payload generate:types && npx payload generate:graphQLSchema",
79+
"cwd": "apps/express"
80+
}
5381
}
5482
},
83+
5584
"tags": []
5685
}

apps/express/src/auth/register.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { UserRoles } from '@binarystarter-angular/backend-only/payloadcms';
1+
import { UserRoles } from 'apps/express/src/payloadcms/src';
22
import { Request, Response } from 'express';
33
import payload from 'payload';
44
import { IUser } from '@binarystarter-angular/shared-types';

apps/express/src/main.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* This is not a production server yet!
33
* This is only a minimal backend to get started.
44
*/
5-
import dotenv from 'dotenv';
65
import express from 'express';
76
import payload from 'payload';
87
import cors from 'cors';
@@ -12,7 +11,7 @@ import { register, registerPath, verifyAccount, verifyPath } from './auth';
1211

1312
const start = async () => {
1413
const app = express();
15-
dotenv.config({
14+
require('dotenv').config({
1615
path: '../../../.env',
1716
});
1817

@@ -44,12 +43,6 @@ const start = async () => {
4443

4544
await payload.init({
4645
secret: process.env.payload_secret,
47-
mongoURL: process.env.mongo_url,
48-
mongoOptions: {
49-
user: process.env.mongo_username,
50-
pass: process.env.mongo_password,
51-
dbName: process.env.mongo_db,
52-
},
5346
express: app,
5447
email: {
5548
fromName: 'binarystarter-angular',
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"outDir": "../../../dist/out-tsc",
6+
"declaration": true,
7+
"resolveJsonModule": true,
8+
"types": ["node"]
9+
},
10+
"exclude": [
11+
"../../../../libs/backend-only/utils/jest.config.ts",
12+
"../../../../libs/backend-only/utils/src/**/*.spec.ts",
13+
"../../../../libs/backend-only/utils/src/**/*.test.ts"
14+
],
15+
"include": ["../../../../libs/backend-only/utils/src/**/*.ts"]
16+
}

apps/web/project.json

+15-73
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
"tags": [],
88
"targets": {
99
"build": {
10-
"executor": "@angular-devkit/build-angular:browser-esbuild",
10+
"executor": "@angular-devkit/build-angular:application",
1111
"outputs": ["{options.outputPath}"],
1212
"options": {
13-
"outputPath": "dist/apps/web/browser/browser",
13+
"outputPath": "dist/apps/web",
1414
"index": "apps/web/src/index.html",
15-
"main": "apps/web/src/main.ts",
15+
"browser": "apps/web/src/main.ts",
1616
"polyfills": ["zone.js"],
1717
"tsConfig": "apps/web/tsconfig.app.json",
1818
"assets": ["apps/web/src/favicon.ico", "apps/web/src/assets"],
@@ -21,7 +21,12 @@
2121
"apps/web/src/styles/variables.css",
2222
"apps/web/src/styles.css"
2323
],
24-
"scripts": []
24+
"scripts": [],
25+
"server": "apps/web/src/main.server.ts",
26+
"prerender": true,
27+
"ssr": {
28+
"entry": "apps/web/server.ts"
29+
}
2530
},
2631
"configurations": {
2732
"production": {
@@ -40,12 +45,9 @@
4045
"outputHashing": "all"
4146
},
4247
"development": {
43-
"buildOptimizer": false,
4448
"optimization": false,
45-
"vendorChunk": true,
4649
"extractLicenses": false,
47-
"sourceMap": true,
48-
"namedChunks": true
50+
"sourceMap": true
4951
}
5052
},
5153
"defaultConfiguration": "production"
@@ -54,22 +56,22 @@
5456
"executor": "@angular-devkit/build-angular:dev-server",
5557
"configurations": {
5658
"production": {
57-
"browserTarget": "web:build:production"
59+
"buildTarget": "web:build:production"
5860
},
5961
"development": {
60-
"browserTarget": "web:build:development"
62+
"buildTarget": "web:build:development"
6163
}
6264
},
6365
"defaultConfiguration": "development"
6466
},
6567
"extract-i18n": {
6668
"executor": "@angular-devkit/build-angular:extract-i18n",
6769
"options": {
68-
"browserTarget": "web:build"
70+
"buildTarget": "web:build"
6971
}
7072
},
7173
"lint": {
72-
"executor": "@nx/linter:eslint",
74+
"executor": "@nx/eslint:lint",
7375
"outputs": ["{options.outputFile}"],
7476
"options": {
7577
"lintFilePatterns": ["apps/web/**/*.ts", "apps/web/**/*.html"]
@@ -79,68 +81,8 @@
7981
"executor": "@nx/jest:jest",
8082
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
8183
"options": {
82-
"jestConfig": "apps/web/jest.config.ts",
83-
"passWithNoTests": true
84-
},
85-
"configurations": {
86-
"ci": {
87-
"ci": true,
88-
"codeCoverage": true
89-
}
84+
"jestConfig": "apps/web/jest.config.ts"
9085
}
91-
},
92-
"server": {
93-
"dependsOn": ["build"],
94-
"executor": "@angular-devkit/build-angular:server",
95-
"options": {
96-
"outputPath": "dist/apps/web/browser/server",
97-
"main": "apps/web/server.ts",
98-
"tsConfig": "apps/web/tsconfig.server.json"
99-
},
100-
"configurations": {
101-
"production": {
102-
"outputHashing": "media"
103-
},
104-
"development": {
105-
"buildOptimizer": false,
106-
"optimization": false,
107-
"sourceMap": true,
108-
"extractLicenses": false,
109-
"vendorChunk": true
110-
}
111-
},
112-
"defaultConfiguration": "production"
113-
},
114-
"serve-ssr": {
115-
"executor": "@nguniversal/builders:ssr-dev-server",
116-
"configurations": {
117-
"development": {
118-
"browserTarget": "web:build:development",
119-
"serverTarget": "web:server:development"
120-
},
121-
"production": {
122-
"browserTarget": "web:build:production",
123-
"serverTarget": "web:server:production"
124-
}
125-
},
126-
"defaultConfiguration": "development"
127-
},
128-
"prerender": {
129-
"executor": "@nguniversal/builders:prerender",
130-
"options": {
131-
"routes": ["/"]
132-
},
133-
"configurations": {
134-
"development": {
135-
"browserTarget": "web:build:development",
136-
"serverTarget": "web:server:development"
137-
},
138-
"production": {
139-
"browserTarget": "web:build:production",
140-
"serverTarget": "web:server:production"
141-
}
142-
},
143-
"defaultConfiguration": "production"
14486
}
14587
}
14688
}

0 commit comments

Comments
 (0)