{"id":13836129,"url":"https://github.com/exequiel09/fastify-angular-universal","last_synced_at":"2025-07-10T13:31:43.256Z","repository":{"id":57233255,"uuid":"110308833","full_name":"exequiel09/fastify-angular-universal","owner":"exequiel09","description":"Angular Universal integration to Fastify for rendering Angular apps on the server","archived":false,"fork":false,"pushed_at":"2018-12-03T19:00:45.000Z","size":185,"stargazers_count":23,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-24T21:02:09.857Z","etag":null,"topics":["angular","angular-universal","fastify","fastifyjs-plugin","server-side-rendering"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/fastify-angular-universal","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/exequiel09.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-11T01:36:01.000Z","updated_at":"2023-08-14T19:01:35.000Z","dependencies_parsed_at":"2022-08-31T14:11:26.318Z","dependency_job_id":null,"html_url":"https://github.com/exequiel09/fastify-angular-universal","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exequiel09%2Ffastify-angular-universal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exequiel09%2Ffastify-angular-universal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exequiel09%2Ffastify-angular-universal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exequiel09%2Ffastify-angular-universal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exequiel09","download_url":"https://codeload.github.com/exequiel09/fastify-angular-universal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225638958,"owners_count":17500656,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","angular-universal","fastify","fastifyjs-plugin","server-side-rendering"],"created_at":"2024-08-04T15:00:36.299Z","updated_at":"2024-11-20T22:31:56.629Z","avatar_url":"https://github.com/exequiel09.png","language":"TypeScript","readme":"# fastify-angular-universal\n\n[![Master - Build Status][img-travis-master]][link-travis]\n[![Master - Build Status][img-appveyor-master]][link-appveyor-master]\n[![LICENSE][img-license]][link-license]\n\nAngular server-side rendering support for Fastify using Angular Universal.\n\n## Install\n\n``\nnpm install --save fastify-angular-universal\n``\n\n## Usage\n\nAdd it to you project with `register` and pass the required options.\n\nFollow the tutorial on how to perform SSR in Angular with Angular CLI [here][link-angular-cli-universal-rendering] ONLY UNTIL step 3.\n\nFor the steps 4 and onwards use the following `server.ts` or check out the [`server.ts`][link-server-ts] in the test-app directory\n\n```typescript\n// These are important and needed before anything else\nimport 'zone.js/dist/zone-node';\nimport 'reflect-metadata';\n\nimport { join } from 'path';\nimport { readFileSync } from 'fs';\n\nimport { enableProdMode } from '@angular/core';\nimport * as fastify from 'fastify';\n\n// * NOTE :: leave this as require() since this file is built Dynamically from webpack\nconst { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/\u003cyour-project-name-here\u003e-server/main');\nconst { provideModuleMap } = require('@nguniversal/module-map-ngfactory-loader');\n\n// Faster server renders w/ Prod mode (dev mode never needed)\nenableProdMode();\n\nconst PORT = process.env.PORT || 3000;\nconst DIST_FOLDER = join(process.cwd(), 'dist');\n\n// Our index.html we'll use as our template\nconst template = readFileSync(join(DIST_FOLDER, '\u003cyour-project-name-here\u003e', 'index.html')).toString();\n\nconst app = fastify();\n\napp.register(require('fastify-static'), {\n  root: join(DIST_FOLDER, '\u003cyour-project-name-here\u003e'),\n  prefix: '/static/'\n});\n\n// register the fastify-angular-universal to your application together with the required options\napp.register(require('fastify-angular-universal'), {\n  serverModule: AppServerModuleNgFactory,\n  document: template,\n  extraProviders: [\n    provideModuleMap(LAZY_MODULE_MAP)\n  ]\n});\n\n// Declare a route\napp.get('/*', function (request, reply) {\n  // NOTE: you can also pass the options for the fastify-angular-universal fastify plugin \n  //       as second parameter to the `.renderNg()` function.\n  // \n  //       Example: `reply.renderNg(url, options)`\n  (reply as any).renderNg(request.req.url);\n});\n\n// Run the server!\napp.listen(PORT, function (err) {\n  if (err) {\n    throw err;\n  }\n\n  console.log(`server listening on ${app.server.address().port}`);\n});\n```\n\n## Options\n\nThis plugin allow you to specify options:\n\n- `serverModule` to specify the NgModuleFactory to be used in rendering an Angular app in the server\n- `document` to specify the template where the Angular app will be rendered\n- `extraProviders` to specify additional providers to be used by the Angular app. (optional)\n\n## License\n\n[MIT][link-license].\n\n\u003c!-- [Images] ::start --\u003e\n[img-travis-master]: https://travis-ci.org/exequiel09/fastify-angular-universal.svg?branch=master\n[img-appveyor-master]: https://ci.appveyor.com/api/projects/status/5hg5qsav8q2xjqah/branch/master?svg=true\n[img-license]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square\n\u003c!-- [Images] ::end --\u003e\n\n\n\u003c!-- [Links] ::start --\u003e\n[link-license]: ./LICENSE\n[link-travis]: https://travis-ci.org/exequiel09/fastify-angular-universal\n[link-appveyor-master]: https://ci.appveyor.com/project/exequiel09/fastify-angular-universal/branch/master\n[link-angular-cli-universal-rendering]: https://github.com/angular/angular-cli/wiki/stories-universal-rendering\n[link-server-ts]: https://github.com/exequiel09/fastify-angular-universal/blob/master/test-app/server.ts\n\u003c!-- [Links] ::end --\u003e\n\n\n","funding_links":[],"categories":["\u003ch2 align=\"center\"\u003eAwesome Fastify\u003c/h2\u003e"],"sub_categories":["\u003ch2 align=\"center\"\u003eEcosystem\u003c/h2\u003e"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexequiel09%2Ffastify-angular-universal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexequiel09%2Ffastify-angular-universal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexequiel09%2Ffastify-angular-universal/lists"}