Miniaturized spectrometers with a tunable van der Waals junction