A Node.js/Express/Handlebars mock web application for testing the Web eID browser extension.
-
Install the latest LTS version of Node.js - https://nodejs.org
- Windows: Install Node.js via the official installer.
- Linux and MacOS:
- Option 1: Install Node.js and NPM via the official Node.js installer and optionally configure NPM global package path manually.
The following steps can be skipped when running the project locally and when you don't need global packages! The following steps configure the NPM global package path, so that installing packages globally and running them does not require root orsudo
. If you wish to run this project as a service on a server, then the recommended approach is to use a globally installed PM2 and then the following steps are necessary.- On the command line, in your home directory, create a directory for global installations:
mkdir ~/.npm-global
- Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
- In your preferred text editor, open or create a
~/.profile
file and add this line:export PATH=~/.npm-global/bin:$PATH
- On the command line, update your system variables:
source ~/.profile
- To test your new configuration, install a package globally without using
sudo
npm install -g pm2
- On the command line, in your home directory, create a directory for global installations:
- Option 1: Install Node.js and NPM via the official Node.js installer and optionally configure NPM global package path manually.
- Option 2: Install Node.js and NPM via NVM (Node Version Manager). This option is recommended by NPM, but unless you need to switch between different Node.js versions quickly, I would recommend the first option instead. Manual configuration is more transparent.
-
Clone the project
git clone [email protected]:web-eid/web-eid-webextension-mock-webapp.git
-
Install dependencies
cd webextension-service-mock npm install
-
Start the service
npm run start
-
Optionally use
ngrok
to serve your locally running service mock on an HTTPS connection. Getngrok
from https://ngrok.com/ and run it in a separate terminal.ngrok http 3000 --region=eu
It should display something similar to this:
Session Status online Session Expires 7 hours, 59 minutes Version 2.3.35 Region Europe (eu) Web Interface http://127.0.0.1:4040 Forwarding http://e569eb9def37.eu.ngrok.io -> http://localhost:3000 Forwarding https://e569eb9def37.eu.ngrok.io -> http://localhost:3000
From there, use the HTTPS forwarding URL for testing.
During development, start the service via npm run dev
, this will:
- Watch for changes in the project files
- Run the linter when changes occur
- Automatically restart the service