/Illusive

An ASP.NET Core C# back-end application for a forum website.

Primary LanguageC#MIT LicenseMIT

GitHub repo size GitHub issues GitHub GitHub Workflow Status Twitter Follow

API Documentation

Illusive

A forum website and REST API made on the ASP.NET Core framework using Razor pages and .NET WebAPI.

Installation

Clone the repo using Git terminal

gh repo clone pippinmole/Illusive

or download here.

Usage

You will need to set up some services to obtain connection strings so the application can interact with things like a database.

MongoDB
  1. Create an account and cluster using this tutorial.

  2. Obtain the connection string which should be formatted as such:

    mongodb+srv://<username>:<password>@cluster0.builj.azure.mongodb.net/<dbname>?retryWrites=true&w=majority
    
  3. Add the app secret to the appsettings.json file:

    "ConnectionStrings": {
      "DatabaseConnectionString": "<api key>"
    }
Serilog
  1. Add the app secret to the appsettings.json file:
    "Serilog": {
      "DataDog": {
       "ApiKey": "<api key>"
      }
    }
Content Delivery
Mail Handling

You will need access to an SMTP server for password resetting to work, since an email does get sent out to users' accounts in the scenario that they have forgotten their credentials.

To set up email services:

  1. Register an SMTP server and obtain the relevant credentials
  2. Enter the credentials into the appsettings.json
    "MailSenderOptions": {
      "AddressFrom": "",
      "Password": "",
      "SmtpHostAddress": "",
      "Port": ""
    }

Example appsettings.json

{
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "ConnectionStrings": "<api key>",
    "CdnConnectionString": "<api key>"
  },
  "RecaptchaSettings": {
    "ContentSecurityPolicy": "<policy key>",
    "SecretKey": "<api key>",
    "SiteKey": "<api key>"
  },
  "Serilog": {
    "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.Datadog.Logs", "Serilog.Sinks.File" ],
    "MinimumLevel": {
      "Default": "Debug",
      "Override": {
        "Microsoft": "Warning",
        "Microsoft.Hosting.Lifetime": "Information",
        "System.Net.Http.HttpClient": "Warning"
      }
    },
    "Enrich": [
      "FromLogContext"
    ],
    "DataDog": {
      "OverrideLogLevel": "Information"
    },
    "WriteTo": [
      {
        "Name": "Console"
      }
    ]
  }
}

WebAPI

The WebAPI allows for both anonymous and registered users to interact with the forum using GET, POST, DELETE and PUT requests. The Illusive Public API Documentation is automatically generated using Swagger. To easily create requests, you can use tools such as PostMaster or Fiddler.

The API can be seen in action here: Image from Gyazo

Authorization

Some of the requests require account authorization. Thankfully, Illusive offers an secret JWT API token which can be used to identify a user. It can be found under the Account section of the forum. If you are using one of the tools suggested above, you can add the authorization header as so:

Image from Gyazo

If you are using the API token elsewhere, simply use the dictionary key-value pair in your header (you may be required to explicitly state the request format is in JSON):

   "Authorization: Bearer <api token>",
   "Content-Type: application/json"

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Dependencies

Dependency Description
Simplmds-markdown-editor A drop-in JavaScript textarea replacement for writing beautiful and understandable markdown.
MongoDB.Driver A driver for C# application to connect to a MongoDB instance
Westwind.AspNetCore.Markdown A C# library that parses markdown string into HTMLStrings for rendering on HTML pages.
BCrypt.Net-Next A C# encryption library.
Humanizer.Core Extension methods for the DateTime and TimeSpan datatypes in C# to be parsed to human-readable/user interface strings.
Azure.Storage.Blobs A driver for C# applications to connect to an Azure Blob.
jQuery.AJAX A JavaScript library that allows for easy POST, GET, DELETE and PUT requests on client-side webpage.
party.js A JavaScript library to brighten up your user's site experience with visual effects!
Serilog.AspNetCore A C# driver for application logging.
Serilog.Sinks.Async A C# driver that works with Serilog.AspNetCore to connect to external logging sinks.
Serilog.Sinks.Datadog.Logs A C# driver that works with Serilog.Sinks.Async.

Licence

Copyright © 2020 pippin_mole.
Illusive is licensed under MIT. Do what you want.