Navy's framework for Node.js webservers
Go to file Use this template
2022-11-27 23:19:42 +02:00
src get & post methods 2022-11-27 23:19:42 +02:00
.eslintrc.json add missing function + registration variable 2022-11-15 16:11:58 +02:00
.gitignore gitignore 2022-11-20 18:42:46 +02:00
example.env mongodb auth db 2022-11-24 00:06:02 +02:00
index.js meta files 2022-11-09 11:23:54 +02:00
LICENSE meta files 2022-11-09 11:23:54 +02:00
options.json registration codes 2022-11-25 00:12:45 +02:00
package.json meta files 2022-11-20 18:36:05 +02:00
README.md get user avatar + cleanup 2022-11-26 15:59:05 +02:00
yarn.lock option for not allowing creation of new accounts from oauth 2022-11-25 15:43:26 +02:00

Navy's webserver framework

A template repository for creating Node.js based webservers with sharding.
Main repository: https://git.corgi.wtf/Navy.gif/webserver-framework
Frontend: https://git.corgi.wtf/Navy.gif/webserver-framework-frontend

Technologies

  • Argon2
  • Express
  • Passport & related strategies (2FA support)
  • MongoDB & MariaDB

How to

Using the template

  • Clone the repository git clone https://git.corgi.wtf/Navy.gif/webserver-framework <project name>
  • Change the original remote name to git remote rename origin upstream.
  • Disable pushing to the upstream remote git remote set-url --push upstream no_push.
  • Add your own remote git remote add <remote name> <repository url>

Fetching the upstream changes

  • Fetch the the remotes git fetch.
  • Preview the changes git log -p HEAD..upstream/master
  • Merge changes to the current branch git merge upstream/master.
    (Use git remote -v to list remotes)

OAuth callbacks
By default any OAuth callbacks are expected at /api/login/<methodname>, where methodname is the name of the OAuth strategy. E.g. by default this framework has a discord strategy defined in Server.addAuthStrategies which expects a callback to /api/login/discord.

Endpoints
Any all endpoints should go in the /endpoints directory and are expected to inherit from the Endpoint superclass.
Endpoints have a loadOrder property that can be adjusted, lower values are loaded first.

Serving files By default the framework looks for files to serve under the /files directory, it also tries to satisfy requests to / with an index.html from /files/site. This is with the frontend in mind.

Main components

Controller: /src/controller/Controller.js
Master process, orchestrates the whole program. Takes care of starting up the shards and communication with them.

Shard.js: /src/controller/Shard.js
Manages the forked processes. Essentially a wrapper for ChildProcess.

Server.js: /src/server/Server.js
Main component that runs on the forked processes. Expects a message with a _start property with the startup options to be sent.

"Lesser" components

Authenticator: /src/server/middleware/Authenticator.js
Takes care of sessions, authentication and authorisation, relies on an implementation of AbstractUserDatabase.js.

UserDatabase: /src/server/components/UserDatabase.js
Implementation of AbstractUserDatabase.js, takes care of user management.