GithubHelp home page GithubHelp logo

editor-backend's Introduction

Editor Backend

Build Status

Purpose

The purpose of this repo is to provide a REST API for storing documents in a MongoDB database. This is an application made as part of the course DV1612 JavaScript based web frameworks at Blekinge Institute of Technology.

Installation

To install all prerequisites needed for this application, run:

npm install

Start

To start this application, simply run:

npm start

Routes

This REST API provides the following routes:

Route Description
POST /login Login as a user in the users collection
POST /register Register as a new user
POST /invite Invite a user to collaborate
POST /acceptInvitation Accept an invitation by invitation id and register a new user.
GET /documents Fetch all documents
GET /documents/:id Fetch a single document by its id
POST /documents Create a document
PUT /documents/:id Update an existing document

Configuration

This app needs the following configured environment variables. They can be configured by creating a .env.production file.

Environment variable Example Description
DATABASE_PROTOCOL mongodb+srv The protocol as indicated by the MongoDB instance.
DATABASE_HOSTNAME cluster0.zp46i.mongodb.net The hostname for the connection.
DATABASE_DATABASE editor The MongoDB database name.
DATABASE_USER user The MongoDB username.
DATABASE_PASSWORD 38IjSUubHIu3KI A MongoDB password.
DATABASE_DOCUMENTS_COLLECTION documents The name of the documents collection.
DATABASE_USERS_COLLECTION users The name of the users collection.
DATABASE_INVITES_COLLECTION invites The name of the invites collection.
WEBSOCKET_CORS_HOSTNAMES https://app.azure.net The CORS hostnames to be returned to the client.
JWT_SECRET pL5zW5cL8... The JWT secret that is used for hashing and validating.
GRAPHQL_GRAPHIQL true If the GRAPHIQL UI should be served, e g in development.
SENDGRID_API_KEY SG.CDvuEIv3RN60SfIF4jXP... The API key as given by the Sendgrid account.
SENDGRID_TEMPLATE_ID d-de204326fd254e8ab692b... The ID of the Sendgrid template used for emails.

A typical document

A typical document consist of the following NoSQL document structure:

{
    "_id": ObjectId("6127eecec049b10bc281598d"),
    "contents": "<p>Document text.</p>",
    "name": "Untitled",
    "type": "text",
    "comments": [
        {
            "node": 3,
            "comment": "This is a comment."
        }
    ],
    "collaborators": [
        ObjectId("613f31c615ec7901526cb079")
    ]
}

editor-backend's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.