-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add more variants of known/default server.ts (#229)
- Loading branch information
Showing
5 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"9f8b128c01e925b1187ddab7af26f3a9e84f2aefb34af7f8e14b7b4386edf87d": "CommonEngine", | ||
"eb938d816e6a680b8b52174cac4b0c53a101e40076a18dba7997b284165fb227": "CommonEngine", | ||
"0e451aa946aca10c9d6782ac008748fcd39236d3ad1cc9868100a2981105e010": "CommonEngine", | ||
"577f7bc87c16bd10bac499e228ef24d23dc4dd516e469b5db3eefae4edcf6345": "CommonEngine", | ||
"5678601ed12556305074503967b44ae42c45c268579db057c25cbf4b21a7212e": "CommonEngine", | ||
"76419eb94b4b8672ba3bd79d34c5a66c7c30ff173995ecc6e0adc5808b86822d": "AppEngine" | ||
} |
56 changes: 56 additions & 0 deletions
56
tools/known-server-ts-signatures/CommonEngine/17.3.11-migrated-to-19.0.0.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { APP_BASE_HREF } from '@angular/common'; | ||
import { CommonEngine } from '@angular/ssr/node'; | ||
import express from 'express'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { dirname, join, resolve } from 'node:path'; | ||
import bootstrap from './src/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 serverDistFolder = dirname(fileURLToPath(import.meta.url)); | ||
const browserDistFolder = resolve(serverDistFolder, '../browser'); | ||
const indexHtml = join(serverDistFolder, 'index.server.html'); | ||
|
||
const commonEngine = new CommonEngine(); | ||
|
||
server.set('view engine', 'html'); | ||
server.set('views', browserDistFolder); | ||
|
||
// Example Express Rest API endpoints | ||
// server.get('/api/**', (req, res) => { }); | ||
// Serve static files from /browser | ||
server.get('*.*', express.static(browserDistFolder, { | ||
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: browserDistFolder, | ||
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}`); | ||
}); | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { APP_BASE_HREF } from '@angular/common'; | ||
import { CommonEngine } from '@angular/ssr'; | ||
import express from 'express'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { dirname, join, resolve } from 'node:path'; | ||
import bootstrap from './src/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 serverDistFolder = dirname(fileURLToPath(import.meta.url)); | ||
const browserDistFolder = resolve(serverDistFolder, '../browser'); | ||
const indexHtml = join(serverDistFolder, 'index.server.html'); | ||
|
||
const commonEngine = new CommonEngine(); | ||
|
||
server.set('view engine', 'html'); | ||
server.set('views', browserDistFolder); | ||
|
||
// Example Express Rest API endpoints | ||
// server.get('/api/**', (req, res) => { }); | ||
// Serve static files from /browser | ||
server.get('*.*', express.static(browserDistFolder, { | ||
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: browserDistFolder, | ||
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}`); | ||
}); | ||
} | ||
|
||
run(); |
57 changes: 57 additions & 0 deletions
57
tools/known-server-ts-signatures/CommonEngine/18.2.12-migrated-to-19.0.0.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { APP_BASE_HREF } from '@angular/common'; | ||
import { CommonEngine } from '@angular/ssr/node'; | ||
import express from 'express'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { dirname, join, resolve } from 'node:path'; | ||
import bootstrap from './src/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 serverDistFolder = dirname(fileURLToPath(import.meta.url)); | ||
const browserDistFolder = resolve(serverDistFolder, '../browser'); | ||
const indexHtml = join(serverDistFolder, 'index.server.html'); | ||
|
||
const commonEngine = new CommonEngine(); | ||
|
||
server.set('view engine', 'html'); | ||
server.set('views', browserDistFolder); | ||
|
||
// Example Express Rest API endpoints | ||
// server.get('/api/**', (req, res) => { }); | ||
// Serve static files from /browser | ||
server.get('**', express.static(browserDistFolder, { | ||
maxAge: '1y', | ||
index: 'index.html', | ||
})); | ||
|
||
// 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: browserDistFolder, | ||
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}`); | ||
}); | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { APP_BASE_HREF } from '@angular/common'; | ||
import { CommonEngine } from '@angular/ssr'; | ||
import express from 'express'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { dirname, join, resolve } from 'node:path'; | ||
import bootstrap from './src/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 serverDistFolder = dirname(fileURLToPath(import.meta.url)); | ||
const browserDistFolder = resolve(serverDistFolder, '../browser'); | ||
const indexHtml = join(serverDistFolder, 'index.server.html'); | ||
|
||
const commonEngine = new CommonEngine(); | ||
|
||
server.set('view engine', 'html'); | ||
server.set('views', browserDistFolder); | ||
|
||
// Example Express Rest API endpoints | ||
// server.get('/api/**', (req, res) => { }); | ||
// Serve static files from /browser | ||
server.get('**', express.static(browserDistFolder, { | ||
maxAge: '1y', | ||
index: 'index.html', | ||
})); | ||
|
||
// 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: browserDistFolder, | ||
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}`); | ||
}); | ||
} | ||
|
||
run(); |