Central service used for management of CodeSupport user generated content.

Overview

CodeSupport API

About

This repository contains the code for the CodeSupport API. The project is written in TypeScript using the NestJS framework with a postgreSQL database.

Getting started

The project uses a .env file for configuration. Copy .env.example and rename it to .env. If you're going to run the application in docker, no changes to the configuration are required. If running without docker, change the settings to match your own environment.

With Docker

For development purposes, this project is configured to make use of Docker for easily running the API and a local postgresql instance with no configuration required. In order to make use of this, Docker and Docker Compose must be installed on the machine. The easiest way to get these components on MacOS, Windows and Linux is to install Docker Desktop.

With docker installed, the application can be started by running the start:docker npm script with no further configuration required.

npm run start:docker

This will automatically set up docker images for postgresql and the NestJS API with hot reloading, meaning the docker container will automatically update when a file is changed.

If any NPM dependencies are installed or uninstalled, docker might not pick up the changes to the NPM dependencies. To fix this, run docker:rebuild. This will rebuild the image and refresh any cached NPM packages.

Without Docker

The application can also be ran without Docker. In this case, Node.js version 12 or later (tested with 16.13) and a PostgreSQL server instance is required. Make sure you've set the correct settings in the .env file, then start the app by running the start:debug script.

npm run start:debug

Attaching a debugger

Visual Studio Code

With both the docker and non-docker approach, the application is automatically set to debug mode. If you're using visual studio code, you can easily attach a debugger by going to the 'Run and Debug' tab and selecting either the debug-docker or debug-local profile.

Any Questions?

Feel free to mention @LamboCreeper#6510 in the CodeSupport Discord.

Comments
  • Article Module, Entity and Service

    Article Module, Entity and Service

    What Functionality Are You Suggesting?

    To start our work on supporting articles we need a new article module that houses an article entity and article service. The article service should include the ability to:

    • Get one specific article by ID
    • Get all articles
    • Create a new article
    • Update an article by ID

    An article entity should have:

    • An auto-incrementing, unique and primary key id field (e.g. 1)
    • A created field which contains the date at which the entity was created
    • A modified field which's value updates each time the entity is modified
    • A user field which's value is equal to the ID of the user who created the article
      • In the entity, we should join the article and user tables together so that it contains a full copy of the user
    • A title field which's value is a string which is the title of the article
    • A slug field which's value is a unique string which is the path to the article
    • A status field which's value is an enum of APPROVED, PENDING, REJECTED (default of PENDING)
    • A description field which is a string (max length of 250 characters)
    • A content field which is a string

    You can use the @CreateDateColumn() and @UpdatedDateColumn() decorators to automatically handle the dates.

    Why Will This Benefit The Community?

    This will allow us to create and retrieve articles throughout the API, therefore unlocking the ability to serve them across the web and Discord.

    accepted enhancement 
    opened by LamboCreeper 1
  • Get User Endpoint

    Get User Endpoint

    What Functionality Are You Suggesting?

    The ability to get a specific user from the database via the API.

    API Endpoint

    GET /user/:id

    Users are not required to be authenticated to access this endpoint.

    Response Body

    {
        id: number;
        username: string;
        created: string; // simplified extended ISO formatted date
        modified: string; // simplified extended ISO formatted date 
    }
    

    Why Will This Benefit The Community?

    This functionality will allow us to display user profiles on the web and in Discord.

    accepted enhancement 
    opened by LamboCreeper 1
  • Adds User Module

    Adds User Module

    Resolves #18

    Not entirely happy with the tests yet. ~~80~~ 90% sure it works fine, ~~but haven't had the chance yet to attach it to a controller to really test it out~~.

    Overview

    Please bullet point the changes you have made below:

    • Adds user entity
    • Adds user service with all methods
    • Adds basic test cases for the service
    opened by JonaVDM 1
  • User Module, Entity and Service

    User Module, Entity and Service

    What Functionality Are You Suggesting?

    To start our work on supporting users we need a new user module that houses a user entity and user service. The user service should include the ability to:

    • Get one specific user by ID
    • Get one specific user by Auth ID
    • Get all users
    • Create a new user
    • Update a user by ID

    A user entity should have:

    • An auto-incrementing, unique and primary key id field (e.g. 1)
    • A unique auth_id field (e.g. auth0|6237590b647a36006ba3c6ea)
    • A unique username field (e.g. johnsmith)
    • A created field which contains the date at which the entity was created
    • A modified field which's value updates each time the entity is modified

    You can use the @CreateDateColumn() and @UpdatedDateColumn() decorators to automatically handle the dates.

    Why Will This Benefit The Community?

    This will allow us to create and retrieve users throughout the API, therefore unlocking the ability to serve them across the web and Discord.

    accepted enhancement 
    opened by LamboCreeper 1
  • Add TypeORM with PostgreSQL to NestJS app, add docker config for running in docker containers

    Add TypeORM with PostgreSQL to NestJS app, add docker config for running in docker containers

    Resolves #3

    Overview

    • Installed @nestjs/typeorm, typeorm, and pg (postgres package used by typeorm)
    • Added database credentials to .env.example and to .env.docker.local
    • Added Dockerfile and docker-compose.yaml for running NestJS app and PostgreSQL instance in docker containers with no configuration required
    • Updated Readme.md with instructions for getting started
    • Import TypeOrmModule into root module found in src/app.module.ts. This automatically connects to PostgreSQL on startup.
    opened by J141 1
  • Setup Swagger

    Setup Swagger

    Blocked by #1

    What Functionality Are You Suggesting?

    We want to set up a swagger document that automatically contains all the documentation for the API. This functionality is described on the NestJS documentation here.

    Why Will This Benefit The Community?

    This will allow developers who are working on the frontend to easily see how to save and retrieve data to and from the API.

    accepted enhancement 
    opened by LamboCreeper 1
  • Setup Database ORM

    Setup Database ORM

    Blocked by #1

    What Functionality Are You Suggesting?

    We want to set up an ORM so that we can interact with our database. This can be achieved through TypeORM and is documented here (note this uses MySQL in the example, but we want to use PostgreSQL).

    You do not need to set up any repositories as part of this ticket, just the initial connection.

    The following environment variables should be used for the database connection:

    • DATABASE_HOST (host)
    • DATABASE_PORT (port)
    • DATABASE_USER (username)
    • DATABASE_PASS (password)
    • DATABASE_NAME (database)

    If NODE_ENV is not production then synchronize should be true.

    We should also have a Docker Compose setup for running the API and database together.

    Why Will This Benefit The Community?

    This will benefit us by allowing us to have a place where we can save and retrieve data from.

    accepted enhancement 
    opened by LamboCreeper 1
  • Make API Production Ready

    Make API Production Ready

    What Functionality Are You Suggesting?

    • Switch over POST /user to use API key validation so that it can be used in an Auth0 Action
    • Update Open API documentation
    • Hookup deployment to Heroku

    Why Will This Benefit The Community?

    This will make the API ready for use in production

    accepted enhancement 
    opened by LamboCreeper 0
  • Get All Articles Endpoint

    Get All Articles Endpoint

    Resolves #29

    Overview

    • Added GET /article endpoint to retrieve all articles
      • Added ?userId query parameter to retrieve all articles by a given user
      • Added ?status query parameter to retrieve articles of a given status
    opened by LamboCreeper 0
  • Get All Users Endpoint

    Get All Users Endpoint

    What Functionality Are You Suggesting?

    The ability to get all users from the database via the API.

    API Endpoint

    GET /user

    Users are not required to be authenticated to access this endpoint.

    Response Body

    [
        {
            id: number;
            username: string;
            created: string; // simplified extended ISO formatted date
            modified: string; // simplified extended ISO formatted date 
        },
        ...
    ]
    

    Why Will This Benefit The Community?

    This functionality will allow us to display user profiles on the web and in Discord. As we are statically rendering via Next.js we need to be able to get every user ahead of time, rather than on demand.

    accepted enhancement 
    opened by LamboCreeper 0
  • Remove end to end tests from CI.

    Remove end to end tests from CI.

    Since people run CI on their forks end to end tests do not run successfully, therefore blocking the merge process. For the time being, we will remove this job from CI as we investigate a better solution.

    opened by LamboCreeper 0
  • Mark Optional Query Parameters As Optional In Swagger

    Mark Optional Query Parameters As Optional In Swagger

    What Functionality Are You Suggesting?

    Currently we are not marking any optional query parameters as optional within Swagger, therefore causing them to be labelled as required when they are not. This currently only affects this route.

    This can be achieved by using the @ApiQuery() parameter decorator.

    Why Will This Benefit The Community?

    This means the documentation will correctly reflect the implementation, avoiding any confusion which may be caused.

    accepted documentation 
    opened by LamboCreeper 0
  • Add The Ability To Search For Articles

    Add The Ability To Search For Articles

    What Functionality Are You Suggesting?

    We should introduce a new GET /article/search endpoint which returns any articles which contain a given query. We can use PostgreSQL's LIKE operator to return the results. As we do not have much data this is a perfectly fine solution - there is no need for something like ElasticSearch.

    Why Will This Benefit The Community?

    This will allow members to easily search for articles, primarily through auto-complete functionality of an upcoming /article command within our Discord community.

    accepted enhancement 
    opened by LamboCreeper 0
  • Break Out Users and Articles Into Their Own API Tags

    Break Out Users and Articles Into Their Own API Tags

    What Functionality Are You Suggesting?

    Instead of grouping all our API endpoints together we should have them split out into sections based on their module name. For example: user, article...

    See documentation here.

    Why Will This Benefit The Community?

    This will make the documentation more organised and easier to follow.

    accepted documentation 
    opened by LamboCreeper 0
  • Remove App Controller and Service

    Remove App Controller and Service

    What Functionality Are You Suggesting?

    We should remove the App controller and service file which was used during setup and testing.

    Why Will This Benefit The Community?

    The application is now running in production and these serve no purpose.

    accepted enhancement 
    opened by LamboCreeper 0
  • Re-introduce End to End Tests

    Re-introduce End to End Tests

    What Functionality Are You Suggesting?

    Due to issues with running end to end tests on forked repositories, we removed them from CI. However, end to end tests are a very powerful safety net for your codebase so it would be ideal to add them back. We should explore ideas on how to best do this.

    Old CI Code
    test_e2e:
        name: End to End Tests
        runs-on: ubuntu-latest
        container: node:16.14.2-alpine3.15
        env:
          DB_PASS: ruv2cyHT4H78BVzK7b4DnBAHJR8dG4fG
          DB_USER: admin
          DB_NAME: codesupport-api
        services:
          postgres:
            image: postgres:12
            env:
              POSTGRES_PASSWORD: $DB_PASS
              POSTGRES_USER: $DB_USER
              POSTGRES_DB: $DB_NAME
            options: >-
              --health-cmd pg_isready
              --health-interval 10s
              --health-timeout 5s
              --health-retries 5
            ports:
              - 5432:5432
        steps:
          - uses: actions/checkout@v2
          - name: Runs End to End Tests
            env:
              DATABASE_HOST: postgres
              DATABASE_PASS: $DB_PASS
              DATABASE_USER: $DB_USER
              DATABASE_NAME: $DB_NAME
              AUTH0_ISSUER_URL: ${{ secrets.AUTH0_ISSUER_URL }}
              AUTH0_AUDIENCE: http://localhost:8080
              AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }}
              AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }}
              AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }}
            run: |
              npm ci
              npm run migration:run
              npm run seed:run
              npm run test:e2e
    

    Why Will This Benefit The Community?

    Allow us to quickly and easily catch bugs when making changes to the source code.

    accepted enhancement 
    opened by LamboCreeper 0
  • Custom Logger

    Custom Logger

    What Functionality Are You Suggesting?

    We should create a custom logger which when NODE_ENV is production logs to our Logtail instance and in any other environment uses the regular Node console.

    A new environment variable called LOGTAIL_TOKEN should be added and provided to the Logtail constructor.

    Useful Resources

    Why Will This Benefit The Community?

    This will allow us to easily trace issues, query logs and solve bugs without the need to SSH into the server.

    accepted enhancement 
    opened by LamboCreeper 0
Owner
CodeSupport
Open source code from the community of over 15,000 programmers.
CodeSupport
Contains html file showcasing Earthquake related data generated in the form of VR model, ArcGIS API with real-time earthquake feed and video of simulation of earthquake generated in blender

Module-EADGI-Project-All about Earthquakes Introduction Contains html file showcasing Earthquake related data generated in the form of VR model, ArcGI

Abhishek Rawat 2 Jun 9, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
The LMS (Life Management System) is a free tool for personal knowledge management and goal management based on Obsidian.md.

README Documentation | 中文帮助 The LMS (Life Management System) is a tool for personal knowledge management and goal management based on Obsidian.md. It

null 27 Dec 21, 2022
The completed Codelab for GDG Central Florida - Ionic/Capacitor wizardry with Angular

GDG Central Florida - Ionic/Capacitor wizardry with Angular This is the completed code for Building an Ionic Application with Angular The App It is a

Javier 2 Oct 10, 2022
Kyrillos Hany 14 Aug 10, 2022
this is a single-page web application. we built a book website where the user can add , remove and display books. we used modules to implement these functionalities. also, we used the Date class to display the date and time.

Awsome Books In this Project, we have built A Books websites. Built With ?? HTML CSS javascript Git & Github Live Demo Here you can find the live Demo

Nedjwa Bouraiou 10 Aug 3, 2022
The Frontend of Escobar's Inventory Management System, Employee Management System, Ordering System, and Income & Expense System

Usage Create an App # with npx $ npx create-nextron-app my-app --example with-javascript # with yarn $ yarn create nextron-app my-app --example with-

Viver Bungag 4 Jan 2, 2023
Its a Advanced Content Management System built on top of Frappe.

Go1 CMS Go1 CMS - Its a Advanced Content Management System built on top of Frappe with Advanced Page builder. Lead your business towards the future of

null 20 Dec 29, 2022
[WIP] A micro content management system

T8 CMS T8 is a minimal CMS for static sites and blogs. Tech Stack ReactJS TypeScript Material UI Styled Components Supabase(BaaS) Project Folder Struc

null 7 Oct 15, 2022
A bodacious, secure, headless content management system.

A bodacious, secure, headless content management system. Cassiopeia allows you to create your blog with a customizable interface and comes with a dyna

bear 4 Jan 6, 2023
RESTful service to provide API linting as-a-service

API Linting Service Prerequisites / general idea General idea behind this API implementation is to provide an API as a service based on the awesome sp

Schwarz IT 6 Mar 14, 2022
TypeScript plugin for service-to-service (aka. "functionless") cloud integrations.

Functionless λ< Functionless is a TypeScript plugin that transforms TypeScript code into Service-to-Service (aka. "functionless") integrations, such a

sam 303 Jan 2, 2023
Denail of service system for the Dentistimo system. Used to improve the tolerance and testing fail safe functionality.

Distributed Systems - Dos Testing DoS (Denail of Service) System for Testing and Practical demonstration of systems capability to handle a basic DDoS

null 28 Nov 8, 2022
Erick Hans 5 Oct 26, 2022
MidJourney is an AI text-to-image service that generates images based on textual prompts. It is often used to create artistic or imaginative images, and is available on Discord and through a web interface here.

Midjourney MidJourney is an AI text-to-image service that generates images based on textual prompts. It is often used to create artistic or imaginativ

Andrew Tsegaye 8 May 1, 2023