Role based separation or service based separation in NestJs?

Viewed 32

I am trying to build a service using NestJs. There are two stakeholders in this app (teacher and a student). If I want to create an endpoint for exam i.e. a teacher will have create exam and student will have give exam. Both of them will have dtos which are very similar (or the interfaces when using TS would be very similar).

Something like

create exam's message might look like:

{
    "name" : "midterm",
    "time" : "2hrs",
    "qalist" : [
        {"question" : "What is it?",
         "answer" : "This is it"},
         {"question" : "What is it?",
         "answer" : "This is it"}
    ]
}

and for give exam, "answer" field won't be there.

Typically these two services can be routed through one controller. But since they are separate things functionally, should I create a different module for each or should I just separate them based on role based access control? I can do it either way, but what would be the cleaner way?

0 Answers
Related