✨ This workspace has been generated by Nx, a Smart, fast and extensible build system. ✨
Each part's source code is separated into folders at /packages
; only part-5
contains 2 folders (1 for the server, 1 for the client).
You will need:
- Docker Compose (latest to support
docker compose
statement). - NodeJS LTS
- Optional: PNPM is more preferred to installing packages
Commands to setup environment:
- Install packages
# npm or yarn, based on your preference.
pnpm install
- Prepare env (from
.env.example
)
cp .env.example .env
- Build and Run docker image (MongoDB image)
npm run preconfig
You can import the API specs to the Postman to test some NodeJS/Express API directly.
Note: You also have to create environment in the Postman for host
(and _id
) variable
- Import API Specs file here.
- Create variables
host
: must be set ashttp://localhost
- Optional:
_id
you can either set this, or replace this variable in API call. This is the user_id in the database.
Each part has its own NPM command available. However, all of them are connected to a single MongoDB instance (for simplicity and time constrain). Each part should be running separately.
# [X] is from part 1 -> 5
npm run part-X
Notes:
-
ALl client code is hosted on port 4200 -
http://localhost:4200
(default of Nx, can modify inproject.json
); -
NodeJS servers are served in port they are defined in
.env
file. -
part-1
: has an API which can initiate the database records by running the following API.# You can use this API to reset the DB after tweaking with it curl --location 'http://localhost:3000/api/mock/user'
-
part-3
:part-3
must be run along withpart-2
(since it has a back-end endpoint set aspart-2
). You can run both in separate terminals. -
part-4
: You can replace the example file in.sample
directory. Although the requirement is to write a NodeJS script (trigger from terminal, I suppose), but for quick implementation, easy to use, and since the internal logic of reading file is the same, I implemented it as an API. -
part-5
: is a parallel run of 2 source code (expressjs and react). This part also have a mocking API forblogs
# You can use this API to reset the DB after tweaking with it # Amount should be 1->100 curl --location 'http://localhost:3004/api/blog/refresh?amount=100'
- The code in this repo is far from perfect, but it should be enough to demonstrate the understanding and problem-solving skill.
- Since
nx daemon
can be a little troublesome when running on Windows, in case the commands cannot start because of it, you can build the code directly (usingnx build <project name>
) and run it just like a JS code in thedist
folder. - Some error handling logic is skipped for faster implementation speed... But generally it should not impact too much