I'm creating a modified MEAN(MSSQL,Express,Angular,Node)
website as much from scratch as MEAN can be.
Since I've never worked with any of this before I am slow af. Oh and I'm working on my own.
please send help.

  • 1
    boilerplate all things!
  • 3
    Step 1: Use knex.js for database queries, it's pretty good if you are not working with Mongo

    Step 2: API first! Once you've established your API everything coming after is way easier

    Step 3: Work with models (Interfaces). TypeScript is very powerful to type your requests and responses. Use TypeScript for your API as well to have the same syntax everywhere. If you prefer to work with ORM based libraries like Sequelize it is also an option, although I do not personally recommend it for most use cases.

    Step 4: Once all the data can be retrieved, build your Angular frontend around the data. Your frontend should only perform API calls and have as little logic as possible.

    Step 5: If your Database is very complex, integrate another layer for business logic. This will save you a lot of frustration if applied correctly.

    Further reading:
    - Pro TypeScript: Application-Scale JavaScript Development by Steve Fenton
    - REST API Design Rulebook by Mark H. Massé
  • 1
    I also made a boilerplate with the similar purpose you've described. Feel free to check it out, contributions are always appreciated 😎

  • 1
  • 1
    @frickerg wow, thanks! I will put this to good use :)
  • 2
    @frickerg out of ignorance about other options I started with sequelize and my own way to build sql queries. knex will most probably clean things up a lot :) I'll have to look into models in typescript because I only followed the angular hero tour and a few guides before starting. I guess I'll also have to find out the business logic layer part, because there is a hell lot of complexity
  • 2
    @writeascript no sweat man, it takes time... I've been working with ORM quite a lot (not on Javascript though, so it might differ here!) and my experience was that ORM is only beneficial if you have a low throughput (so maybe a handful of queries) with very high complexity. Otherwise I would not use ORM as a replacement for actually writing and optimizing SQL queries, that approach starts to make things very dirty!
  • 2
    @writeascript you are also not forced to use models (I call them models, they are basically TypeScript classes or interfaces) but it definitely helps a lot to keep your code clean and tidy. If for example your Express API returns something and you can already specify that it will be a promise with an array of Product it can save you a lot of time.

    TypeScript is basically just JavaScript with syntactic sugar, so it does not do things that JavaScript cannot do, it just does it in a more readable fashion and you'll find errors way faster, which is why I recommend to use TypeScript everywhere instead of jumping between JS and TS all the time.
  • 2
    @writeascript and of course if you have question feel free to ask anytime. I've been clueless about all those topics a year ago, but I had to learn it in depth for my bachelor's thesis. I am very passionate about boilerplating all those things now and breaking it down for people who are new to it.

    Don't hesitate to file an issue on the github repo I've provided! The boilerplate is unfinished and I would be very happy to finish it if there are some things you'd like to see demonstrated. Also collabs are awesome so feel free to modify it for a pull request
Your Job Suck?
Get a Better Job
Add Comment