compile() {
        // Initialize a fresh array of middlewares
        const middlewares = [];
        const pattern = this.pattern;

        // Determine wildcard properties about this route
        const is_wildcard = pattern.endsWith('*');
        const wildcard_path = pattern.substring(0, pattern.length - 1);

        // Iterate through the global/local middlewares and connect them to this route if eligible
        const app_middlewares = this.app.middlewares;
        Object.keys(app_middlewares).forEach((pattern) =>
            app_middlewares[pattern].forEach((middleware) => {
                // A route can be a direct child when a route's pattern has more path depth than the middleware with a matching start
                // A route can be an indirect child when it is a wildcard and the middleware's pattern is a direct parent of the route child
                const direct_child = pattern.startsWith(middleware.pattern);
                const indirect_child = middleware.pattern.startsWith(wildcard_path);
                if (direct_child || (is_wildcard && indirect_child)) {
                    // Create shallow copy of the middleware
                    const record = Object.assign({}, middleware);

                    // Set the match property based on whether this is a direct child
                    record.match = direct_child;

                    // Push the middleware
                    middlewares.push(record);
                }
            })
        );

        // Find the largest ID from the current middlewares
        const offset = middlewares.reduce((max, middleware) => (middleware.id > max ? middleware.id : max), 0);

        // Push the route-specific middlewares to the array at the end
        if (Array.isArray(this.options.middlewares))
            this.options.middlewares.forEach((middleware) =>
                middlewares.push({
                    id: this.id + offset,
                    pattern,
                    handler: middleware,
                    match: false, // Route-specific middlewares do not need to be matched
                })
            );

        // Sort the middlewares by their id in ascending order
        // This will ensure that middlewares are executed in the order they were registered throughout the application
        middlewares.sort((a, b) => a.id - b.id);

        // Write the middlewares property with the sorted array
        this.options.middlewares = middlewares;
    }
Compiles the route's internal components and caches for incoming requests.