Skip to content

bargoldi/nodejs-typescript-seed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nodejs-typescript-seed

NodeJS, typescript based seed. (Micro-services intended)

Usage

Clone the repository:
git clone https://github.com/bargoldi/nodejs-typescript-seed.git

Run the basic server:
npm start

Why?

Let's take an example.

You just started a new project and you have a TS interface, named User.
Today, this User interface contains only 2 fields - id and name.

Now, after some progress, you heard of Micro-Services and chose to adapt the concept.

In a new service you will be using the same User interface. So far so good.
BUT! In a few months you will be using a few more services and a few of them even use the same old User interface! Still, so far so good.

Oh, but now your friend says - "Hey Bill, what about the users' phone number?".

I guess you got my cynical voice shouting - "Code re-usage!, SOLID!"

Code re-usage and extensibility are troubling us all, especially in the matter of Micro-Services

This seed is going to help you initiate your project based on the Micro-Services approach.

Take a look at the models directory. It has it's own package.json, tsconfig.json, etc...
That's because one day, those interfaces will be used in another service.
And no, I'm not going to initiate a new SERVICE just for those models. So I'd just bundle them up and npm publish them to some private repository.

How?

As I mentioned above, the 'extensible' modules are going to have their own packaging system.
What the seed really does is actually installing those modules as dependencies and not using them as part of the project.

Notes

  • Don't forget to include package.json, tsconfig.json, etc... in a new module
  • Don't forget to use the modules as dependencies and not as locals
  • Don't forget to use UMD imports of TS instead of relative paths
  • The seed initializes an Express app but you are free to use pure NodeJS, KoaJS, etc...

About

NodeJS, typescript based seed. (Micro-services intended)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published