mirror of https://github.com/abpframework/abp.git
8 changed files with 297 additions and 52 deletions
@ -0,0 +1,11 @@ |
|||
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core'; |
|||
import { provideServerRendering } from '@angular/platform-server'; |
|||
import { appConfig } from './app.config'; |
|||
|
|||
const serverConfig: ApplicationConfig = { |
|||
providers: [ |
|||
provideServerRendering() |
|||
] |
|||
}; |
|||
|
|||
export const config = mergeApplicationConfig(appConfig, serverConfig); |
|||
@ -0,0 +1,7 @@ |
|||
import { bootstrapApplication } from '@angular/platform-browser'; |
|||
import { AppComponent } from './app/app.component'; |
|||
import { config } from './app/app.config.server'; |
|||
|
|||
const bootstrap = () => bootstrapApplication(AppComponent, config); |
|||
|
|||
export default bootstrap; |
|||
@ -0,0 +1,69 @@ |
|||
import 'zone.js/node'; |
|||
|
|||
import { APP_BASE_HREF } from '@angular/common'; |
|||
import { CommonEngine } from '@angular/ssr/node'; |
|||
import express from 'express'; |
|||
import { existsSync } from 'node:fs'; |
|||
import { join } from 'node:path'; |
|||
import bootstrap from './main.server'; |
|||
|
|||
// The Express app is exported so that it can be used by serverless Functions.
|
|||
export function app(): express.Express { |
|||
const server = express(); |
|||
const distFolder = join(process.cwd(), 'dist/dev-app/browser'); |
|||
const indexHtml = existsSync(join(distFolder, 'index.original.html')) |
|||
? join(distFolder, 'index.original.html') |
|||
: join(distFolder, 'index.html'); |
|||
|
|||
const commonEngine = new CommonEngine(); |
|||
|
|||
server.set('view engine', 'html'); |
|||
server.set('views', distFolder); |
|||
|
|||
// Example Express Rest API endpoints
|
|||
// server.get('/api/**', (req, res) => { });
|
|||
// Serve static files from /browser
|
|||
server.get('*.*', express.static(distFolder, { |
|||
maxAge: '1y' |
|||
})); |
|||
|
|||
// All regular routes use the Angular engine
|
|||
server.get('*', (req, res, next) => { |
|||
const { protocol, originalUrl, baseUrl, headers } = req; |
|||
|
|||
commonEngine |
|||
.render({ |
|||
bootstrap, |
|||
documentFilePath: indexHtml, |
|||
url: `${protocol}://${headers.host}${originalUrl}`, |
|||
publicPath: distFolder, |
|||
providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }], |
|||
}) |
|||
.then((html) => res.send(html)) |
|||
.catch((err) => next(err)); |
|||
}); |
|||
|
|||
return server; |
|||
} |
|||
|
|||
function run(): void { |
|||
const port = process.env['PORT'] || 4000; |
|||
|
|||
// Start up the Node server
|
|||
const server = app(); |
|||
server.listen(port, () => { |
|||
console.log(`Node Express server listening on http://localhost:${port}`); |
|||
}); |
|||
} |
|||
|
|||
// Webpack will replace 'require' with '__webpack_require__'
|
|||
// '__non_webpack_require__' is a proxy to Node 'require'
|
|||
// The below code is to ensure that the server is run only when not requiring the bundle.
|
|||
declare const __non_webpack_require__: NodeRequire; |
|||
const mainModule = __non_webpack_require__.main; |
|||
const moduleFilename = mainModule && mainModule.filename || ''; |
|||
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) { |
|||
run(); |
|||
} |
|||
|
|||
export default bootstrap; |
|||
@ -0,0 +1,16 @@ |
|||
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ |
|||
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ |
|||
{ |
|||
"extends": "./tsconfig.app.json", |
|||
"compilerOptions": { |
|||
"outDir": "../../out-tsc/server", |
|||
"types": [ |
|||
"node", |
|||
"@angular/localize" |
|||
] |
|||
}, |
|||
"files": [ |
|||
"src/main.server.ts", |
|||
"src/server.ts" |
|||
] |
|||
} |
|||
@ -1,19 +1,80 @@ |
|||
{ |
|||
"migrations": [ |
|||
{ |
|||
"version": "20.3.0-beta.1", |
|||
"description": "Update ESLint flat config to include .cjs, .mjs, .cts, and .mts files in overrides (if needed)", |
|||
"implementation": "./src/migrations/update-20-3-0/add-file-extensions-to-overrides", |
|||
"package": "@nx/eslint", |
|||
"name": "add-file-extensions-to-overrides" |
|||
"version": "21.0.0-beta.8", |
|||
"description": "Removes the legacy cache configuration from nx.json", |
|||
"implementation": "./src/migrations/update-21-0-0/remove-legacy-cache", |
|||
"package": "nx", |
|||
"name": "remove-legacy-cache" |
|||
}, |
|||
{ |
|||
"version": "21.0.0-beta.8", |
|||
"description": "Removes the legacy cache configuration from nx.json", |
|||
"implementation": "./src/migrations/update-21-0-0/remove-custom-tasks-runner", |
|||
"package": "nx", |
|||
"name": "remove-custom-tasks-runner" |
|||
}, |
|||
{ |
|||
"version": "21.0.0-beta.11", |
|||
"description": "Updates release version config based on the breaking changes in Nx v21", |
|||
"implementation": "./src/migrations/update-21-0-0/release-version-config-changes", |
|||
"package": "nx", |
|||
"name": "release-version-config-changes" |
|||
}, |
|||
{ |
|||
"version": "21.0.0-beta.11", |
|||
"description": "Updates release changelog config based on the breaking changes in Nx v21", |
|||
"implementation": "./src/migrations/update-21-0-0/release-changelog-config-changes", |
|||
"package": "nx", |
|||
"name": "release-changelog-config-changes" |
|||
}, |
|||
{ |
|||
"version": "21.0.0-beta.10", |
|||
"description": "Removes the `tsConfig` and `copyFiles` options from the `@nx/cypress:cypress` executor.", |
|||
"implementation": "./src/migrations/update-21-0-0/remove-tsconfig-and-copy-files-options-from-cypress-executor", |
|||
"package": "@nx/cypress", |
|||
"name": "remove-tsconfig-and-copy-files-options-from-cypress-executor" |
|||
}, |
|||
{ |
|||
"cli": "nx", |
|||
"version": "21.0.0-beta.9", |
|||
"description": "Replace usage of `getJestProjects` with `getJestProjectsAsync`.", |
|||
"implementation": "./src/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync", |
|||
"package": "@nx/jest", |
|||
"name": "replace-getJestProjects-with-getJestProjectsAsync-v21" |
|||
}, |
|||
{ |
|||
"version": "21.0.0-beta.10", |
|||
"description": "Remove the previously deprecated and unused `tsConfig` option from the `@nx/jest:jest` executor.", |
|||
"implementation": "./src/migrations/update-21-0-0/remove-tsconfig-option-from-jest-executor", |
|||
"package": "@nx/jest", |
|||
"name": "remove-tsconfig-option-from-jest-executor" |
|||
}, |
|||
{ |
|||
"cli": "nx", |
|||
"version": "20.4.0-beta.1", |
|||
"requires": { "@angular/core": ">=19.1.0" }, |
|||
"description": "Update the @angular/cli package version to ~19.1.0.", |
|||
"factory": "./src/migrations/update-20-4-0/update-angular-cli", |
|||
"package": "@nx/angular", |
|||
"name": "update-angular-cli-version-19-1-0" |
|||
}, |
|||
{ |
|||
"cli": "nx", |
|||
"version": "20.5.0-beta.5", |
|||
"requires": { "@angular/core": ">=19.2.0" }, |
|||
"description": "Update the @angular/cli package version to ~19.2.0.", |
|||
"factory": "./src/migrations/update-20-5-0/update-angular-cli", |
|||
"package": "@nx/angular", |
|||
"name": "update-angular-cli-version-19-2-0" |
|||
}, |
|||
{ |
|||
"cli": "nx", |
|||
"version": "20.3.0-beta.2", |
|||
"description": "If workspace includes Module Federation projects, ensure the new @nx/module-federation package is installed.", |
|||
"factory": "./src/migrations/update-20-3-0/ensure-nx-module-federation-package", |
|||
"version": "21.0.0-beta.3", |
|||
"description": "Set the `continuous` option to `true` for continuous tasks.", |
|||
"factory": "./src/migrations/update-21-0-0/set-continuous-option", |
|||
"package": "@nx/angular", |
|||
"name": "ensure-nx-module-federation-package" |
|||
"name": "set-continuous-option" |
|||
} |
|||
] |
|||
} |
|||
|
|||
Loading…
Reference in new issue