• Stars
    star
    547
  • Rank 81,254 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Angular 9 Universal repo with many features

Angular RU Universal Starter Angular-RU Angular-RU Universal

Build Status Build Status

If you like this project please show your support with a GitHub star. Much appreciated!

Repository with Angular CLI and Angular Universal

Translations:

Resources:

Plans:

  • Angular 11
  • document is not defined and window is not defined - here
  • Angular Material2 UI components - individual branch
  • Primeng UI components - [individual branch] (https://github.com/Angular-RU/angular-universal-starter/tree/primeng)
  • modules import depending on the platform (MockServerBrowserModule)
  • execution of queries to api on the server TransferHttp
  • work with cookies on the server UniversalStorage
  • Uses ngx-meta for SEO (title, meta tags, and Open Graph tags for social sharing).
  • uses ngx-translate to support internationalization (i18n)
  • uses ORIGIN_URL - for absolute queries
  • @angular/service-worker(ng add @angular/pwa --project universal-demo)

How to start

  • yarn or npm install
  • yarn start or npm run start - for client rendering
  • yarn ssr or npm run ssr - for server-side rendering
  • yarn build:universal or npm run build:universal - for assembly in release
  • yarn server or npm run server - to start the server
  • yarn build:prerender or npm run build:prerender - to generate static by static.paths.ts
  • for watch with ssr - npm run ssr:watch

How to use this repository in your project:

To transfer ssr to your repository, you need the following files:

  • .angular-cli.json
  • server.ts
  • prerender.ts
  • webpack.config.js
  • main.server.ts
  • main.browser.ts
  • shared/*
  • forStorage/*
  • environments/*
  • app.browser.module.ts
  • app.server.module.ts

References

Official example in English: https://github.com/angular/universal-starter Modules used for universal:

Features (Important)

  • The module for TransferHttp uses import {TransferState} from '@angular/platform-browser'; and it is necessary to implement the request rest api on the server and the absence of the second request a second time. See home.component.ts (delay 3c)
this.http.get('https://reqres.in/api/users?delay=3').subscribe(result => {
    this.result = result;
});
  • export const AppRoutes = RouterModule.forRoot(routes, { initialNavigation: 'enabled' });- so that there is no flashing of the page!

  • to work with cookies, it is written AppStorage, which with DI allows you to give different implementations for the server and the browser. See server.storage.ts and browser.storage.ts for implementations. In server.ts there is

providers: [
    {
        provide: REQUEST, useValue: (req)
    },
    {
        provide: RESPONSE, useValue: (res)
    }
]

to work with REQUEST and RESPONSE via DI - this is necessary for implementing UniversalStorage when working with cookies.

  • webpack.config.js is written exclusively for building server.ts file in server.js, since angular-cli has [bug](https: //github.com / angular/angular-cli/issues/7200) to work with 3d dependencies. - To solve some problems, use the following code in server.ts Solving the problems of global variables, including document is not defined and window is not defined
const domino = require('domino');
const fs = require('fs');
const path = require('path');
const template = fs.readFileSync(path.join(__dirname, '.', 'dist', 'index.html')).toString();
const win = domino.createWindow(template);
const files = fs.readdirSync(`${process.cwd()}/dist-server`);
// const styleFiles = files.filter(file => file.startsWith('styles'));
// const hashStyle = styleFiles[0].split('.')[1];
// const style = fs.readFileSync(path.join(__dirname, '.', 'dist-server', `styles.${hashStyle}.bundle.css`)).toString();

global['window'] = win;
Object.defineProperty(win.document.body.style, 'transform', {
  value: () => {
    return {
      enumerable: true,
      configurable: true
    };
  },
});
global['document'] = win.document;
global['CSS'] = null;
// global['XMLHttpRequest'] = require('xmlhttprequest').XMLHttpRequest;
global['Prism'] = null;
  global['navigator'] = req['headers']['user-agent'];

this allows you to remove some of the problems when working with undefined.

Migrate 5 to 6

More Repositories

1

angular-ru-interview-questions

Вопросы на собеседовании по Angular
371
star
2

angular-awesome-list

Список ресурсов по Angular на русском
294
star
3

angular-quick-starter

Учебные материалы на русском
122
star
4

change-detection-tree

Visual detecting changes in the component tree (View Engine)
TypeScript
76
star
5

angular-ru-sdk

🅰️ ngular-RU Software Development Kit
TypeScript
72
star
6

angular-cli-webpack

Webpack configuration modifier for @angular/cli
TypeScript
67
star
7

webpack-typescript-starter

A simple Webpack starter with TypeScript
JavaScript
37
star
8

angular-storybook-starter

TypeScript
35
star
9

angular-ngrx-starter

TypeScript
32
star
10

angular-logger

Move: https://github.com/Angular-RU/angular-ru-sdk
TypeScript
25
star
11

angular-russia-meetups

Angular Meetups in Russia
22
star
12

angular-nest-starter

A simple Angular with Nest starter kit
TypeScript
15
star
13

angular-weather-app

Проект в рамках курса Codedojo - Angular in Action
TypeScript
10
star
14

autowired

Simple Dependency Injection with Autowired
TypeScript
9
star
15

webpack-angular-starter

Current repo is deprecated, instead usage https://github.com/gdi2290/angular-starter
JavaScript
8
star
16

who-use-angular-in-russia

List of companies using Angular in Russia
6
star
17

angular-clarity-ui-starter

A simple Angular with ClarityUI starter kit
HTML
5
star
18

ngxs-starter

ngxs/store starter
TypeScript
5
star
19

angular-performance-example

Angular JIT vs AOT
JavaScript
5
star
20

redux-demo

TypeScript
5
star
21

angular-table-builder

Data Grid for Angular
TypeScript
5
star
22

angular-ru.github.io

Welcome page
HTML
4
star
23

frontconf-store-wars

4
star
24

angular-sws-library-starter

TypeScript
4
star
25

ngxs-cli

CLI for @ngxs/store
4
star
26

angular-ngx-kit

Boost your Angular development
3
star
27

angular-universal-full-starter

TypeScript
3
star
28

angular-ru-contrib

Angular-RU community extension for Angular
TypeScript
2
star
29

angular-style-guide

Angular / TypeScript projects style guide
2
star
30

angular-ionic-starter

A simple Angular with Ionic starter kit
2
star
31

angular-kendo-ui-starter

Angular CLI starter with KendoUI
TypeScript
2
star
32

angular-ru-ng-table-builder-example-app

DEMO: https://angular-ru.github.io/angular-ru-ng-table-builder-example-app/
HTML
2
star
33

angular-ru-devs

Разработки сообщества (стартеры, пакеты, etc)
2
star
34

angular-eslint-config

Strict ESLint rules for your Angular projects
JavaScript
2
star
35

angular-prettier-config

Shareable Prettier config for Angular projects
TypeScript
2
star
36

angular-renovate-config

Angular-RU Renovate config template
2
star
37

angular-ru-press-kit

2
star
38

.github

1
star
39

ngMoscow

Angular parties in Moscow
1
star
40

angular-reactive-forms-starter

TypeScript
1
star
41

angular-jest-utils

TypeScript
1
star
42

angular-tsconfig

Shared TSconfig options for your Angular projects
1
star
43

angular-team-interview-quiestions

Questions for the interview with the team Angular
1
star