The Hither and Thither of Things

Courtney Ott
montanacodeschool
Published in
3 min readMar 12, 2019

This week, we picked a project to work on for the next 3 weeks. Abe, Haley and I are building a dream journaling app that will generate pictures based on journal entries. In theory, the pictures will help the user remember more about their dream. As dream-memories come back to them, users can elaborate upon their initial entry and experience deeper dream reflection.

As we embark on this project, I have noticed that real world things are blossoming. Like promoting synergy through Git work flow and To-Do lists and other things that evoke images of Andy Samberg swaggering around Like A Boss. In relation to said song, our process includes crying deeply but excludes having my own bathroom.

Anyway…

While Abe valiantly toiled away at authentication and Haley explored territories of keyword extraction, I worked on making a basic Express server, and some routes. I also attempted **sweet styling** that we all agree looks **diaper-y**.

Our apt comparison

My styling has fallen from grace(into supreme awesomeness) but I wanted to flesh out my other endeavors to advance my fledgling understanding. I drew a picture of what I think is happening in the relationship between the server’s route handlers, Mongoose, and MongoDB.

Data scurrying hither and thither and ideally not in a dither.

Now I’d like to write about what happened...

What happened: Made a “barebones” server, connected it to MongoDB and made some routes.

To set up a minimal server, Express and Nodemon were installed. Express was required into the server.js file and a port established and stored in a constant. Then, a listener was made that enables the app to listen for requests through the port.

Next was making scripts for starting the server in the package-json file and putting notes about that in the README.md for future convenience. Professor Weymouth prompted me to take notes in the code to remind myself of who’s who at the code party( // this does a thing, that does a thing wow!!). That was helpful.

The main things in the Server/MongoDB relationship:

Connecting to the server to MongoDB involved starting MongoDB in the terminal with brew services start mongodb, requiring Mongoose in the server file, and some other code that I won’t bore you with.

Building routes is cool. The routes enable you to do the whole CRUD dance…because you need to be able to Create, Read, Update, and Delete data! Here is a Create route…the server communicates it to Mongoose which tells MongoDB, “create a thing and if you can’t, show me an error”…

When the routes go through Mongoose(Object Data Modeling library for MongoDB), Mongoose compiles the request into a Schema that MongoDB can work with(a json-like object). Our particular schema reflects how our dream entries are structured. Each dream has a title and content both of which are “string” data types and are also required fields…

All of this is the backend part of what happens with requests and responses. The frontend is where the requests are coming from and where the responses will end up. . . so there’s a bunch of other CRUD functions and Fetch API shtuff to be added in there…but I don’t feel like completing that circle right now…

So, Auf Wiedersehen, I guess.

*>* :} :] :D

PS- For the people who in theory are reading this stuff. With these blog posts, I’d love some corrections/hints/additions/thoughts you have based on your perceived level of my understanding(like if you’re going to give feedback, keep it basic otherwise I won’t be able to relate that well). In fact, I have a suggestion for your potential suggestion(in case my demand is overwhelming)- draw on my server picture if you see something I’m missing and post a comment!

--

--