This marks the initial segment of a sequence of posts where I intend to discuss overarching ideas related to Simba.js. These encompass its utilization scenarios, potential applications, associated considerations, recommendations, and more.

Another JS library/framework? 

Short answer, yes. Long answer, well…

If you are something like me, you might be really annoyed whenever you want to start a new JS/TS API. Most of the time, you have to configure the same stuff over and over again, creating a tsconfig.json, .eslintrc, LICENSE, jest.config.js/ts, Dockerfile, and so many more depending on how complex your project is. 

Back in 2021, when I had just started programming (I had one year of experience or so), I decided I did not want to do that again, so I created a CLI tool to help me make all the configs files and avoid the stress of creating them manually over and over again. That tool was very useful on the days I did not have to create anything manually, but it was not enough for me. Why? Because when you create an API (at least a RESTFul API) most of the things you do are usually the same. 

You have to config your server, then your database, then add some things in the middle to handle your business logic — let’s call it “services” — and finally add some routes — “controllers” — to expose your business logic through some endpoints. Once you get to that point, you probably need to add some kind of validation between the request you receive and the logic you have in your controllers, so you may end up adding some schemas to validate if the request a user sent was correct, and so on. 

As you can see, creating a JS/TS RESTFul API is usually a very repetitive process. So I started working on creating something to avoid this process. 

I got inspiration from many places. During that time, we used to build SPAs with CRA, and it was fun. CRA gave you most of the tools you needed to start building your own app, but that was for the frontend. What about the backend? I remember we did not have something like CRA, but we had popular complete frameworks such as NestJS or SailsJS, as well as very opinionated (or not) popular frameworks such as Express, koa or Fastify that did not provide you at least a skeleton or basic config to begin with like CRA used to provide. According to what I remember, there was no middle point. You had to go entirely with Nest or go on your own with plain Express or Fastify. 

That is how the idea of Simba.js (I did not have the name yet) came to my mind. I wanted a tool that gave me a starting point, so I had to write queries, controllers, or services by hand, but I just had to follow the skeleton to make it work. I needed something that did not feel like magic (sorry, Nest) where you just have to import something, and that was it, but also, I did not want to reinvent the wheel. 

I was ready, I built a CLI tool that allowed me, with a few keystrokes, to create a little boilerplate with all the configuration done and a fully working RESTFul API, but the name was missing, and then the idea came to my mind. I named my framework/library after my cat, Simba, the laziest creature I have ever met. But so I am. Why? Because I do not want to create a RESTFul API from scratch again.

The goal of Simba.js is to standardize the way we create RESTFul APIs. Well, in fact, that was the goal. Nowadays, I also want to standardize the way we build GraphQL APIs too. So let’s say that Simba.js aims to become the standard way to build TS APIs. 

Of course, Simba.js is heavily opinionated. I chose the backend frameworks I liked (and also very popular ones): Express and Fastify, and also the tools I liked at the time, which were Joi and Mongoose (currently not supported) and some others. I also chose the eslint and prettier config I liked, the test framework, and so on.

I chose these tools based on my own experience because they work very well together, and it was easy to combine them in a reusable way. I also think this is an excellent point to start. Once Simba.js provides you with the boilerplate, it is pretty easy to manipulate it and escalate the application based on your needs. Besides, Simba.js gives you many tools to allow you to build your own API. You can choose: 

  •  Between Express and Fastify, 
  •  A MongoDB or a classic Relational DB
  •  A REST API or a GraphQL one 
  • To have a GitHub Action of linting and testing
  • Which license you want to use, etc. 

And do not forget you will no longer have to worry about those annoying configuration files everyone hates. 

Sounds good, right? Why don’t you give it a try? Here is the repo (if you want, leave a star there!) and the npm package. I hope you find it useful. 

That’s it for now.

Happy coding!