Skip to content
/ edu Public

Educational website for bootcamp grads, CS college grads, and anyone else interested in learning software craftsmanship

License

Notifications You must be signed in to change notification settings

ExoKomodo/edu

Repository files navigation

Edu

Important Links

Client - Setup

Install nodejs v22+. Using nvm is the best option.

After installing, refer to the README

Client - Run

Refer to the README

Client - Test

Refer to the README

Server - Setup

Install .Net 8

# Setup mongo creds. Feel free to make your own mongodb database and connect to that.
export MONGODB_URI="<connection string>"
# Setup object storage creds
export AWS_ACCESS_KEY_ID="DO00MM6Z43GZ4V6YX8PY"
export AWS_SECRET_ACCESS_KEY="*************************************"

Server - Run

The helper script will verify the environment you are running in. By doing so, you should be able to successfully run the server, as long as this script can run. If the script cannot successfully run, the script will proactively tell you what is wrong with the environment and why.

./run.sh

Server run on your own

Without hot reloading:

dotnet restore # Optional step, as `dotnet run` will restore as well
dotnet run

With hot reloading:

# Optional step, as `dotnet run` will restore as well
dotnet watch run

The helper script will verify the environment you are running in. By doing so, you should be able to successfully run the server, as long as this script can run. If the script cannot successfully run, the script will proactively tell you what is wrong with the environment and why.

./test.sh

Server test on your own

Without hot reloading:

dotnet restore # Optional step, as `dotnet test` will restore as well
dotnet test

With hot reloading:

# Optional step, as `dotnet test` will restore as well
dotnet watch test

Server - Mongo

Interacting with Mongo

Mongo works with a simple pattern

You have:

  1. a client, that connects to
  2. a database, that opens
  3. a collection of documents, that can be
  4. filtered, and those elements can now be either
    • retrieved
    • updated
Connecting to a collection

A collection is somewhat analogous to a table in a normal SQL database

let connectionString = Environment.GetEnvironmentVariable("MONGODB_URI")
match connectionString with
| null ->
  printfn "You must set your 'MONGODB_URI' environmental variable. See\n\t https://www.mongodb.com/docs/drivers/go/current/usage-examples/#environment-variable"
  exit 1
| _ ->
  let client = new MongoClient(connectionString)
  let database = client.GetDatabase("edu")
  let collection = database.GetCollection<Course>("courses")
Filtering items

Assuming the previous sections's collection will receive the filter

Any operations needs to be filtered, so it only applies to that subset of documents, whether it be that the operation is Get or Update

let filter = Builders<Course>.Filter.Eq("Id", "intro")
let course = collection.Find(filter).FirstOrDefault()
// NOTE: Must use `box` to convert value type like `Course`, into a reference so null can be checked
match box course with
| null -> RequestErrors.NOT_FOUND $"Course not found with id {id}"
| _ -> json course

You can make a filter without a collection. It is simply a piece of data describing a filter to apply.

Updating items

Assuming the previous section's filter

// NOTE: Should be able to chain together .Set() calls to update multiple fields at once
let update = Builders<Course>.Update.Set(
  // Pick, in an anonymous function, what field to update
  (fun course -> course.Metadata.Description),
  "Introducing you to the Edu platform, where higher learning persuades you"
)
// Filter to the element to effect, then apply the update, and ignore the results
collection.UpdateOne(filter, update) |> ignore

Server - Object Storage (s3)

Installing aws cli

Follow the instructions found here

Using s3

# Test that you can connect to s3
aws s3 ls edu.exokomodo --endpoint-url https://sfo3.digitaloceanspaces.com

About

Educational website for bootcamp grads, CS college grads, and anyone else interested in learning software craftsmanship

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks