Getting Started
Last updated
Last updated
Source code for the project can be found . Use one of the following commands to clone the repo to your local machine.
HTTPS: git clone https://github.com/codyburleson/rmtn.git
SSH: git clone git@github.com:codyburleson/rmtn.git
GitHub CLI: gh repo clone codyburleson/rmtn
We recommend development with (VS Code). From within the project directory, you can launch VS Code with the following command.
On Windows, if you want to develop with the Windows Subsystem for Linux (WSL), you will need to install the WSL extension for VS Code. For more information, see .
After launching VS Code, select Terminal > New Terminal to show the terminal within the IDE. You'll need the terminal to install dependencies and to run the project in development mode, among other things.
Our habit is to work in a branch other than the main
branch and then merge into main
once work is fully tested. You can create your own unique branch to work in, or you can at least checkout the preview
branch and work with it. You can switch to the preview
branch by running the following command.
To create a new branch that is based on your currently checked out (HEAD) branch, simply use "git branch" with the name of the new branch as the only parameter. You can then "checkout" the branch to work within it.
Next, run the following command to install package dependencies.
This installs all of the node packages that are defined in the ./package.json
file, which is found in the root of the project.
After running the command, you should see a node_modules
folder in the root of the project. The node_modules
folder is never committed to GitHub because it is specified to be ignored in the .gitignore
file.
In apps/rockmtn-platform
, you will find a file called .env.local.example
. This contains environment variables that need unique values. Copy the .env.local.example
template and rename the copy to .env.local
. You can use the following command to copy and rename the file.
As you proceed with the Getting Started procedure, you'll be filling out values in this file. Environment variables that exist in this file for local development purposes must also be available as environment variables on any environment you deploy to. We'll soon go over how to do that for the main cloud server environment that we support, which is Vercel.
Because the .env.local
file contains secrets like login credentials, it is included in the .gitignore
file and will not be committed to the source code repository. Be sure to keep a secure backup of all the values needed for this file as you obtain them.
Rock Mountain uses Mongo DB Atlas for its NoSQL cloud database.
If you are working independently or with your own fork, you can sign up for your own MongoDB Atlas account and obtain your own credentials.
After signing up, you'll need to get the connection string that enables you to connect the application and use it in the .env.local
file. Here's how.
Navigate to Databases > Deployment and, click the Connect button...
Next, click "Connect your application"...
Copy the connection string found under "2. Add your connection string into your application code"...
In the .env.local
file, paste the connection string as the value for the MONGODB_URI
variable.
Replace <username>
and <password>
with credentials for a user that has readWrite
access to a database named "rmtnPreview". We recommend setting two administrative users for such access; one for the preview database (e.g. username: dev) and one for the main database, which will be created later (e.g. username: admin).
Replace the database name, "myFirstDatabase", in the URL connection string with the name, "rmtnPreview". We will later create a whole separate database for production called "rmtnMain," but don't worry about that for now.
Make sure the value for the MONGODB_DB
environment variable is rmtnPreview
.
The entries in .env.local
should now look something like this:
This is all we need to get started with the database. When the system recognizes that it does not exist, the database will be created automagically.
Note: To see how we programmatically create database collections when they do not already exist, take a look in the file, ./lib/mongodb.js
. Before we cache the connection in the global
object, we call checkAndCreateAllMissingCollections()
. For each collection that must exist the function calls checkAndCreateSingleMissingCollection()
.
If you are developing with the Rock Mountain team, you can obtain the MongoDB Atlas URL, database name, and login credentials for use in your own development environment. or another team member to obtain the information.