this project is a proof of concept! Whose macro goal is to use a minimum of frameworks (Apollo GraphQL on the back-end, and React + Material UI on the front-end) to 'federate and consumes' a (REST - provided by api. zippopotam.us) zip code search!
The server is (for obvious reasons) in the 'server' folder. It will require node.js 18 (to reduce direct dependencies, I was prefered use the Experimental FetchAPI over RESTDataSource from @apollo/datasource-rest)
To simplify the development process, 'nodemon' was enabled in 'npm run dev'. For production use, is need to setup NODE_ENV as production, and the 'npm run serve' will do that (if you're using Linux/unix/macOS)!
The sever will start On port '8080'!
Inside server folder:
$ npm run test
Inside server folder:
$ npm run dev
Access to Apollo Studio will be enabled in this mode!
Inside server folder:
$ npm run serve
Access to Apollo Studio will NOT be enabled in this mode!
The React+MUI client is in the 'client' folder. To reduce direct dependencies, I also prefered use FetchAPI over (Apollo GraphQL client*. Due to simplicity, SSR was not required. The client will run in a different port (than server), but will FETCH in the same URL address (except for the door).
Inside client folder:
$ npm run dev
Due to simplicity, This option has not been made available! But, after build a 'deployable' version, it can be deployed on a server like Apache (or even node's express)
Inside client folder:
$ npm run build
At this moment, the coutries (in the suportedCountries.json) was captured open the web site of zippopotam.us (https://www.zippopotam.us/), open a console and run:
console.log( JSON.stringify(
[...document.querySelectorAll("#where table tbody tr")]
.map( (row) => ({
name: row.childNodes[0].innerText,
abbreviation: row.childNodes[1].innerText
}))
));
but it can be done by the server with addtional imports like jsdom or cheerio!