Skip to content

Sink-or-be-Sunk/Websocket_Server

Repository files navigation

Sink or be Sunk Websocket Server

TypeScript version Node.js version APLv2

Tools and Configurations:

Getting Started

This project is intended to be used with the latest Active LTS release of Node.js.

Clone repository

To clone the repository, use the following commands:

git clone https://github.com/marndt26/SobS_Web
cd SobS_Web
npm install

Download Volta

Volta is used to ensure that all team members are using the same javascript tooling and environments.

  • For more info see Volta

for Unix environment, Install with one command:

curl https://get.volta.sh | bash

Project Setup

  • npm i
    • npm audit or npm audit fix if needed
  • npm run build → for building the project
  • npm run watch → for starting server in development mode
  • npm run start → for starting server in production mode

Configure Prettier Formatter

  • Select VS Code -> View -> Command Palette, and type: Format Document With
  • Then Configure Default Formatter... and then choose Prettier - Code formatter.

Setting up Typescript

  • npm i -g typescript

Tools

Cloudflare Tunnel

For testing the server with the microcontroller, it is helpful to expose the localhost server to the internet. Cloudflare is a server that allows for this. More information can be found here

To start the tunnel:

npm run watch
cloudflared tunnel --url localhost:3000

Mongosh

This project used a MongoDB backend database. To interact with the local version of the database, you can use mongosh.

Download

  • WSL

    • Follow this tutorial
    • may need this command sudo chown -R id -un data/db
    • also may need to delete sudo rm /tmp/mongodb-27017.sock to fix a permissions issue

Helpful commands

start mongod:

mongod --dbpath /data/db

mongosh:

use command description
connect mongosh connect to mongo shell (must have already started mongod in another process)
navigation use <db-name> equivalent to cd into a database directory
list db.<collection>.find({"doc_property": "query"}) equivalent to ls for a database collection with an optional query parameter
delete db.<collection>.deleteOne({"doc_property":"query"}) equivalent to a rm with a query parameter for a certain doc property
delete all db.<collection>.deleteMany({}) removes all documents in a collection

for more information view the MongoDB documentation

Available Scripts

  • start - deploy application,
  • build - build application,
  • dev - start application in development mode with live server reload
  • TODO: NEEDS UPDATING: THERE ARE MANY MORE (SEE PACKAGE.JSON)

References

Running Node Locally

  • Install Node Binaries
  • create powershell alias for node
    • echo $profile to find where powershell profile is located
    • create/modify file to include the following:
      • Set-Alias -Name node -Value C:\path\to\node.exe
      • Set-Alias -Name npm -Value C:\path\to\npm.cmd
      • Set-Alias -Name npx -Value C:\path\to\npx.cmd
    • Add .npmrc file to root of project folder with the following line
      • scripts-prepend-node-path=true

License

Licensed under the APLv2. See the LICENSE file for details.

About

"Sink or be Sunk" Web Sever in charge of fulfilling game requests

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published