DEV Community

Stop repeating work and Start coding your express API 🚀

Mahmoud Ashraf Mahmoud on July 14, 2020

Too much wasted time 🙁 Think about every time you started a new Express API. you start by creating a new folder, initialize npm, install...
Collapse
 
ssimontis profile image
Scott Simontis

I feel like Express is a framework for writing web frameworks. It is so low-level and every method becomes so repetitive, that unless you or your company have a solid library built on top of it already, it is one of the most unproductive solutions for a server.

For really simple CRUD apps, I think it would be cool to see a database schema transformed into a REST API. Not applicable most of the time, but totally automated when required.

Collapse
 
uptotec profile image
Mahmoud Ashraf Mahmoud

I'm pretty new to node.js with less that a full year of experience. and we I get started I found express is the most used library with node.js when it comes to building REST API's. so I started using it and I did't expose to any other alternative. and I guess Google Firebase implements the idea that you are taking about, but it has a lot of limitations. I see it with express like you trade the simplicity for the more functionalities you get over something like FireBase.

Collapse
 
stagfoo profile image
Alex King

I think there are some solutions that do just that if you look around, you can also try json-server for really simple apps

Collapse
 
aghost7 profile image
Jonathan Boudreau

Yea, there are more complete frameworks like eggjs and nest.

Collapse
 
joserocha3 profile image
Pablo Rocha • Edited

Hasura.io does almost that. Creates a graphql API from your postgres schema.

Collapse
 
drazisil profile image
Molly Crendraven

Thanks for the article. This is motivating me to look at yeoman again and make a template. You are correct, so much repeated time wasting work to start a new project.

Collapse
 
uptotec profile image
Mahmoud Ashraf Mahmoud

Yup, it seems like 5 or 10 mins but in really it becomes too much when the number of projects increases. I didn't know about yeoman before but it seems like a pretty good tool and it would've been saved a lot of time with me, but it was fun coding it from scratch 😅

Collapse
 
drazisil profile image
Molly Crendraven

In the end, the fun is what really matters :high-five:

Collapse
 
chukwuemekaigbokwe profile image
Chukwuemeka Igbokwe

There is already a framework for that. You can check out Expresswebjs github.com/Alexigbokwe/ExpressWebJs

Collapse
 
uptotec profile image
Mahmoud Ashraf Mahmoud

I took a look on the repo and I see a great work and effort with pretty good ideas ❤️. And I see that you are the author so if you don't mind we can work together to build a better library to server this purpose😀

Collapse
 
mustaphee profile image
Yusuff Mustapha

+1 contributor, if you guys are willing to team up! I have also done something like this

Thread Thread
 
uptotec profile image
Mahmoud Ashraf Mahmoud

I'm ready whenever you are ready 🤝

Thread Thread
 
hanzlahabib profile image
hanzlahabib

Count me in..
Don't go through my repo 😅

Collapse
 
chukwuemekaigbokwe profile image
Chukwuemeka Igbokwe

That will be nice, we are happy to release the new version of Expresswebjs. You can check out the website at expresswebjs.com for documentation and use.

Collapse
 
zluther89 profile image
Zach • Edited

I could be wrong, but I don't think cors module is needed by default, I think the setup you have for cors is what express already does by default, the cors module is only needed if you need to make exceptions.

Collapse
 
uptotec profile image
Mahmoud Ashraf Mahmoud

When I started using expess i spent a whole day trying to receive requests from the browser with react js. I was sending requests to the backend with postman and it works fine but it doesn't receive and requests from the browser. And then I found that to be able to receive browser requests you have to use the cors module. So I thought it would be convenient to add it by default as most of express API's will be consumed by some sort of a frontend which may work on a browser 😅

Collapse
 
zluther89 profile image
Zach

It depends on if the server is hosting the page or not. But yeah I see what you mean, makes sense! Really cool project 🤗

Collapse
 
ralphkay profile image
Raphael Amponsah

Really helpful. Its a crazy orchestra with setp these days.

Collapse
 
miteshkamat27 profile image
Mitesh Kamat

Great effort !!!

Collapse
 
uptotec profile image
Mahmoud Ashraf Mahmoud

Thanks 😀.

Collapse
 
spiritupbro profile image
spiritupbro

no i code web in c++

Collapse
 
uptotec profile image
Mahmoud Ashraf Mahmoud

Coding isn't limited to one language and this is one of the reasons why I love coding so much. Pick the language that you want and do whatever you want. Maybe some languages are better in sertin fields, but you know it's doable with any language if you want. Personally, I chose JavaScript because, the same idea of having a language that works everywhere and JavaScript has a solid fremeworks/libraries on every feild. This isn't making it the best solution, but if you are like me working frontend, backend and even mobile development I guess having a one language to do all of them is a great thing to have 😅

Collapse
 
spiritupbro profile image
spiritupbro

yes sir i got you i just joking no way i use c++ as backend also

Collapse
 
michi profile image
Michael Z

It sounds like a lot of fun to build such a tool. Personally, I will just stick with Adonis though, it comes with most things you need for your average app.

Collapse
 
uptotec profile image
Mahmoud Ashraf Mahmoud

Sadly, I didn't try it till now, but surely I'll give it a try soon. thanks 😀

Collapse
 
uptotec profile image
Mahmoud Ashraf Mahmoud

thanks, it's now updated! 😃

Collapse
 
uptotec profile image
Mahmoud Ashraf Mahmoud

Now in V 1.2.0 you can create Typescript project with TsLint and Prettier configuration 😀

Collapse
 
uptotec profile image
Mahmoud Ashraf Mahmoud

I didn't work with typescript in the backend before I only did it in the frontend, but I guess now is the perfect time to do it and I will try to add it today. Thanks 😊