In my quest to become a well rounded backend developer, I recently delved into NodeJS\ExpressJs.
Coming from a background of writing Django, I noticed some similarities between the two frameworks, albeit with some notable differences. With ExpressJS for example, you must handle the middlewares and controllers directly. Middleware is the fundamental concept and a core part of the framework's design and sits in the middle of the request/response cycle.
In ExpressJS middleware functions can be used to perform various tasks such as parsing incoming data, authentication, error handling and logging. Middleware is also written as a function that takes three parameters: request
, response
and next
. The Middleware functions can either modify the request
and response
object or terminate the request/response cycle by sending a response or invoking next
to pass control to the next middleware
But in Django, middleware is an optional feature, I mean you don't need to handle it yourself. It provides a way to process requests and responses globally across all views it sits between the web server and the views functions. The Middleware can also be used for authentication, session management, and caching.
Django automatically handles the order in which middleware is applied to the request/response chain based on the order in which they are defined in the MIDDLEWARE setting.
Just know that middleware in Django and ExpressJs serve similar purposes but are handled differently.
After a few weeks of intensively learning NodeJS/ExpressJS, I have come to appreciate the ease and efficiency of Django. Nonetheless, I built a small app using ExpressJS and, although I am not entirely satisfied with the outcome, I am determined to continue honing my skills in this area.
In the meantime, you can explore a microservice I recently designed with Django REST Framework. The microservice boasts of a comprehensive authentication system that includes user registration and verification via OTP, as well as OAuth2 integration for social login. I have also implemented logging and monitoring features to ensure optimal performance.
You can check the code here, although it is not yet hosted due to ongoing documentation efforts. However, feel free to clone the repository and explore its features.
Thank you for reading through. you can follow me on Twitter.
Top comments (0)