Skip to content

Latest commit

 

History

History

README.md

Compiling and running the project

```
NPM/YARN INSTALL: Initialise all the node modules
NPM RUN "<Command>" ...
YARN <Command> ...

<Commands>
"clean": To dist folder and files,
"copy-assets": To copy custome files to a folder,
"build": Build project to dist folder,
"lint": lint and fix TS and JS issues,
"serve": run the project,
"tsc": Typescript compiler,
"tsc:w": Watch and compile anything that changes,
"dev:start": Start and debug,
"dev": Develop and watch for file changes restarting node,
"start": "npm run serve",
"debug": Debug application through CHROME plugins,
"test": Jest test with coverage,
"test-build": Deploy just tests,
"test-watch": Watch for test changes
```

Docker Dev

  • Download docker and install it on your local operation system

  • https://docs.docker.com/get-started/part2/ documentation

  • Within the local .env file, make sure you comment out the MONGO_URL=mongodb://localhost:27017 and uncomment the MONGO_URL=mongodb://mongo:27017 for mongo to be run through the docker container, otherwise this file will be packaged with the wrong environment settings and not be able to share data out of the container.

  • Run to start docker compose

    # to start
    docker-compose up
    
    # to stop
    docker-compose down 
  • Here are the images related to Node Node Images

  • In a production deployment of docker, there would be a requirement to preserve the data on subsequent deployments. Within the docker compose file, you will need to uncomment the data section, see docker-compose.yml for more comments in the file and create an empty data folder in the root, if it does not already exist. NOTE trying this on Windows or Mac is not supported as there is a bug mapping to the vbox or hyperv within these environments and as a result the data is not able to be bound together to the outside.

  • Finally if there is no Mongo Compass installed locally, there is an option to see the Mongo data using Mongo Express on localhost:8081 as below. "Mongo-express"

Creating a Typescript Node project

"V2 Mongo driven API"

"Code coverage output"

Final thoughts

I really enjoyed working with Node, something I have used as a backing framework on Angular and just for mocking services and testing front ends. Typescript seemed to cause me problems for debugging and testing, but I think I can improve this experience more in later versions. Nock, Jest and Super Test are libraries I will utilise in my other web projects bringing so much to mocking HTTP endpoints. I was a little disappointed with the speed of Mongo with Node, expecting faster results but I think there may be room for enhancement, placing it on Ubuntu and initiating more indexes. I would like to say, in their favour that it is something I have done and will try to improve it.