Waveguide single-photon and photon number-resolving detectors