Skip to content

luminosityleds/server

Repository files navigation

luminosity-led

Control brightness and color of LEDs

codecov

Install Recommended/Required VSCode Extensions

https://code.visualstudio.com/docs/editor/extension-marketplace#_recommended-extensions Install all of the VSCode extensions

  1. Ctrl + Shift + P (Open the Command Pallete)
  2. Extensions: Show Recommended Extensions
  3. Click on the cloud icon to "Install Workplace Recommended Extensions"

Getting Started

Once you have downloaded and installed Node.js on your computer, let's try to display "Hello World" in a web browser.

The code tells the computer to write "Hello World!" if anyone (e.g. a web browser) tries to access your computer on port 8080.

Command Line Interface

Node.js files must be initiated in the "Command Line Interface" program of your computer.

How to open the command line interface on your computer depends on the operating system. For Windows users, press the start button and look for "Windows Powershell", or simply write "powershell" in the search field.

Navigate to the folder that contains the file "helloWorld.js", the command line interface window should look something like this:

C:\Users\Your Name>_ Initiate the Node.js File The file you have just created must be initiated by Node.js before any action can take place.

  1. Make sure you are at the root of this directory
  2. Start your command line interface, write node helloWorld.js and hit enter:

Now, your computer works as a server!

If anyone tries to access your computer on port 8080, they will get a "Hello World!" message in return!

Start your internet browser, and type in the address: http://localhost:8080

You can exit out of the script running by pressing Ctrl + C

Getting Started with TypeScript

Run all commands as an admin in the root of the server directory

  1. Download typescript globally npm install -g typescript
  2. npm install
  3. For Development ( all TS files in ./src ): npm run devStart
  4. For Build ( all JS files in ./build ): npm run build
  5. For Production ( all JS files in ./build ): npm run start
  6. package.json are where the scripts are configured
  7. tsconfig.json defines that the built JS code populates in ./build and that the source directroy is ./src

Getting Started with MongoDB on Development Machine

Talk with Aaron or Jason for credentials.
IMPORTANT: Do not push the credentials up to Github

Run all commands in the root of the server directory

MongoDB is the database that the project is using and a connection can be established to the server using nodeJS.

  1. Get the credentials from Aaron or Jason
    1. MONGO_INITDB_ROOT_USERNAME
    2. MONGO_INITDB_ROOT_PASSWORD
    3. MONGO_INITDB_DATABASE
  2. Open a Git Bash terminal in VScode
  3. export MONGO_INITDB_ROOT_USERNAME=<username>
  4. export MONGO_INITDB_ROOT_PASSWORD=<password>
  5. export MONGO_INITDB_DATABASE=<database>
  6. npm install
  7. npm run devStart
    1. PASS:
      0 connecting 2 connected 1 disconnecting 3 disconnected 0
    2. FAIL:
      0 connecting 2 disconnected 0 C:\Users\<machine>\git\luminosity-led\server\node_modules\mongodb-connection-string-url\lib\index.js:111 throw new MongoParseError('URI contained empty userinfo section');