I'm building a Node.js website in TypeScript that exposes a RESTful API.
What are the best practices for separating the different methods to different classes/files?
I guess that for each resource I need to create a separate class. For example:
class Customers{
router.get('/customers');
router.post('/customers');
router.put('/customers');
router.delete('/customers');
}
class Orders{
router.get('/orders');
router.post('/orders');
router.put('/orders');
router.delete('/orders');
}
Is this true? And what if I have many resources that only contain one method each one?
For example:
router.get('/orders');
router.post('/customers');
router.put('/products');
router.delete('/employees');
Edit: I was answered that I can put all the routes in a single file and just separate the handlers into multiple files. So my question is: How to order/separate them LOGICALLY into different files (regarding the examples I wrote in my question)?
Notice: I don't need a technical programmatic information but an abstract explanation for logic separation.