MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / app

Function app

packages/angular/test/apps/ng18/server.ts:12–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10
11// The Express app is exported so that it can be used by serverless Functions.
12export function app(): express.Express {
13 const server = express();
14 const distFolder = join(process.cwd(), 'dist/test-app/browser');
15 const indexHtml = existsSync(join(distFolder, 'index.original.html'))
16 ? join(distFolder, 'index.original.html')
17 : join(distFolder, 'index.html');
18
19 const commonEngine = new CommonEngine();
20
21 server.set('view engine', 'html');
22 server.set('views', distFolder);
23
24 // Example Express Rest API endpoints
25 // server.get('/api/**', (req, res) => { });
26 // Serve static files from /browser
27 server.get('*.*', express.static(distFolder, {
28 maxAge: '1y'
29 }));
30
31 // All regular routes use the Angular engine
32 server.get('*', (req, res, next) => {
33 const { protocol, originalUrl, baseUrl, headers } = req;
34
35 commonEngine
36 .render({
37 bootstrap,
38 documentFilePath: indexHtml,
39 url: `${protocol}://${headers.host}${originalUrl}`,
40 publicPath: distFolder,
41 providers: [
42 { provide: APP_BASE_HREF, useValue: baseUrl },],
43 })
44 .then((html) => res.send(html))
45 .catch((err) => next(err));
46 });
47
48 return server;
49}
50
51function run(): void {
52 const port = process.env['PORT'] || 4000;

Callers 1

runFunction · 0.70

Calls 3

setMethod · 0.80
getMethod · 0.65
renderMethod · 0.45

Tested by

no test coverage detected