Exports
Exports are used in order to give another resource the opportunity to use functionality from your own resource by exposing functions. For example, inside your vehicles
resource, you might want to allow other resources to fetch all of a player’s personal vehicles by exposing the getPlayerVehicles()
function.
The Armoury Framework recognizes functions annotated with the @Export()
decorator and automatically marks them as exports.
Creating an export: Basic example
// server.controller.ts inside 'vehicles' resource
@Export()
public getPlayerVehicles(playerId: number): void {
return this.vehicles[playerId];
}
Calling exports: Basic example
// server.controller.ts inside 'foo' resource
console.log(
global.exports['vehicles'].getPlayerVehicles(playerId)
);