This is an Express API demo that illustrates the following:
- How to serve vanilla HTML/CSS/JS pages
- How to implement a simple "fake database" in the API using an array
- How to retrieve data from the API inside of vanilla HTML/CSS/JS pages using fetch requests
NOTE: Accessing the pages will require the .html
extension to be present. Ex: http://localhost:3000/users.html
Fork this repo on Replit to run the app with no setup:
https://replit.com/@Prgrmming4Doers/DemoSimpleExpressApiVanillaUi
(You can also modify the code and see the changes)
Otherwise, to clone/set up this project locally, proceed to "Getting Started" section
Windows
You will need Docker installed
You will need WSL installed
Run this to avoid errors related to line-endings
git config --global core.autocrlf input
MacOS
You will need Docker installed
- Clone this project
- Enter the project directory
- Run:
bin/setup
- Run:
bin/services up -d
- Run:
bin/services logs
to tail logs - Navigate to
http://localhost:3000
in your browser
Commands
- Bring down the stack:
bin/services down
- Bring up the stack:
bin/services up -d
- Restart the stack:
bin/services down; bin/services
- Tail logs:
bin/services logs
- Restart the stack and tail logs:
bin/services down; bin/services; bin/services logs
Note: For some kinds of code changes, you may need to restart the stack for them to take effect