Concept Flow - Resource naming conventions
Start
Identify resource type
Choose naming style
Apply naming rules
Check consistency
Use in code
End
This flow shows how to pick and apply consistent resource names in Node.js projects.
const userController = require('./controllers/userController'); const productRouter = require('./routes/productRouter'); app.use('/users', userController); app.use('/products', productRouter);
| Step | Action | Resource Name | Naming Style | Result |
|---|---|---|---|---|
| 1 | Identify resource type | User controller | camelCase | userController |
| 2 | Identify resource type | Product router | camelCase | productRouter |
| 3 | Apply file naming | User controller file | camelCase + suffix | userController.js |
| 4 | Apply file naming | Product router file | camelCase + suffix | productRouter.js |
| 5 | Use in code import | Import user controller | variable matches file | const userController = require('./controllers/userController'); |
| 6 | Use in code import | Import product router | variable matches file | const productRouter = require('./routes/productRouter'); |
| 7 | Use in app | Mount user controller | URL path plural noun | app.use('/users', userController); |
| 8 | Use in app | Mount product router | URL path plural noun | app.use('/products', productRouter); |
| 9 | Check consistency | All names | Consistent camelCase and plural URLs | Naming conventions followed |
| 10 | End | - | - | Resources named and used consistently |
| Variable | Start | After Step 1 | After Step 2 | After Step 5 | After Step 6 | Final |
|---|---|---|---|---|---|---|
| userController | undefined | userController | userController | userController | userController | userController |
| productRouter | undefined | undefined | productRouter | undefined | productRouter | productRouter |
Resource Naming Conventions in Node.js: - Use camelCase for variable and file names (e.g., userController.js) - Use plural nouns for URL paths (e.g., '/users') - Keep variable names matching file names for imports - Consistency improves readability and avoids errors - Follow RESTful conventions for URLs