Options of the Application
const app = new Application({
public: '/public',
port: 3000,
db: { ...dbParameters },
waitForModuleInit: true
})
app.registerModule(...)
app.registerModule(...)
...
try {
app.run()
} catch(error) {
// Error handling on promise catch
console.log(error)
}
Express application
Application database instance
Database asynchronous connection promise
Registered endpoints
SocketIO server
Registered modules
HTTP server from express
Connected sockets
Try to connect to the mongo database
Credentials
Database name
Database user's password
Database access url
Database access user
Mongoose instance
const db = await connectDatabase({ ...dbOptions })
The Promises results of the init methods of all modules that have the wait flag at true
const modulesInitResponses = await ensureModulesInit()
Fetch the endpoint matching the path and type
Path to match
Endpoint type to match
The endpoint if one is found, otherwise null
const userSocketEndpoint = getEndpoint('/userLogin', 'Socket')
const userHTTPEndpoint = getEndpoint('/userLogin', 'HTTP')
Find the good handler and use it for the incoming request
Socket to handle the request from
Path of the request
Data transmitted by the socket
Whatever the handler returns
socket.on('request', (data) => {
const res = handleSocketRequest(socket, data.path, data)
})
Listen to requests from the socket to redirect them
Socket to listen to the requests from
Whatever the handler returns
io.on('connection', (socket) => {
listenSocketRequests(socket)
})
Spread client socket connection information
Client socket
io.on('connection', (socket) => {
onSocketJoin(socket)
})
Instantiate and link a module to the Application
Class of the module to register
The instance of the module
const module = await registerModule(MyModuleClass, { wait: true })
Start the server
The instance of the HTTP server
Generated using TypeDoc
Application object that handle the main working process of the project