This is a ReactJS app, with NextJS for SSR, ExpressJS, and MongoDB for content.
- Run
npm installto install all packages
NextJS "fetch" API caches data locally (https://nextjs.org/docs/app/building-your-application/caching), so if cache exists, the MongoDB server does not need to be ran and dev (npm run dev) or prod (npm run start) can be ran directly. If the cache is empty, then a server connection must be made.
The "MONGODB_URI" environment variable must be set in ".env.local" in the project root. Do NOT commit or push .env.local.
"MONGODB_URI" is the connection string to connect to the mongoDB server.
mongodb+srv://<db_username>:<db_password>@<db_host>/?retryWrites=true&w=majority
optionally &appName=<appName>
The connection string must have a valid username, password, and host.
If working in dev for a database bug or feature:
- Connect to a localhost copy of the DB instead of the remote. If one doesn't exist run
mongodumpto create one.mongodump --host="<db_host>" --username <db_username> --password <db_password> - Run
npm run mongoto start the mongo server.- Ensure the mongodb.conf "dbPath" matches where
mongodumpdumped the DB - Run
chmod 400on the "keyFile" if a "permissions are too open" error occurs when attempting to start
- Ensure the mongodb.conf "dbPath" matches where
- Make the needed changes in the DB.
- Run
mongorestoreto "restore" the remote DB with the new local DB.mongorestore --uri mongodb+srv://<db_username>:<db_password>@<db_host>
- Run
npm run devto both build and run dev server (port 3000 by default). Hot refresh will be enabled, making changes reflect instantly upon save.
- Run
npm run buildfor prod build. - Run
npm run startto run prod server (port 8000 by default).
- Single nouns are base/container components (e.g. "Journal")
- Adjective-noun pairs are sub-components (e.g. "JournalMenu")
- Camel case all words (e.g. "Journalmenu" is invalid)