MCPcopy Create free account
hub / github.com/LeetCode-OpenSource/ayanami / SSRModule

Function SSRModule

src/ssr/ssr-module.ts:10–36  ·  view source on GitHub ↗
(config: string | (InjectableConfig & { name: string }))

Source from the content-addressed store, hash-verified

8
9// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
10export const SSRModule = (config: string | (InjectableConfig & { name: string })) => {
11 const injectableConfig: InjectableConfig = { providers: [] }
12 let name: string
13 if (typeof config === 'string') {
14 if (configSets.has(config)) {
15 reportDuplicated(config)
16 }
17 name = config
18 configSets.add(config)
19 } else if (config && typeof config.name === 'string') {
20 if (configSets.has(config.name)) {
21 reportDuplicated(config.name)
22 }
23 configSets.add(config.name)
24 name = config.name
25 Object.assign(injectableConfig, omit(config, 'name'))
26 } else {
27 throw new TypeError(
28 'config in SSRModule type error, support string or InjectableConfig with name',
29 )
30 }
31
32 return (target: any) => {
33 target.prototype[moduleNameKey] = name
34 return Injectable(injectableConfig)(target)
35 }
36}
37
38function reportDuplicated(moduleName: string) {
39 if (process.env.NODE_ENV === 'production') {

Callers 7

CountModelClass · 0.90
TipModelClass · 0.90
ErrorModelClass · 0.90
ModelClass · 0.90
Model2Class · 0.90
ErrorModel1Class · 0.90
ErrorModel2Class · 0.90

Calls 2

reportDuplicatedFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected