import { Component } from '@appt/core';

It is a class decorator responsible for the application's logic programming. There is where you are going to put your code. For Appt, it does not really matters what your components are. Unless you modify a behaviour using a Special-Type Extender, it only cares if it's a piece of implementation which you want inject or use on/by somewhere else.

An @Component has the following syntax and options:

import { Component, TDatabase } from '@appt/core';
import { database } from '@appt/core/config';
import { Mongoose } from '@appt/mongoose';
extend: TDatabase(Mongoose, database.uri, database.options),
inject: 'HelpersComponent'
export class AppDatabase {
constructor(helpers, res){
console.log(res.instance, res.config)

There are few thing here:

  • @Component is also a class decorator.

  • For a didactic explanation, the example above expose all the options an @Component can have.

  • We're using the @appt/mongoose plugin. It is a driver of MongoDB using Mongoose ODM.

  • By default, TDatabase appends a param into constructor returning a driver instance, in this case mongoose and the configurations used.

Plus, it's important to notice:

  • These type of decorator can only inject other components and these injection are passed through the class constructor, such as seen withHelpersComponent;

  • A @Component can get a meaning, a special behaviour passed through a Special-Type Extender (TDatabase, in this case).