diff --git a/books/Dockerfile b/books/Dockerfile index 2d270bf..c5ee15d 100644 --- a/books/Dockerfile +++ b/books/Dockerfile @@ -1,4 +1,4 @@ -FROM node:latest +FROM node:alpine COPY . /src diff --git a/readme.md b/readme.md index dbff4ad..bf8432f 100644 --- a/readme.md +++ b/readme.md @@ -21,3 +21,7 @@ communication. Docker containers = good for almost all project sizes Microservices = good for big companies with a lot of code and people Sweetspot = Monolith app and databases in containers + +## Tests + +You can check out sample test cases via postman on sample-pics folder diff --git a/sample-pics/post-new-book.PNG b/sample-pics/post-new-book.PNG new file mode 100644 index 0000000..fd58125 Binary files /dev/null and b/sample-pics/post-new-book.PNG differ diff --git a/sample-pics/post-new-video.PNG b/sample-pics/post-new-video.PNG new file mode 100644 index 0000000..f706631 Binary files /dev/null and b/sample-pics/post-new-video.PNG differ diff --git a/sample-pics/search-books.PNG b/sample-pics/search-books.PNG new file mode 100644 index 0000000..bef578b Binary files /dev/null and b/sample-pics/search-books.PNG differ diff --git a/sample-pics/search-default.PNG b/sample-pics/search-default.PNG new file mode 100644 index 0000000..b14084a Binary files /dev/null and b/sample-pics/search-default.PNG differ diff --git a/sample-pics/search-depends-on.PNG b/sample-pics/search-depends-on.PNG new file mode 100644 index 0000000..9dbebec Binary files /dev/null and b/sample-pics/search-depends-on.PNG differ diff --git a/sample-pics/search-videos-by-regex.PNG b/sample-pics/search-videos-by-regex.PNG new file mode 100644 index 0000000..cd2d2ba Binary files /dev/null and b/sample-pics/search-videos-by-regex.PNG differ diff --git a/search/Dockerfile b/search/Dockerfile index 2d270bf..c5ee15d 100644 --- a/search/Dockerfile +++ b/search/Dockerfile @@ -1,4 +1,4 @@ -FROM node:latest +FROM node:alpine COPY . /src diff --git a/search/src/app.js b/search/src/app.js index e46f78a..e31c765 100644 --- a/search/src/app.js +++ b/search/src/app.js @@ -24,6 +24,24 @@ app.get("/api/v1/search", async (req, res) => { res.json(videos.concat(books)); }); +// Search spesific named books +app.get("/api/v1/search-books/:name", async (req, res) => { + const booksPromise = Book.find({name: {$regex : '.*' + req.params.name + '.*'}}); + const promises = [booksPromise]; + const [books] = await Promise.all(promises); + + res.json(books); +}); + +// Search spesific named videos +app.get("/api/v1/search-videos/:name", async (req, res) => { + const videosPromise = Video.find({name: {$regex : '.*' + req.params.name + '.*'}}); + const promises = [videosPromise]; + const [videos] = await Promise.all(promises); + + res.json(videos); +}); + /* Calling other services from a service is dangerous. If those services make their own calls there is a chance diff --git a/videos/Dockerfile b/videos/Dockerfile index 2d270bf..c5ee15d 100644 --- a/videos/Dockerfile +++ b/videos/Dockerfile @@ -1,4 +1,4 @@ -FROM node:latest +FROM node:alpine COPY . /src diff --git a/web/Dockerfile b/web/Dockerfile index 2d270bf..c5ee15d 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -1,4 +1,4 @@ -FROM node:latest +FROM node:alpine COPY . /src