Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion books/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:latest
FROM node:alpine

COPY . /src

Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file added sample-pics/post-new-book.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample-pics/post-new-video.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample-pics/search-books.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample-pics/search-default.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample-pics/search-depends-on.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample-pics/search-videos-by-regex.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion search/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:latest
FROM node:alpine

COPY . /src

Expand Down
18 changes: 18 additions & 0 deletions search/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion videos/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:latest
FROM node:alpine

COPY . /src

Expand Down
2 changes: 1 addition & 1 deletion web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:latest
FROM node:alpine

COPY . /src

Expand Down