DEV Community

Cover image for I would love feedback on my TypeScript skills and NPM Module.
DeChamp
DeChamp

Posted on

I would love feedback on my TypeScript skills and NPM Module.

I wrote a post about my first public module plugin, but since then I've re-written most of it using TypeScript. It could definitely use some input as I'm only on week 3 of TypeScript.

The NPM module I built is for express routing. It will let you create your routes via a config file, as well as setup your middleware, across all routes or per route.

NPM module - @dechamp/express-auto-route

It comes packaged with 2 optional middleware for both request and response.

The middleware will enable options in the config to allow you to point to Json Schema, which will validate your input to ensure it's qualified.

It can be configured to work against query, body and params (express path :yourVar).

I plan on adding more TypeScript typings throughout the code, eventually doing away with "noImplicitAny": false.

Please feel free to import it to your project, play with it and let me know if it was easy to implement. How was the README.md file? Did it all make sense?

I understand express is already very easy to use and this package won't have any value to some people, and that is ok. That is not what I'm asking to hear. I'm asking for tips on improve my TypeScript skills, how the package could be improved and if it made your life easier.

NPM module - @dechamp/express-auto-route

Thank you so much!

Top comments (3)

Collapse
 
cubiclebuddha profile image
Cubicle Buddha

I love that you’re adding to the TypeScript ecosystem. Here are some things I noticed:
1) you provide a way to utilize JSON Schema for the request and response but most APIs (that I’m aware of) utilize OpenAPI/Swagger Spec which is essentially JSON Schema. The advantage that OpenAPI has is that it allows you to describe much more than the request and the response. I believe it allows you to detail the headers, the parameters, and even the error codes that API might return.
2) There is a popular library called tsoa that already lets you generate APIs and their OpenAPI Spec files based off of configuration (well actually decorators). If you’re passionate about helping to make TypeScript a more popular server side language, then maybe consider helping out with tsoa?
3) Your code looks pretty great! :)

Collapse
 
dechamp profile image
DeChamp

Thank you! It's been fun so far. So I've defaulted to Openapi many times in the past and I still do for other projects.

I started with json schema middleware because AWS gateway uses it and for many developers, they are comfortable with it as well, but i didn't see a huge push for it.

I wanted to tackle that as a first project. This plugin was aimed as convenience of setting up projects quickly but mainly aimed as a "can i do this and get it to NPM". So that is a little info behind that.

With that being said, I think you're right. It would be great to be part of a well supported plugin. I will look at it and see if I can start adding to it.

Thank you for the feedback!

Collapse
 
cubiclebuddha profile image
Cubicle Buddha

Awesome! :)