Giter Club home page Giter Club logo

mern-work's Introduction

MernWorks

This workspace has been generated by Nx, a Smart, fast and extensible build system.

Parts:

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).

Pre-Setup:

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

API Postman

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 as http://localhost
    • Optional:_id you can either set this, or replace this variable in API call. This is the user_id in the database.

Running Code

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 in project.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 with part-2 (since it has a back-end endpoint set as part-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 for blogs

    # 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'

Troubleshoot

  • 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 (using nx build <project name>) and run it just like a JS code in the dist folder.
  • Some error handling logic is skipped for faster implementation speed... But generally it should not impact too much

mern-work's People

Contributors

namdien177 avatar namdh3-smartosc avatar

Watchers

Tung Nguyen avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.