Exam Assignment 2

A02: CRUD Code Snippets

In this assignment, you will create a web application for persistent handling of programming code snippets using an application framework and an object data modeling library for MongoDB.


The application in Node.js will use Express as the application framework and Mongoose as the object modeling library. The application must have full CRUD functionality regarding snippets, whereby a user must be able to create, read, update and delete snippets.

Users must be able to register and login to the application after entering a username and a password. A user cannot register an already existing username because the username must be unique to the application. A logged in user must be able to log out of the application.

Anonymous users should only be able to view snippets. Authenticated users, in addition to view snippets, must also be able to create, edit and delete their snippets. No one but the authenticated user should be able to create, edit and delete their snippets. Because of this, the application must support some basic authentication and authorization. On the server-side you may only use plain session storage, using the express-session package, to implement authentication and authorization. You must not use any packages such as Passport, etc., to authenticate or authorize.

When writing and presenting snippets, the application must support multiline text, enabling the user to write real code snippets, not just a one-line text string. The application should be easy to understand, meaning that the users should get clear notifications on what is going on in the application (eg. using flash messages).

If a user tries to access a resource that requires the user to be logged in, the application must return the status code 403 (Forbidden). Of course, when necessary, the application must also return the status code 404 (Not Found) as well as 500 (Internal Server Error).

As far as possible, the application must be protected from vulnerable attacks. Be prepared to explain and defend your solution at the oral hearing.

As always, we have the following requirements:

  • The application should be written as a JavaScript application following the JavaScript Standard Style code standard, using the Express API, running on the Node.js platform.
  • The only command that the examiner will need to execute to run your application after cloning it from GitLab is npm install and npm start.
  • You must use GitLab, and make several commits, to show how your completed assignment has evolved from the start to the end.
  • To announce that you have completed the assignment, you must create a release of your examination repository on GitLab. If a release is missing the examinators will not grade your assignment.


You are free to set up your development environment. You will need a database connection. You are free to use Docker or a connection-string to mLab (see the database connection text for more information)

Extra features [optional]

For those who want to expand functionality in the application and get an extra plus on the assignment, feel free to do that. Some examples of this could be:

  • Add support for tagging each snippet by one or more tags.
  • Add support for just showing snippets that's belongs to one tag or/and one user.

Get going

This is how to get going with the assignment.

1. You have a git repo on GitLab named "a02-crud-code-snippets", available below your lnu student acronym in the course at GitLab. Start of by cloning the repo to your computer ("xxx" is your lnu-username):

# Using ssh
git clone git@gitlab.lnu.se:1dv523/student/xxx/a02-crud-code-snippets.git

2. Write your code in the repo, commit and push it to GitLab.


This assignment is graded as A-F and it is worth 3.0 credit/hp.

These are a few notes on how your submission is graded.

Grade E, D

Fulfill all mandatory features and requirements to a satisfactory level where they work as expected.

Document all your features in the report page and present your solution with a proper video.

Grade D, C

As above and your application, documentation and presentation has a high level of quality.

The outcome is visual appealing and has a high level of usability.

Grade B, A

Your application, documentation and presentation has an excellent level of quality, usability and fulfillment of all the features and their requirements.

You have implemented and explained some optional/added feature.


You are to record a video presentation of your project where you show how your project implements the features and fullfills the requirements. You should also present a few highlights from your source code and elaborate on why you feel the code is good/bad.

The video scene should contain a cam where your face is visible.

The tool OBS is a free and opensource tool you can use to record the presentation video.

The video should be 3-7 minutes.


This is how to submit this assignment.

  1. Write in the repo README.md and answer the following questions. Write freely with 15 to 30 sentences of text.

    1. Describe the architecture of your application. How have you structured your code and what are your thoughts behind the architecture?

    2. How was it to work with persistant data in this assignment, can you relate to other databases you might have learned before?

    3. Are you satsified with your application? Does it have some improvement areas? What are you especially satisfied with?

    4. What is your TIL for this course part?
  2. Add a tag v1.0.0 to the repo. Add another tag if you make update, tag like v1.0.1 or v1.1.0 and so on.

  3. Ensure you have committed and pushed all your changes, including the tags, to your GitLab repo.

  4. Add an issue to the assignmentrepo if you have any question to the teacher. The teacher will check your issues during grading the assignment.

  5. Ensure that the README.md contains any essential details for grading, installing, starting, configuring your submission.

What is a TIL? TIL is an acronym for "Today I Learned" which playfully indicates that there are always new things to learn, every day. You usually pick up things you have learned and where you might have hiked to a little extra about its usefulness or simplicity, or it was just a new lesson for the day that you want to note.


The teacher will grade your submission and provide feedback in an issue on GitLab.

Welcome to CoursePress

en utav Linnéuniversitets lärplattformar. Som inloggad student kan du kommunicera, hålla koll på dina kurser och mycket mer. Du som är gäst kan nå de flesta kurser och dess innehåll utan att logga in.

Läs mer lärplattformar vid Linnéuniversitetet

Student account

To log in you need a student account at Linnaeus University.

Read more about collecting your account

Log in LNU