Skip to content

Commit

Permalink
#17 return sorted lists, use updated data for Trabzon
Browse files Browse the repository at this point in the history
  • Loading branch information
canbax committed May 13, 2023
1 parent c2c068c commit ada0f15
Show file tree
Hide file tree
Showing 3 changed files with 80,956 additions and 81,014 deletions.
14 changes: 11 additions & 3 deletions api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@ function getCountries(_: Request, res: Response) {
for (const c in ALL_PLACES) {
r.push({ code: ALL_PLACES[c].code, name: c });
}
res.send(r);
res.send(r.sort((a, b) => a.name.localeCompare(b.name)));
}

function getRegionsOfCountry(req: Request, res: Response) {
const country = req.query.country as string;
if (ALL_PLACES[country]) {
res.send(Object.keys(ALL_PLACES[country].regions));
res.send(
Object.keys(ALL_PLACES[country].regions).sort((a, b) =>
a.localeCompare(b)
)
);
} else {
res.send({ error: "NOT FOUND!" });
}
Expand All @@ -77,7 +81,11 @@ function getCitiesOfRegion(req: Request, res: Response) {
const country = req.query.country as string;
const region = req.query.region as string;
if (ALL_PLACES[country] && ALL_PLACES[country].regions[region]) {
res.send(Object.keys(ALL_PLACES[country].regions[region]));
res.send(
Object.keys(ALL_PLACES[country].regions[region]).sort((a, b) =>
a.localeCompare(b)
)
);
} else {
res.send({ error: "NOT FOUND!" });
}
Expand Down
Loading

1 comment on commit ada0f15

@vercel
Copy link

@vercel vercel bot commented on ada0f15 May 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

namaz-vakti-api – ./

namaz-vakti-api-canbax.vercel.app
namaz-vakti.vercel.app
namaz-vakti-api-git-main-canbax.vercel.app

Please sign in to comment.