How to use aspnet-prerendering - 5 common examples

To help you get started, we’ve selected a few aspnet-prerendering examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github VerdantSparks / vuejs-aspnetcore-ssr / ClientApp / renderOnServer.js View on Github external
process.env.VUE_ENV = 'server'

const fs = require('fs')
const path = require('path')

const filePath = path.join(__dirname, '../wwwroot/dist/main-server.js')
const code = fs.readFileSync(filePath, 'utf8')

const vue_renderer = require('vue-server-renderer').createBundleRenderer(code)

//prevent XSS attack when initialize state
var serialize = require('serialize-javascript')
var prerendering = require('aspnet-prerendering')
module.exports = prerendering.createServerRenderer(function (params) {
  return new Promise(
    function (resolve, reject) { 
      // console.log('#prerendering#',params)
      const context = {
        url: params.url,
        absoluteUrl: params.absoluteUrl,
        baseUrl: params.baseUrl,
        data: params.data,
        domainTasks: params.domainTasks,
        location: params.location,
        origin: params.origin,
        xss: serialize("")
      }
      const serverVueAppHtml = vue_renderer.renderToString(context, (err, _html) => {
        if(err) { reject(err.message) }
        resolve({
github Independer / ind-angular-starter / src / shared / ssr / server-only / app-bootstrap.ts View on Github external
export function bootstrapServer(ngModule: Type<{}> | NgModuleFactory<{}>) {
  enableProdMode();

  let renderer = createServerRenderer(params => {
    // Platform-server provider configuration
    const setupOptions: IEngineOptions = {
      appSelector: '',
      ngModule: ngModule,
      request: params,
      providers: [
        // Optional - Any other Server providers you want to pass (remember you'll have to provide them for the Browser as well)
        { provide: ssrDataToken, useValue: params.data },
        { provide: LOCATION, useValue: params.location }
      ]
    };

    return ngAspnetCoreEngine(setupOptions);
  });

  return renderer;
github dotnet / aspnetcore / src / Middleware / NodeServices / samples / NodeServicesExamples / Node / prerenderPage.js View on Github external
var createServerRenderer = require('aspnet-prerendering').createServerRenderer;

module.exports = createServerRenderer(function(params) {
    return new Promise(function (resolve, reject) {
        var message = 'The HTML was returned by the prerendering boot function. '
            + 'The boot function received the following params:'
            + '<pre>' + JSON.stringify(params, null, 4) + '</pre>';

        resolve({
            html: '<h3>Hello, world!</h3>' + message,
            globals: { sampleData: { nodeVersion: process.version } }
        });
    });
});
github oktadeveloper / okta-vuejs-aspnetcore-todo-example / ClientApp / boot-server.js View on Github external
var prerendering = require('aspnet-prerendering');

module.exports = prerendering.createServerRenderer(function (params) {
    return new Promise(function (resolve, reject) {
        var result = '<h1>Loading...</h1>'
            + '<p>Current time in Node is: ' + new Date() + '</p>'
            + '<p>Request path is: ' + params.location.path + '</p>'
            + '<p>Absolute URL is: ' + params.absoluteUrl + '</p>';

        resolve({ html: result });
    });
});
github berkansasmaz / ketum / src / Ketum.Web / ClientApp / boot-server.js View on Github external
var prerendering = require('aspnet-prerendering');

module.exports = prerendering.createServerRenderer(function (params) {
  return new Promise(function (resolve, reject) {
    var result = '<h1>Loading...</h1>' +
            '<p>Current time in Node is: ' + new Date() + '</p>' +
            '<p>Request path is: ' + params.location.path + '</p>' +
            '<p>Absolute URL is: ' + params.absoluteUrl + '</p>';

    resolve({ html: result })
  })
});

aspnet-prerendering

Helpers for server-side rendering of JavaScript applications in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.

Apache-2.0
Latest version published 7 years ago

Package Health Score

52 / 100
Full package analysis

Popular aspnet-prerendering functions

Similar packages