GithubHelp home page GithubHelp logo

angular-server-services's Introduction

Angular Server Services ๐Ÿ‘

This project presents an example of Angular Server Services implementation, utilizing proxying for client services to make RPC (Remote Procedure Calls) to the server service. The goal of this example is to demonstrate how easily these services can be auto-generated, potentially reducing half of your existing codebase.

Whats used in the repo:

  • Angular 16
  • Standalone Components
  • Universal
  • Hydration
  • NgExpressEngine
  • Custom Webpack

Please note, we are currently using injection-js to bypass the Angular injector and micotask to force zone.js to wait on the server-side. This workarounds are only needed to workaround how Angular bootstraps and manages the apps on the server. I am also creating my own TransferState service just for this demo.

Why

The goal is to replicate GraphQL or RSC by moving all domain logic that lives in these services to the server. We want to do this so we can utilize caching on the server and remove all client code for these services (usually half your codebase)

Angular can easily support this pattern in Angular Universal with little effort.

Start

$ npm install
$ npm run dev:ssr

go to localhost

Screenshot 2023-05-30 at 7 32 35 PM

Initial load uses transfer state. When you navigate to another page the back to Home we will make an RPC to get the updated state

If we had Angular support then the api would look like this (a lot less code)

Production ready version

  • WIP #2
  • Preview
Screen.Recording.2023-06-07.at.11.42.34.PM.mov

TODO: production ready version

  • use webpack to auto-generate ServerServices
  • create @server folder in src that will be all server services and components
  • use angular TransferState
  • batch client requests
  • batch server requests
  • server commponents
  • hook into router to batch requests for server components
  • mixed server in client components and vice versa
  • server and client caching
  • UI over http

angular-server-services's People

Contributors

patrickjs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

biophoton

angular-server-services's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.