- Express.js - framework
- MongoDB - database
- Mongoose - object modeling
- Axios - http client
- cors for Express.js - middleware
- nodemon - development dependency
Install and run the backend using npm install
, then npm run app
, or simply run npm run backend
from the project root folder.
Add environment variables to an .env
file in the backend folder.
# .env
## MongoDB connection string
DB_URI = "mongodb://<username>:<password>@<host>:<port>/<database>"
## Optional variables to use in development
API_URI = "https://dev.api.ntnui.no"
MAIN_BOARD_ID = 9
ELECTION_COMMITTEE_ID = 10
Set up a cluster and database on MongoDB Atlas and add the credentials to the .env
file.
- Log in to MongoDB
- Find the database you created on MongoDB Atlas
- Go to "Network access" in the tab to the left
- Click "Add IP address"
- Open for all IPs or click "Add current IP address"
- Click "Connect"
- Click "Connect using MongoDB Compass"
- Ignore step 1, copy the connection string
- Create an
.env
file in the backend folder and paste the connection string in theDB_URI
variable - Change
<password>
to the database password you set in Part 4 of the MongoDB Atlas guide