Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 53c7af4

Browse files
committed
chore: fix linting
1 parent b3df93b commit 53c7af4

File tree

8 files changed

+770
-769
lines changed

8 files changed

+770
-769
lines changed

libs/isr-move/projects/docs/server.ts

Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,101 @@
1-
import { environment } from './src/environments/environment';
2-
import 'zone.js/dist/zone-node';
3-
4-
import { ngExpressEngine } from '@nguniversal/express-engine';
5-
import * as express from 'express';
6-
import { join } from 'path';
7-
8-
import { existsSync } from 'fs';
9-
10-
import { ISRHandler } from 'ngx-isr/server';
11-
import { RedisCacheHandler } from './redis-cache-handler';
12-
13-
import bootstrap from './src/main.server';
14-
15-
// The Express app is exported so that it can be used by serverless Functions.
16-
export function app(): express.Express {
17-
const server = express();
18-
const distFolder = join(process.cwd(), 'dist/docs/browser');
19-
const indexHtml = existsSync(join(distFolder, 'index.original.html'))
20-
? 'index.original.html'
21-
: 'index';
22-
23-
const REDIS_CONNECTION_STRING = process.env['REDIS_CONNECTION_STRING'] || '';
24-
const INVALIDATE_TOKEN = process.env['INVALIDATE_TOKEN'] || '';
25-
26-
// Step 0 (optional): Create FileSystemCacheHandler with required options.
27-
// const fsCacheHandler = new FileSystemCacheHandler({
28-
// cacheFolderPath: join(distFolder, '/cache'),
29-
// prerenderedPagesPath: distFolder,
30-
// addPrerenderedPagesToCache: true,
31-
// });
32-
33-
const redisCacheHandler = REDIS_CONNECTION_STRING
34-
? new RedisCacheHandler({ connectionString: REDIS_CONNECTION_STRING })
35-
: undefined;
36-
37-
// Step 1: Initialize ISRHandler
38-
const isr = new ISRHandler({
39-
indexHtml,
40-
cache: redisCacheHandler, // we can remove this field if we want to use the default InMemoryCacheHandler
41-
invalidateSecretToken: INVALIDATE_TOKEN || 'MY_TOKEN',
42-
enableLogging: !environment.production,
43-
buildId: environment.buildTimestamp + '',
44-
});
45-
46-
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
47-
server.engine('html', ngExpressEngine({ bootstrap }));
48-
49-
server.set('view engine', 'html');
50-
server.set('views', distFolder);
51-
52-
// needed for post requests in our case we use it for the invalidation url
53-
server.use(express.json());
54-
55-
// Example Express Rest API endpoints
56-
// server.get('/api/**', (req, res) => { });
57-
58-
// Step 2: Add invalidation url handler
59-
server.post('/api/invalidate', async (req, res) => await isr.invalidate(req, res));
60-
61-
// Serve static files from /browser
62-
server.get('*.*', express.static(distFolder, { maxAge: '1y' }));
63-
64-
// Step 3: handle rendering and serving using ISR handler
65-
server.get(
66-
'*',
67-
// Serve page if it exists in cache
68-
async (req, res, next) => await isr.serveFromCache(req, res, next),
69-
// Server side render the page and add to cache if needed
70-
async (req, res, next) => await isr.render(req, res, next)
71-
);
72-
73-
// Step 4: Comment out default angular universal handler, because it's will be handled in ISR render method
74-
// (req, res) => {
75-
// res.render(indexHtml, { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
76-
// }
77-
78-
return server;
79-
}
80-
81-
function run(): void {
82-
const port = process.env['PORT'] || 4000;
83-
84-
// Start up the Node server
85-
const server = app();
86-
server.listen(port, () => {
87-
console.log(`Node Express server listening on http://localhost:${port}`);
88-
});
89-
}
90-
91-
// Webpack will replace 'require' with '__webpack_require__'
92-
// '__non_webpack_require__' is a proxy to Node 'require'
93-
// The below code is to ensure that the server is run only when not requiring the bundle.
94-
declare const __non_webpack_require__: NodeRequire;
95-
const mainModule = __non_webpack_require__.main;
96-
const moduleFilename = (mainModule && mainModule.filename) || '';
97-
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
98-
run();
99-
}
100-
101-
export * from './src/main.server';
1+
// import { environment } from './src/environments/environment';
2+
// import 'zone.js/dist/zone-node';
3+
//
4+
// import { ngExpressEngine } from '@nguniversal/express-engine';
5+
// import * as express from 'express';
6+
// import { join } from 'path';
7+
//
8+
// import { existsSync } from 'fs';
9+
//
10+
// import { ISRHandler } from 'ngx-isr/server';
11+
// import { RedisCacheHandler } from './redis-cache-handler';
12+
//
13+
// import bootstrap from './src/main.server';
14+
//
15+
// // The Express app is exported so that it can be used by serverless Functions.
16+
// export function app(): express.Express {
17+
// const server = express();
18+
// const distFolder = join(process.cwd(), 'dist/docs/browser');
19+
// const indexHtml = existsSync(join(distFolder, 'index.original.html'))
20+
// ? 'index.original.html'
21+
// : 'index';
22+
//
23+
// const REDIS_CONNECTION_STRING = process.env['REDIS_CONNECTION_STRING'] || '';
24+
// const INVALIDATE_TOKEN = process.env['INVALIDATE_TOKEN'] || '';
25+
//
26+
// // Step 0 (optional): Create FileSystemCacheHandler with required options.
27+
// // const fsCacheHandler = new FileSystemCacheHandler({
28+
// // cacheFolderPath: join(distFolder, '/cache'),
29+
// // prerenderedPagesPath: distFolder,
30+
// // addPrerenderedPagesToCache: true,
31+
// // });
32+
//
33+
// const redisCacheHandler = REDIS_CONNECTION_STRING
34+
// ? new RedisCacheHandler({ connectionString: REDIS_CONNECTION_STRING })
35+
// : undefined;
36+
//
37+
// // Step 1: Initialize ISRHandler
38+
// const isr = new ISRHandler({
39+
// indexHtml,
40+
// cache: redisCacheHandler, // we can remove this field if we want to use the default InMemoryCacheHandler
41+
// invalidateSecretToken: INVALIDATE_TOKEN || 'MY_TOKEN',
42+
// enableLogging: !environment.production,
43+
// buildId: environment.buildTimestamp + '',
44+
// });
45+
//
46+
// // Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
47+
// server.engine('html', ngExpressEngine({ bootstrap }));
48+
//
49+
// server.set('view engine', 'html');
50+
// server.set('views', distFolder);
51+
//
52+
// // needed for post requests in our case we use it for the invalidation url
53+
// server.use(express.json());
54+
//
55+
// // Example Express Rest API endpoints
56+
// // server.get('/api/**', (req, res) => { });
57+
//
58+
// // Step 2: Add invalidation url handler
59+
// server.post('/api/invalidate', async (req, res) => await isr.invalidate(req, res));
60+
//
61+
// // Serve static files from /browser
62+
// server.get('*.*', express.static(distFolder, { maxAge: '1y' }));
63+
//
64+
// // Step 3: handle rendering and serving using ISR handler
65+
// server.get(
66+
// '*',
67+
// // Serve page if it exists in cache
68+
// async (req, res, next) => await isr.serveFromCache(req, res, next),
69+
// // Server side render the page and add to cache if needed
70+
// async (req, res, next) => await isr.render(req, res, next)
71+
// );
72+
//
73+
// // Step 4: Comment out default angular universal handler, because it's will be handled in ISR render method
74+
// // (req, res) => {
75+
// // res.render(indexHtml, { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
76+
// // }
77+
//
78+
// return server;
79+
// }
80+
//
81+
// function run(): void {
82+
// const port = process.env['PORT'] || 4000;
83+
//
84+
// // Start up the Node server
85+
// const server = app();
86+
// server.listen(port, () => {
87+
// console.log(`Node Express server listening on http://localhost:${port}`);
88+
// });
89+
// }
90+
//
91+
// // Webpack will replace 'require' with '__webpack_require__'
92+
// // '__non_webpack_require__' is a proxy to Node 'require'
93+
// // The below code is to ensure that the server is run only when not requiring the bundle.
94+
// declare const __non_webpack_require__: NodeRequire;
95+
// const mainModule = __non_webpack_require__.main;
96+
// const moduleFilename = (mainModule && mainModule.filename) || '';
97+
// if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
98+
// run();
99+
// }
100+
//
101+
// export * from './src/main.server';
Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
import { TitleStrategy, provideRouter } from '@angular/router';
2-
import { HIGHLIGHT_OPTIONS } from 'ngx-highlightjs';
3-
import { CustomTitleStrategy } from './custom-title-strategy';
4-
import { routes } from './routes';
5-
import {
6-
APP_ID,
7-
ApplicationConfig,
8-
PLATFORM_ID,
9-
PLATFORM_INITIALIZER,
10-
inject,
11-
} from '@angular/core';
12-
import { provideHttpClient } from '@angular/common/http';
13-
import { isPlatformServer } from '@angular/common';
14-
import {
15-
injectAnalyticsScript,
16-
ANALYTICS_TRACK_ID,
17-
trackRouterEvents,
18-
} from './analytics/inject-analytics-script';
19-
import { provideClientHydration } from '@angular/platform-browser';
20-
21-
export const appConfig: ApplicationConfig = {
22-
providers: [
23-
provideRouter(routes),
24-
provideHttpClient(),
25-
provideClientHydration(),
26-
{ provide: TitleStrategy, useClass: CustomTitleStrategy },
27-
{
28-
provide: HIGHLIGHT_OPTIONS,
29-
useValue: {
30-
coreLibraryLoader: () => import('highlight.js/lib/core'),
31-
languages: {
32-
typescript: () => import('highlight.js/lib/languages/typescript'),
33-
},
34-
},
35-
},
36-
{
37-
provide: PLATFORM_INITIALIZER,
38-
useFactory: () => {
39-
const isServer = isPlatformServer(inject(PLATFORM_ID));
40-
// we don't want to inject the script on the server side
41-
if (!isServer) {
42-
injectAnalyticsScript({ gaTrackId: ANALYTICS_TRACK_ID });
43-
trackRouterEvents();
44-
}
45-
},
46-
multi: true,
47-
},
48-
],
49-
};
1+
// import { TitleStrategy, provideRouter } from '@angular/router';
2+
// import { HIGHLIGHT_OPTIONS } from 'ngx-highlightjs';
3+
// import { CustomTitleStrategy } from './custom-title-strategy';
4+
// import { routes } from './routes';
5+
// import {
6+
// APP_ID,
7+
// ApplicationConfig,
8+
// PLATFORM_ID,
9+
// PLATFORM_INITIALIZER,
10+
// inject,
11+
// } from '@angular/core';
12+
// import { provideHttpClient } from '@angular/common/http';
13+
// import { isPlatformServer } from '@angular/common';
14+
// import {
15+
// injectAnalyticsScript,
16+
// ANALYTICS_TRACK_ID,
17+
// trackRouterEvents,
18+
// } from './analytics/inject-analytics-script';
19+
// import { provideClientHydration } from '@angular/platform-browser';
20+
//
21+
// export const appConfig: ApplicationConfig = {
22+
// providers: [
23+
// provideRouter(routes),
24+
// provideHttpClient(),
25+
// provideClientHydration(),
26+
// { provide: TitleStrategy, useClass: CustomTitleStrategy },
27+
// {
28+
// provide: HIGHLIGHT_OPTIONS,
29+
// useValue: {
30+
// coreLibraryLoader: () => import('highlight.js/lib/core'),
31+
// languages: {
32+
// typescript: () => import('highlight.js/lib/languages/typescript'),
33+
// },
34+
// },
35+
// },
36+
// {
37+
// provide: PLATFORM_INITIALIZER,
38+
// useFactory: () => {
39+
// const isServer = isPlatformServer(inject(PLATFORM_ID));
40+
// // we don't want to inject the script on the server side
41+
// if (!isServer) {
42+
// injectAnalyticsScript({ gaTrackId: ANALYTICS_TRACK_ID });
43+
// trackRouterEvents();
44+
// }
45+
// },
46+
// multi: true,
47+
// },
48+
// ],
49+
// };

0 commit comments

Comments
 (0)