init & add middleware