Skip to content

Structure

Ksawery Chodyniecki edited this page Oct 3, 2021 · 4 revisions

Main files and directories

app.js

Main file of the application, reads config, connects to database, starts session and hosts the app. Handles index and 404 pages.

routes/

Handles all routing to specific pages (currently divided between notes and users).

models/

Describes the structure of tables present in our mongoDB (currently representing note and user records), and exposes them for further use in application.

controllers/

Contains handler functions for the routes directory - here data from the database is restructured, formatted and rendered.

noteController.js

  • note_get - gets all notes of a user and lists them
  • note_details - renders edit view of a note
  • note_create_get - renders note creation form
  • note_create_post - assigns note to user and saves it to the DB
  • note_delete - (does not work) deletes a note
  • note_update - (does not work) updates a note

userController.js

  • user_register_get - renders registration form
  • user_register_post - validates user and saves to database
  • user_login_get - renders login form
  • user_register_post - validates credentials and starts session for user
  • user_logout_get - logs user out

session/

Stores session data in separate files for each session, in json format.

views/

Contains templates of HTML pages, which will be presented to the user when rendered.

public/

All static resources are stored here, among which are vector images and CSS files.

Clone this wiki locally