Starting an API using javascript
I’ve been using Node.js for a decade, and I can say that I’m happy with it.
It’s kind of crazy to think that the latest release of Express was over a year ago, yet it’s still used in millions of projects. To this day, it remains the most popular framework in Node.js.


The question is: Should I still use it for a brand-new API project?
To answer that, I believe, it really depends on the project and the team you are working with. Some counter-questions you could ask to help with the decision include:
- Is there any other project using the same structure?
- If you are considering a new tool for the job, how different is it from the current structure?
- How difficult will it be to adopt a new structure?
- Do you want to keep projects on separate structures?
The point I want to make is that no matter what you decide, it’s a trade-off. If you choose to use a structure that hasn’t been updated for quite a while, you won’t benefit from the latest security updates.
As a developer, I think competition in the ecosystem is a good thing. However, this also has a downside, it further fragments the ecosystem.
What I’m using for my projects?
Code structure
I’m creating a project using Hono, a lightweight web framework that follows the Web Standard API.
Here’s a quick look at the project structure.
"/routes": Routes of the application.
"/lib/db": Database structure. Migrations, seed and types.
"/app/cases": Use cases of your application.
"/app/repositories": Repositores and interfaces that are used by the use cases.
"/node.ts": Initial file to run the project using node.
"/bun.ts": Initial file to run the project using bun.
You can check the repository here.
Framework agnostic?
Thanks to Hono's simplicity, you can structure your project in a way that best suits your needs.
The core of this project is located in the /app
directory, where I use only JavaScript, none of these files are specific to Hono. This means that if you ever need to switch away from Hono for any reason, you can simply copy the /app
directory and adjust the request handling as needed.
Why hono?
Based on my experience with Express.js and Fastify, I’ve found Hono to be powerful, easy to use, and supported by an active community. If you're still not convinced, Fastify is also an excellent option.
Why this structure?
This comes down to personal preference and depends on your application and deployment process.
I've been using this case structure for a while and have found it enjoyable, though I’m still learning and refining it as I go.
I generally aim for a balanced approach to structuring projects for various reasons.
As a personal recommendation, try not to become too attached to any one framework. You’ll gain more value by focusing on structuring your code and learning about patterns that can benefit your team, projects, and clients.
Feel free to adapt these ideas to fit your needs.
Hono best practices
Hono presets