Backend express server for the js framework course.
To clone the repo.
git clone https://github.com/maru23bth/jsramverk-backend
Installation.
npm install
To configure create an .env file in root of repo.
# Mongodb
DB_USER=
DB_PASSWORD=
DB_NAME="SSREditor"
DB_DOCUMENTS_COLLECTION="DocumentWithUser"
DB_USERS_COLLECTION="Users"
# Express HTTP Server
PORT=1337
To get started running the website.
npm run start
To started the website in development mode.
npm run dev
To run tests.
npm run test
All data is transferred using json.
Success are reported with HTTP status 2XX.
Errors are reported with HTTP status >= 400.
List all documents
-
Response 200 (application/json)
-
Body
[ Document, Document, Document, ... ]
-
Get a specific document
-
Response 200 (application/json)
-
Body
Document
-
Save a new document
-
Body (application/json)
{ title?: "(string)", content?: "(string)" }
-
Response 200 (application/json)
-
Body
Document
-
Update document with :id
-
Body (application/json)
{ title?: "(string)", content?: "(string)" }
-
Response 200 (application/json)
-
Body
Document
-
Delete document with :id
-
Response 200 (application/json)
-
Body
{ "message": "Document deleted" }
-
Save a new comment
-
Body (application/json)
{ content: "(string)", location: "(string)" }
-
Response 200 (application/json)
-
Body
Document
-
Updatecomment
-
Body (application/json)
{ content: "(string)" }
-
Response 200 (application/json)
-
Body
Document
-
Delete comment with :commentId from document with :id
-
Response 200 (application/json)
-
Body
Document
-
Add a new collaborator by userId or email
-
Body (application/json)
{ userId?: "(string)" email?: "(string)" }
-
Response 200 (application/json)
-
Body
Document
-
Delete collaborator
-
Body (application/json)
{ userId: "(string)" }
-
Response 200 (application/json)
-
Body
Document
-
{
id: string,
type: string,
title: string,
content: string,
collaborators: User[],
comments: Comment[]
}
{
id: string,
username: string,
email: string
}
{
id: string,
author: User,
content: string,
location: string
}
- 2XX - Successful responses
- 3XX - Redirection messages
- 4XX - Client error responses
- 5XX Server error responses