geographic.js 370 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
const fs = require('fs');

function getJson(infoType) {
  const json = fs.readFileSync(`${__dirname}/${infoType}.json`, 'utf8');
  return JSON.parse(json);
}

export function getProvince(req, res) {
  res.json(getJson('province'));
}

export function getCity(req, res) {
  res.json(getJson('city')[req.params.province]);
}

export default {
  getProvince,
  getCity,
};