Coder Social home page Coder Social logo

sveske-juice / denodaco Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 1.91 MB

DEfinetly NO DAta COllection. School project on survaliance capitalism, that shows how much user data sites can collect

License: GNU General Public License v3.0

JavaScript 69.84% HTML 17.65% CSS 12.51%
crud data-collection mariadb nodejs surveillance-capitalism

denodaco's Introduction

Description

A school project on survaliance capitalism. This is a static website which connects to a backend with the use of an API. It's a social media where there is a global feed where all posts end up.

Usage

The website consists of a Node js backend and a statically served front end (both behind a reverse proxy)

Backend

To run the backend, you must have mariadb installed and running and have the appropiate tables setup (see tables.sql). Once the mariadb server is running you need to clone the repo:

git clone https://github.com/Sveske-Juice/denodaco.git
cd denodaco/server/src

Then make a file called .env here all secret configurations will be stored. Make sure all values with placeholders (<>) are set to something you choose:

JWT_SECRET=<some long secret>
DB_USER=<the db user to use (should probably be something like 'denodacoUser' or 'denodacoSlave' etc.)>
DB_PASS=<the pass for the db user>
DB_NAME=denodaco
DB_SOCK=<the socket the mariadb server runs on>
JWT_EXPIRATION=1024 # how long before access tokens expire
MAX_UPLOAD_SIZE=4096 # in MB

Install node dependencies:

cd ..
npm i

Now it's done!

To test the backend run the following from the root of the repo: node server/server.js

Serving the frontend

I will be serving the site using nginx but can easily be translated to other reverse proxies like apache.

This is how to run the site under a path (example.com/denodaco):

set $ip 127.0.0.1;

location /denodaco {
	client_max_body_size 4M; # 4GiB max upload

	index index.html;
	alias /var/www/denodaco/public/;
	access_log on;
	try_files $uri $uri/ @backend;
}

location @backend {
	client_max_body_size 4M; # 4GiB max upload

	proxy_pass http://$ip:3500;

	# Pass client real ip to upstream
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;	
	
	# intercept errors on backend so that we can fallback to 404 (doesn't work, hence setting 502 to 404)
	proxy_intercept_errors on;
	#error_page 502 = 404;
}

The above configuration assumes that a server block is already configured.

Systemd service

To make it run on boot a simple systemd service can be used:

[Unit]
Description=NodeJS backend API for a denodaco instance

[Service]
WorkingDirectory=/var/www/denodaco/server
ExecStart=/usr/bin/node /var/www/denodaco/server/src/server.js

[Install]
WantedBy=multi-user.target

Improvements that could be done

  • [Frontend] Switch to Typescript
  • [Frontend] Make a backend connection status (offline, online etc.)
  • [Frontend] Redirect to login when token expires
  • [Frontend] Redirect back to the page user was previosly on when having to auth
  • [Backend] Switch to Typescript with Node
  • [Backend] Limit login attempts
  • [Backend] DB pooling
  • [Backend] Refactor error handling

denodaco's People

Contributors

sveske-juice avatar

Watchers

 avatar  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.