Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Districts feature has been added to provinces-of-turkey-api project. #1

Merged
merged 5 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Small name changes
  • Loading branch information
ubeydeozdmr committed Jul 28, 2022
commit f0a141b377cedb5c5a2139bdc5b31b5199669a6c
4 changes: 2 additions & 2 deletions controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const fs = require('fs');
const provinces = JSON.parse(fs.readFileSync(`${__dirname}/dev-data/api.json`));
let query;

exports.checkQuery = (req, res, next, val) => {
query = req.params.query.replace('İ', 'I').toLowerCase();
exports.checkID = (req, res, next, val) => {
query = req.params.id.replace('İ', 'I').toLowerCase();
// console.log(query)
// console.log(query[0]);
// console.log(query[0] === 'ı');
Expand Down
6 changes: 4 additions & 2 deletions router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ const controller = require('./controller');

const router = express.Router();

router.param('query', controller.checkQuery);
router.param('id', controller.checkID);

router.route('/').get(controller.getAllProvinces);
router.route('/:query').get(controller.getProvince);
router.route('/:id').get(controller.getProvince);
// router.route("/:id/districts").get();
// router.route("/:id/districts/:district").get();

module.exports = router;