- Home
- Services
- IVY
- Portfolio
- Blogs
- About Us
- Contact Us
- Sun-Tue (9:00 am-7.00 pm)
- infoaploxn@gmail.com
- +91 656 786 53
```
export const apiSlice = createApi({ reducerPath: ’postsApi’, baseQuery: fetchBaseQuery({ baseUrl: ’/api’ }), tagTypes: [’Post’], endpoints: () => ({}) })
```
I deleted them with glee.
I replaced them with zero lines.
That felt good, so I wrote this rant.
Every team has that one folder: features/auth/api, features/users/api, features/comments/api…
Each file is a carbon copy of the last, except the string ’postsApi’ becomes ’commentsApi’.
We copy-paste, change two tokens, commit, and call it “scalable architecture”.
It’s not scalable. It’s busy-work.
I’m not talking about the unavoidable stuff like useState or console.log.
I’m talking about the self-imposed ceremony we invented to feel “enterprise”.
Every time we add a new model we:
We burn story points on typing, not on thinking.
Those five lines look harmless, but they spread like ivy:
● Junior devs think they’re “following the pattern”, so they cargo-cult it into new modules.
● PR reviewers rubber-stamp it (“looks consistent”).
● Bundle size grows because tree-shaking can’t delete a file that’s imported everywhere.
● Onboarding docs swell: “Make sure you create the api slice file…”
Suddenly your codebase has 200 apiSlice files and one actual endpoint.
I replaced the 200 files with one factory:
```
// apiFactory.ts export const createNamedApi = (name: string) => createApi({ reducerPath: name, baseQuery: fetchBaseQuery({ baseUrl: ’/api’ }), tagTypes: [name], endpoints: () => ({}) })
```
Now adding a new domain is a one-liner:
```
export const postsApi = createNamedApi(’posts’)
```
No file, no copy-paste, no typo in reducerPath.
The tests? They test the factory once, not every file.
“But what if we need different baseQuery options later?”
Then we’ll pass an optional config object.
“What if we need custom tagTypes?”
Then we’ll accept an override.
We can evolve the helper faster than we can delete 200 stale files.
YAGNI is not an excuse to multiply garbage.
Add an eslint rule:
```
"no-restricted-syntax": [ "error", { "selector": "CallExpression[callee.name=’createApi’]", "message": "Use createNamedApi() instead of inline createApi()" } ]
```
Now the machine stops the pattern from spreading.
Next time you’re about to create features/unicorns/api, ask yourself:
“Am I solving a real problem, or just avoiding the real problem?”
Stop writing the same five lines.
Start deleting them.
Your future self will git-blame you—and smile.
Imagine reducing your operational costs by up to $100,000 annually without compromising on the technology you rely on. Through our partnerships with leading cloud and technology providers like AWS (Amazon Web Services), Google Cloud Platform (GCP), Microsoft Azure, and Nvidia Inception, we can help you secure up to $25,000 in credits over two years (subject to approval).
These credits can cover essential server fees and offer additional perks, such as:
By leveraging these credits, you can significantly optimize your operational expenses. Whether you're a startup or a growing business, the savings from these partnerships ranging from $5,000 to $100,000 annually can make a huge difference in scaling your business efficiently.
The approval process requires company registration and meeting specific requirements, but we provide full support to guide you through every step. Start saving on your cloud infrastructure today and unlock the full potential of your business.