TServer

import { TServer } from '@appt/api';

This is a special-type extender we can use to transform a component into an express server. There are many default configurations (as you can see at the example below) which, without them, you probably could not do much. That brings us one of the Appt's main goals: allow you to start a project with minimum effort. Of course you can override each one of them.

import { Component } from '@appt/core';
import { TServer } from '@appt/api';
/* These are the default configuration you can override */
const config = {
port: 3000,
options: {
statics: [{
route: '/',
path: '/'
}],
bodyParser: {
json: {
limit: '50mb',
type: 'application/json'
},
urlencoded: {
limit: '50mb',
extended: true
}
},
cors: [{
route: "/*",
header: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Authorization, Content-Type, Origin, Accept, X-Requested-With, Origin, Cache-Control, X-File-Name",
"Access-Control-Allow-Methods": "GET, POST, PUT, OPTIONS, DELETE"
}
}]
}
};
@Component({
extend: TServer(config.port, config.options)
})
export class ApiServer{
constructor(config){
// the especial-type externder TServer inject all the server configurations
console.log(`Server running at http://localhost:${config.port}`)
}
}