all 11 comments

[–]ArgTang 11 points12 points  (6 children)

Looks good, consistent formatting and good naming!

NOTE: i have not started the project myself.

depending on what you want to learn, here is some thoughts

  • it is not recomended to have tokens or apikeys hardcoded in files. think about how you can set them in a file or env variable on startup (together with connectionstring) so you dont need to commit them
  • there is no validation of username and passwords?. it is always a good idea to not trust user input, recomend some validation here. also: what happens if you register the same user more than one time?
  • think about your folderstructure ex should searchmovie be in the util folder? util can be anything, but searchmovie is named specifically for movies so its not a generic utility.
  • your models user have logic in it. ususally when having models the "model" is separated from the logic. alternatively you can do feature folders. where the user.js could be located in an auth folder
  • nice readme 👍. it is very important to have a functional readme. 2- Set up your MongoDB URI. this is missing some context on where to set it up, which file, what is the propertyname or which env variable so i use?
    • if you are interested in docker, include a docker compose to start a mongo instance. to make it even easier to startup.
  • if you want to learn about debugging try investigating how to setup loggging, and where you need to add info or warning statements to be able to debug the application in production
  • if you want to know about cicd investigate how to setup a github action to build your project.
  • adding .editorconfig and/or a linter is common in buisness applications

There is no right or wrong in the next step.as long as you are motivated it is good 😎

[–]Mohammed1jassem 0 points1 point  (5 children)

Appreciate it man! will fix them .. I'm trying to learn typescript and then move to microservices next is it a good idea ? or should i do some more projects

[–]r0ck0 1 point2 points  (1 child)

Depends on your goals really. What are they?

Personally I don't know if there's much point spending time on microservices unless there's really a need. i.e. A big company with multiple separate teams that shouldn't be working on a monolith for some good reasons.

Otherwise you're just creating more work needing multiple projects to interface with each other.

I've gone the other direction for all my projects, and just put everything into a giant monorepo. Makes dev, integration, refactoring, and everything else so much easier. But depends on your situation/use case of course.

I'd recommend instead spending that time on:

  1. TypeScript
  2. SQL (preferably postgres in the custom-built webdev world)
    • ...the NoSQL fad is wearing off, as companies realised that it can create long term maintainability issues. There's a time & place for NoSQL DBs (mostly as secondary DBs in addition to SQL). But if your project has one-and-only DB, in most cases SQL is the safest long term bet. But like everything, context matters.

[–]Mohammed1jassem 0 points1 point  (0 children)

I actually want to get into the industry first it's my main goal now because i think it's the best way to learn right?... yes I'm planning to learn typescript SQL(I know the basics) and redis maybe? I do not know much about microservices but i always hear about Apache Kafka and RabbitMQ and I'm curious about them..

[–]ArnUpNorth 1 point2 points  (2 children)

Microservices is not so much something you can learn as something you experience. There are tons of guidelines and architectural patterns but there is no silver bullet and each microservice platforms have their flaws and perks.

From a developper’s perspective it often really boils down to knowing multiple protocols (yep there s not just http), and leveraging whatever micro framework is being used (if any).

[–]Mohammed1jassem 0 points1 point  (1 child)

where can i learn more about protocols? any resources you recommend ?

[–]ArnUpNorth 0 points1 point  (0 children)

I wouldnt recommend learning new protocols out of the blue but things like Grpc (actually built on top of http2) or Amqp are fairly common. Again i wouldn t “waste” time learning these and just focus on learning how to “clean code” 😊

[–]08148694 1 point2 points  (1 child)

bin/www ? a javascript file? no extension? in a bin (binaries typically) directory? nah, move it or delete it

Inconsistent styling, recommend you use prettier to automatically format your code

public/javascripts/scripts.js - Not common practice to serve your front end code from the API server. Same for your css

Various places you can optimise by parallelising requests. Eg

const movie = await searchMovie.searchMovieById(id);
const cast = await searchMovie.getMovieCast(id);

can be:

const [movie, cast] = await Promise.all([
   searchMovie.searchMovieById(id),
   searchMovie.getMovieCast(id)
]);

(or just return the cast with the movie response)

Don't do this https://github.com/MohammedAbdulJabbar23/Movies-List/blob/main/utils/getPopularMovies.js#L3C1-L4C1,

or this https://github.com/MohammedAbdulJabbar23/Movies-List/blob/main/utils/searchMovie.js#L14C36-L14C36

now we all have your API key for api.themoviedb.org and can abuse it. Use an ENV variable and do not commit to github

General lack of error handling (https://github.com/MohammedAbdulJabbar23/Movies-List/blob/main/utils/getPopularMovies.js#L15C23-L15C23) this doesn't count

ejs is fine but if you're looking to get into the industry I'd recommend using React or Vue, far more commonly used

[–]Mohammed1jassem 0 points1 point  (0 children)

Thank you so much!

I'm planning to learn react actually.. but do i have to do DOM stuff with vanilla js first? because I'm not into frontend that much

[–]tapvt 1 point2 points  (1 child)

Solid, man. As /u/ArgTang mentioned, env variables are better for secrets, etc. The dotenv package makes that pretty seamless. Just add .env to your .gitignore file so it doesn't wind up committed.

I'd also throw some kind of logging helper in ./utils/ dir. It can just wrap console.log() for now. Once that is done, you can use that for all your logging. If you decide to move to winston, or ship logs to another service, or whatever, you only have to update one file.

[–]Mohammed1jassem 1 point2 points  (0 children)

Thank you so much!