```

 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.



We’ve all done it

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.



Boilerplate is the tax we pay ourselves

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:


  1. Create modelApi.ts
  2. Paste the same 5 lines
  3. Update two strings
  4. Write a test that asserts the file exists
  5. Call the sprint “done”

We burn story points on typing, not on thinking.



The hidden cost

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.



Kill it with abstraction, not convention

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.



Abstraction is scary—duplication is scarier

“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.



Your linter can help

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.



What to do today

  1. Find the five-line clones with rg "reducerPath.Api" -g ’.ts’ | wc -l.
  2. Extract a helper.
  3. Delete the clones.
  4. Push, watch CI go green, do a little dance.



Boilerplate isn’t architecture—it’s procrastination

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.

 

Our Trusted
Partner.

Unlock Valuable Cloud and Technology Credits

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:

  • Google Workspace accounts
  • Microsoft accounts
  • Stripe processing fee waivers up to $25,000
  • And many other valuable benefits

Why Choose Our Partnership?

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.

exclusive-partnersexclusive-partners

Let's TALK

Let's TALK and bring your ideas to life! Our experienced team is dedicated to helping your business grow and thrive. Reach out today for personalized support or request your free quote to kickstart your journey to success.

DIGITAL PRODUCTUI/UX DESIGNDIGITAL STUDIOBRANDING DESIGNUI/UX DESIGNEMAIL MARKETINGBRANDING DESIGNUI/UX DESIGNEMAIL MARKETING
DIGITAL PRODUCTUI/UX DESIGNDIGITAL STUDIOBRANDING DESIGNUI/UX DESIGNEMAIL MARKETINGBRANDING DESIGNUI/UX DESIGNEMAIL MARKETING