The website for the Manga and Anime Society Kharagpur (currently running in kgpmask.club)
This server requires Node.js v16.0+ to run, and all tests are performed on v16. Please upgrade to Node v16 or higher if you haven't already done so.
There are multiple ways to run the server. The vast majority of the time, you will be running it in dev mode - the command for this is npm run dev
. If you wish to run in regular mode, the command is npm start
. Note that the server run in both cases will be identical - the only difference is that dev mode will automatically refresh changes made to the server code and/or pages, while regular mode will not. In addition, you can add flags to customize the operation of the server. These are:
dev
(d): An internal flag that does the same as npm run dev
, except you lose access to nodemon. Just use npm run dev
instead.jsonuser
(t): Runs the server with the user details being defined in /src/user.json
.local
(l): Uses a local database (mongodb://127.0.0.1/mask) instead of the designated test database. Overwrites all other DB flags.mongoless
(m): Runs the server without a database connection. All database-based pages cannot be loaded. This is a superset of the userless
flag (ie; a mongoless
server will also always be userless
).prod
(p): Connects directly to the production database. Do NOT use this flag lightly; it can break many, many things if you mess up and the testing database should serve your purposes. Cannot be used in conjuction with dev mode, for security reasons.quiz
(q): Allows for infinite quiz attempts. Should be used with dev
.test
(t): Used to isolate the testing port and prevent interference with the running server.userless
(u): Runs the server without a user connection/query. All user-based pages cannot be loaded. A planned feature is to have a dummy user with a modifiable JSON file, but as of now no user exists.In order to start the server, you will require an src/credentials.json
file - contact your WebDev Team Head for this file, and do NOT share it. The only exception to this is the mongoless flag - it is recommended to use npm run dev mongoless
(or npm run dm
) for any page that does not involve database-related stuff.
You may also override the database connection string for testing purposes, like so:
MONGO_TEST_URL="mongodb://4.20.69.420/mask" npm dev
Furthermore, for those with access to multiple sets of credentials (the three existing types are admin
, member
, and github
), you can switch between sets of credentials by doing the following:
src
folder as admin-credentials.json
, member-credentials.json
, and/or github-credentials.json
(whichever of these you have).credentials.json
file (should one exist), so copy whichever credentials file you use most often (usually admin).CREDS
and set it to the prefix of the credentials file you wish to access (eg; set it to github
to use the src/github-credentials.json
file).CREDS=github npm run dev
$env:CREDS="github"; npm run dev
Note (edited): You can now connect to the database even while on WiFi/LAN without a VPN. The domain name has been whitelisted. The IP address has NOT been whitelisted for direct http/https connections.
Pages are located as .njk files in /templates. The following variables may be set:
pagetitle
: Title of the page (default MASK)pagedesc
: Description of the page (default 'MASK website')thispage
: URL of intended position of current page, used to select active page in NAVBAR (default none)scripts
: Array of script links to be loaded (default none)Additionally, the following blocks may be set:
pagecontent
: HTML contents of the page (default 'This is an empty page')customcss
: Custom CSS (remember to enclose in \