toxdes / testiny-backend

An API back-end for https://testiny.live
https://api.testiny.live
GNU General Public License v3.0
0 stars 0 forks source link
aws nodejs postgresql

GitHub GitHub release (latest by date) Lines of code

Backend server written in NodeJS for testiny-web. checkout tech-stack for quick overview of technologies used.

Quickstart

1. Local Server

Clone this repo.

$ npm i -g yarn # install yarn
$ # make sure you have set up postgres, and have DATABASE_URL in .env
$ yarn all # checkout package.json to know what it does

2. Heroku

  1. Install heroku-cli
  2. Do heroku login inside the project directory, and login.
  3. Create a NodeJS app from the heroku dashboard, and a new postgresql database, and grab the URL.(How to)
  4. Set following required environment variables (How To).

    Environment Variable Name Value
    ENV production
    JWT_SECRET something_unguessable_secret_key_here
    PROD_DATABASE_URL database_url_from_previous_step

Tech stack

Name Description
express server
prisma to hopefully make DBMS easier.
postgres Database.
bcrypt, jsonwebtoken, uuid Hashing passwords, generating tokens and unique IDs respectively among other usages.
typescript Maintainability.

References

  1. https://likegeeks.com/linux-mail-server/#Linux_SMTP_server - want to try custom mail server for sending various mails - can't because my ISP doesn't provide me a static IP for free, and it takes a while to update DNS records every time I point my domain to the dynamic IP. Reverse DNS, and https'ing is needed otherwise Gmail doesn't even accept the mail (not even in the spam folder). I don't have a credit card, nor money, so can't buy a cheap vps either, so this is postponed until I find a solution. (UPDATE: This is not possible even with AWS EC2 because GMail has blacklisted all the ip-addresses. I managed to run a SMTP server, but Gmail automatically rejects the mails (not even in spam :/) So, I'll have to rely on some SaaS service that provides this functionality, potentially AWS SnS.)

  2. https://wiki.archlinux.org/index.php/PostgreSQL - Guide for setting up postgresql locally. After you set it up successfully, edit the .env file and provide the database URL. Alternatively, you can use Heroku.

  3. https://gist.github.com/soheilhy/8b94347ff8336d971ad0 -> For setting proxies, when we want to run backend and frontend on single VPS.