Add and use reference to the typescript middleware