0.1.6 • Published 2 years ago

@finastra/ssr-pages v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

SSR Pages builder

Builder of html pages for the purpose of SSR (Server-side rendering).

Use it

import { SSRPages } from '@finastra/ssr-pages';

const ssrPagesService = new SSRPages();
const msgPageOpts = {
  title: 'SSR example',
  subtitle: `This is an example of a server-side rendered content`,
  description: 'Built with @finastra/ssr-pages library',
  svg: 'exit' as const,
  redirect: {
    auto: false,
    link: '/user',
    label: 'Check your user',
  },
};
const html = ssrPagesService.build(msgPageOpts);

And use the generated html as you see fit ;)

NestJS

To use it in NestJS, simply create an injectable service that extends the SSRPage class.

import { SSRPages } from '@finastra/ssr-pages';
import { Injectable } from '@nestjs/common';

@Injectable()
export class SSRPagesService extends SSRPages {
  constructor() {
    super();
  }
}

Inject it in a controller, and use it in an endpoint to return the templated html !

constructor(private ssrPagesService: SSRPagesService) {}

@Get('/ssr')
  async ssr(): Promise<string> {
    const msgPageOpts = {
      title: 'SSR example',
      subtitle: `This is an example of a server-side rendered content`,
      description: 'Built with our @finastra/ssr-pages library',
      svg: 'exit' as const,
      redirect: {
        auto: false,
        link: '/user',
        label: 'Check your user',
      },
    };
    return this.ssrPagesService.build(msgPageOpts);
  }
0.1.6

2 years ago

0.1.4

2 years ago

0.1.5

2 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago