Skip to content

Developer Tips and Tricks

Patrick Carlson edited this page Dec 31, 2020 · 16 revisions

Mongoose

The Mongoose NPM package provides the connectivity to MongoDB. See here for compatibility of Mongoose versions and MongoDB versions. Right now with Mongoose 5.X it supports MongoDB 3.0+.

nodemon

Use nodemon to automatically restart the node.js server upon code changes.

nodemon app.js

eslint

Use eslint to find stylistic and other code problems. See the .eslintrc.js config file. Run the checker using:

./node_modules/.bin/eslint .

Linting

Leverage Super Linter in offline-mode to check for code linting and format issues before it's run via Github actions. It requires Docker.

docker run -e RUN_LOCAL=true -v ~/src/kort/:/tmp/lint/ github/super-linter

Functional unit-testing with Casperjs

Run the following to run the test suite:

npm test

MongoDB management through a web UI

Install mongo-express in the main kort folder:

npm install mongo-express

Start the app with:

node app.js

View the web UI via: http://localhost:8081

Alternatively, Robo3T is a nice Open Source desktop client as well.

Docker

Check if the Kort and Mongo containers are running:

sudo docker ps

Making a Release

Edit package.json and rev the version.

Use a git tag with the appropriate version string (e.g. "v1.0.1"). Push the tag up to Github. This will automatically create a release in Github and publish a release to npmjs.com via a Github action.

https://www.npmjs.com/package/@carlsonp/kort

Checking for package.json updates

Utilize the npm-check-updates package to update the package.json file.

npm install -g npm-check-updates
ncu
ncu -u

Then run the following to install these updates packages.

npm install