Skip to main content

Command Palette

Search for a command to run...

Express JS Moduler base folder and file stractrure

Published
1 min read
M

Hi, I am Full Stack Developer. I can build web application, android application, desktop application. My core programming language is JavaScript.

Folder Stracture

modules/
 └── plan/
      ├── plan.interface.ts      // TypeScript interface (TPlan)
      ├── plan.model.ts          // Mongoose schema & model
      ├── plan.service.ts        // Business logic / DB operations
      ├── plan.controller.ts     // Express controllers (handlers)
      └── plan.routes.ts         // Express router

File export stractures controller service routes

const PlanController = {
  createPlan,
  getAllPlans,
  getSinglePlan,
  updatePlan,
  deletePlan,
};

export default PlanController;
const PlanService = {
  createPlan,
  getAllPlans,
  getSinglePlan,
  updatePlan,
  deletePlan,
};

export default PlanService;
  • Routes are diffrent

      const PlanRoutes = router
      export default PlanRoutes
    
  • and route will be use plural

      app.use('/api/plans', PlanRoutes);
    
1 views

More from this blog

Build Like a Cursor AI for Build Software using AI

নিচে আমি আপনাকে Cursor-এর মতো কাজ করার জন্য Continue.dev + Ollama সেটআপ করার সম্পূর্ণ ধাপ (instruction) প্রথম থেকে শেষ পর্যন্ত বাংলায় দিয়ে দিচ্ছি। আপনি কেবল এই ধাপগুলো অনুসরণ করুন: 🛠️ Step-by-step Instruction: Cursor-এর মতো AI কোড সহকারী তৈরি ✅ Ste...

Jul 31, 20252 min read5

promahbubul

59 posts

I'm React Native and Full Stack Web Deveioper. My core programming language is JavaScript.