@@ -18,7 +18,12 @@ export abstract class ServiceBundle<R, C> implements Service<R, C> {
1818 public core : NodeCGIOCore | undefined ;
1919 public nodecg : NodeCG ;
2020 public serviceType : string ;
21- public schema : any ;
21+ public schema : unknown ;
22+
23+ /**
24+ * The default value for the config.
25+ */
26+ public defaultConfig ?: R ;
2227
2328 /**
2429 * This constructor creates the service and gets the nodecg-io-core
@@ -31,7 +36,7 @@ export abstract class ServiceBundle<R, C> implements Service<R, C> {
3136 this . serviceType = serviceName ;
3237 this . schema = this . readSchema ( pathSegments ) ;
3338
34- this . nodecg . log . info ( this . serviceType + " bundle started" ) ;
39+ this . nodecg . log . info ( this . serviceType + " bundle started. " ) ;
3540 this . core = ( this . nodecg . extensions [ "nodecg-io-core" ] as unknown ) as NodeCGIOCore | undefined ;
3641 if ( this . core === undefined ) {
3742 this . nodecg . log . error (
@@ -40,16 +45,16 @@ export abstract class ServiceBundle<R, C> implements Service<R, C> {
4045 }
4146 }
4247
48+ /**
49+ * Registers this service bundle at the core bundle, makes it appear in the GUI and makes it usable.
50+ * @return a service provider for this service, can be used by bundles to depend on this service.
51+ */
4352 public register ( ) : ServiceProvider < C > | undefined {
44- if ( this . core === undefined ) {
45- return undefined ;
46- } else {
47- // Hide nodecg variable from serialization.
48- // The service is saved in a Replicant and nodecg tries to serialize everything in there, including
49- // nodecg instances, which throw errors when serialized.
50- Object . defineProperty ( this , "nodecg" , { enumerable : false } ) ;
51- return this . core . registerService ( this ) ;
52- }
53+ // Hide nodecg variable from serialization.
54+ // The service is saved in a Replicant and nodecg tries to serialize everything in there, including
55+ // nodecg instances, which throw errors when serialized.
56+ Object . defineProperty ( this , "nodecg" , { enumerable : false } ) ;
57+ return this . core ?. registerService ( this ) ;
5358 }
5459
5560 /**
@@ -77,7 +82,7 @@ export abstract class ServiceBundle<R, C> implements Service<R, C> {
7782 */
7883 abstract stopClient ( client : C ) : void ;
7984
80- private readSchema ( pathSegments : string [ ] ) {
85+ private readSchema ( pathSegments : string [ ] ) : unknown {
8186 const joinedPath = path . resolve ( ...pathSegments ) ;
8287 try {
8388 const fileContent = fs . readFileSync ( joinedPath , "utf8" ) ;
0 commit comments