threewebcode / W3

Three Web World
Apache License 2.0
0 stars 0 forks source link

JavaScript Guide #6

Open threewebcode opened 1 year ago

threewebcode commented 1 year ago

Table of Contents

  1. Nest.js
  2. Next.js
threewebcode commented 1 year ago

Next.js Stack:

  1. Configuration

The objects and items can be exported from its definition file. The configuration object is the alias type of record type. The generic type can extend function type. The essence of type statement is to use one token pattern to replace another symbol pattern. That is to say, one thing has more than two formats of syntax. The type expression will be computed during the compilation time and determined its simple construction.

The type can be expressed by the combination of token elements. The concatenation of symbols has its constraints. When it is type declaration statement, it means that two production rules are equal and can be substituted once it is necessary.

The union type operator can give more types to the type name. The interface is used to stand for the options that can be used in the module configuration.

The configuration service is a class with get capability and is injectable as the dependency. The providers and exports are the construction elements of modular class.

threewebcode commented 1 year ago
  1. The Internal Design

The interface can have only fields in its body. The module can be static or dynamic type. The differences between static module and dynamic module is that dynamic module has more metadata in its decoration. The module factory has module type, module token and module metadata. The module has a unique key and the key is combination of module id and module name. The token is the hash value of module key. The module is expressed as a class written in TypeScript language. It does have imports, exports, providers, middlewares, controllers and injectables fields.

The module container is a map data structure and can store the declared modules.

threewebcode commented 1 year ago
  1. Application Context

There are some configuration items for the whole application. These items are represented by the fields of a configuration class in typescript language. The items contain filters, pipes, guards and interceptors. The value of messages and keys can be defined as constant variables. The hooks are the phases of application lifecycle. Some extra actions can be performed during the certain stage of the application. The application context can be specific for each module.

threewebcode commented 1 year ago
  1. Application

The factory design pattern is used for application creation. The application implements the interface constraint and has the application context. The module, microservice and http server are its member fields. The dependency is managed by graph data structure. The node is the metadata of the module and the edge is the relationship between the module.

threewebcode commented 1 year ago

Reflection & Proxy

  1. https://exploringjs.com/deep-js/ch_proxies.html
  2. https://medium.com/jspoint/a-brief-introduction-to-metaprogramming-in-javascript-88d13ed407b5
  3. https://www.freecodecamp.org/news/what-is-metaprogramming-in-javascript-in-english-please/