This is the first segment in a series of posts in which we plan to discuss overarching ideas related to: Simba.js. These include its usage scenarios, potential applications, associated considerations, recommendations, etc.
Another JS library/framework?
The short answer is yes. Long answer, but yeah…
If you’re like me, you can get really frustrated whenever you want to start a new JS/TS API. In most cases, depending on the complexity of your project, you will need to create tsconfig.json, .eslintrc, LICENSE, jest.config.js/ts, Dockerfile, etc. to configure the same content over and over again.
Back in 2021, when I was new to programming (I only had about a year of experience), I decided I didn’t want to do the same thing again and created a CLI tool that allows me to create all my configuration files and avoid the stress. . You have to create it manually many times. This tool was very useful in the days when I didn’t have to create anything manually, but it wasn’t enough for me. why? That’s because most of what you do when creating an API (at least a RESTFul API) is usually the same.
You configure the server, then you configure the database, then you add some elements in between (we call them services) to handle the business logic, and finally you add some routes (we call them controllers). ”) to expose business logic through some endpoint. Once you get to that point, you’ll probably need to add some validation between the incoming request and the logic in your controller, so add some schema to validate if the request submitted by the user is correct. There is a possibility that it will happen. soon.
As you can see, creating a JS/TS RESTFul API is usually a very iterative process. So I started working on creating something that would circumvent this process.
I drew inspiration from many places. Meanwhile, we were building his SPA. CRA,it was fun. CRA provided most of the tools you need to start building your own apps, but only for the front end. What about the backend? I remember there was no such thing as CRA, but there were popular complete frameworks such as: nest JS or SailsJS, Similarly, it also includes highly opinionated (or not) popular frameworks such as: express, core or Speeding up At least no skeleton or basic configuration was provided. Start off similar to what the CRA was offering. As I recall, there was no middle ground. I had to go full Nest or use plain Express or Fastify on my own.
So the idea of Simba.js (we didn’t have a name for it yet) came to mind. I wanted a tool that would give me a starting point, so I didn’t have to manually write queries, controllers, or services, but I just had to follow the skeleton to make it work. I needed something that wasn’t magical enough to just import something (sorry, Nest). That was it, but I also didn’t want to reinvent the wheel.
The preparations are complete. We built a CLI tool that allows you to create a small boilerplate with a fully configured and fully functional RESTFul API in a few keystrokes. But it didn’t have a name. That’s when an idea popped into my head. I named my framework/library after Simba, the laziest cat I’ve ever met. But so am I. why? Because again from scratch he doesn’t want to create a RESTFul API.
The goal of Simba.js is to standardize the way RESTFul APIs are created. Well, actually, that was the goal. These days, we also want to standardize the way we build GraphQL APIs. So let’s say Simba.js aims to become the standard way to build TS APIs.
Of course, there are quite a few opinions on Simba.js. I chose Express and Fastify, which are backend frameworks that I like (and are very popular). I also chose Joi and Mongoose (no longer supported), which were my favorite tools at the time, as well as other tools. I also chose Eslint and more beautiful Favorite settings, testing frameworks, and more.
I chose these tools because they are based on my own experience, work very well with each other, and can be easily combined in a reusable way. I think this is also a good starting point. Once Simba.js provides a boilerplate, it’s very easy to work with it and escalate your application based on your needs. Additionally, Simba.js provides a number of tools that allow you to build your own APIs. You can choose:
- Between Express and Fastify
- MongoDB or traditional relational DB
- REST API or GraphQL API
- To run the lint and test GitHub actions
- Which license to use etc.
And don’t forget, you won’t have to worry about those annoying configuration files that everyone hates.
Sounds good. Would you like to try it?here it is repository (Please put a star there if you want!) npm package. Please help us.
That’s it for now.
Have fun coding!