I am looking at express.js for the back end and JS on the client side. My app is a single page Web App.
The server will only serve JSON messages and my question is abou
You only have to route requests you serve dynamically. Your HTML, CSS, JS are all static assets. So all you need to handling routing for is your data.
It sounds like you want a Restful API, which basically means that you have URLs for specific resources, and HTTP verbs for manipulating them.
Something like:
GET /books.json
- Get all booksPOST /books.json
- Create a new book with properties passed in the body of the requestGET /books/123.json
- Get book with id of 123PUT /books/123.json
- Update an existing book with properties passed in the body of the requestThis blog post seems to show how to set this up in Express.
Once you have a sane API delivering JSON, you just make your AJAX calls use it based on what objects you want to fetch.