Posts

12 Rules to build REST API

Image
  1. Use consistent resource naming Plural nouns, kebab-case, no verbs. Your URLs are nouns. HTTP methods are the verbs. `/api/users`, `/api/order-items`, never `/api/getUsers`. 2. Version from day one Put `/v1/` in your base path before you ship. Retrofitting versioning onto a live API is painful. Starting with it is free. 3. Use proper HTTP status codes Not everything is 200. Not every error is 500. 4. Implement pagination from the start Every list endpoint should support `?page=1&limit=20` or cursor-based pagination from day one. Add filtering and sorting through query params (`?status=active&sort=name`). Keeps your API flexible without new endpoints. 5. Use DTOs. Don't leak your DB schema Your database model is not your API response. Shape what goes out. Strip internal IDs, timestamps you don't want exposed, and sensitive fields. 6. Add rate limiting One abusive client shouldn't take down your API. `express-rate-limit` takes five lines. For production, back it w...

𝐀𝐝𝐝𝐑𝐚𝐧𝐠𝐞() 𝐭𝐨 𝐜𝐨𝐦𝐛𝐢𝐧𝐞 𝐜𝐨𝐥𝐥𝐞𝐜𝐭𝐢𝐨𝐧𝐬?

Image
  𝐒𝐭𝐢𝐥𝐥 𝐮𝐬𝐢𝐧𝐠 𝐀𝐝𝐝𝐑𝐚𝐧𝐠𝐞() 𝐭𝐨 𝐜𝐨𝐦𝐛𝐢𝐧𝐞 𝐜𝐨𝐥𝐥𝐞𝐜𝐭𝐢𝐨𝐧𝐬? C# 12 gives us a cleaner alternative with 𝐂𝐨𝐥𝐥𝐞𝐜𝐭𝐢𝐨𝐧 𝐄𝐱𝐩𝐫𝐞𝐬𝐬𝐢𝐨𝐧𝐬. Instead of creating a list and then calling AddRange(), you can create the final collection in a single expression. 𝐓𝐢𝐧𝐲 𝐍𝐨𝐭𝐞𝐬 ✅ AddRange() modifies an existing list. ✅ Collection Expressions create a 𝐧𝐞𝐰 𝐜𝐨𝐥𝐥𝐞𝐜𝐭𝐢𝐨𝐧. ✅ Great for cleaner, more readable code. ✅ Introduced in 𝐂# 12 (.𝐍𝐄𝐓 8). Small language features like this make your code easier to read, review, and maintain. Which approach do you prefer? AddRange() or Collection Expressions?

𝐏𝐨𝐩𝐮𝐥𝐚𝐫 𝐀𝐏𝐈 𝐀𝐫𝐜𝐡𝐢𝐭𝐞𝐜𝐭𝐮𝐫𝐞 𝐒𝐭𝐲𝐥𝐞𝐬 𝐃𝐞𝐯𝐞𝐥𝐨𝐩𝐞𝐫𝐬 𝐒𝐡𝐨𝐮𝐥𝐝 𝐊𝐧𝐨𝐰

Image
  𝐏𝐨𝐩𝐮𝐥𝐚𝐫 𝐀𝐏𝐈 𝐀𝐫𝐜𝐡𝐢𝐭𝐞𝐜𝐭𝐮𝐫𝐞 𝐒𝐭𝐲𝐥𝐞𝐬 𝐃𝐞𝐯𝐞𝐥𝐨𝐩𝐞𝐫𝐬 𝐒𝐡𝐨𝐮𝐥𝐝 𝐊𝐧𝐨𝐰 1️⃣ gRPC 💡 What it is: A high-performance, open-source RPC framework by Google that uses HTTP/2 and Protocol Buffers, offering built-in features like authentication and load balancing. 🔎 Best for: Microservices, inter-service communication, and high-throughput, low-latency systems. 2️⃣ SOAP (Simple Object Access Protocol) 💡 What it is: A protocol that uses XML to exchange structured data over HTTP or SMTP, with strict standards and formal contracts (WSDL). 🔎 Best for: Enterprise systems that require high security, ACID transactions, and strong contractual interfaces. 3️⃣ GraphQL 💡 What it is: A query language and runtime that lets clients fetch exactly the data they need, no over- or under-fetching. 🔎 Best for: Complex data models and apps that demand flexible, efficient data retrieval. 4️⃣ Webhooks 💡 What they are: Event-driven HTTP callbacks that notify external...

Informed Consent in Human Research: Ethics, Understanding, Deception, and Modern Approaches

  Informed Consent in Human Research: Ethics, Understanding, Deception, and Modern Approaches Introduction Informed consent is one of the most important ethical requirements in research involving human participants. It protects the dignity, autonomy, rights, and welfare of individuals who agree to participate in research. Rather than being simply a form that a participant signs, informed consent should be understood as an ongoing communication process between the researcher and the participant . For informed consent to be ethically valid, participants must understand what the research involves, make their decision voluntarily, and have the capacity to make that decision. Modern research, however, introduces several challenges to this process. Complex scientific terminology, lengthy consent forms, deception, therapeutic misconception, digital technologies, and research involving individuals with diminished decision-making capacity can all make genuine informed consent difficult to a...

Research Integrity: The Foundation Every Future Researcher Should Learn Before Publishing

  Research Integrity: The Foundation Every Future Researcher Should Learn Before Publishing For every future PhD scholar, researcher, academician, reviewer, or research professional , learning research methodology is only one part of becoming a good researcher. The other part is understanding Research Ethics and Research Integrity . After completing the KU Leuven MOOC Research Ethics: A Guide to Responsible Research with Human Subjects , one lesson stood out clearly: Good research is not only about discovering something new. It is about discovering it honestly, responsibly, and transparently. Research ethics mainly focuses on protecting research participants, their rights, safety, privacy, and informed consent . Research integrity goes further. It asks whether the entire research process—from the original idea to data collection, analysis, authorship, publication, and peer review—has been conducted responsibly. The European Code of Conduct for Research Integrity highlights four fun...