Skip to content

Lipoic/Lipoic-Backend

Repository files navigation

Lipoic-Backend

The backend for Lipoic, using Express.js and TypeScript.

Development

Getting Started

Requirements:

Install dependencies:

yarn install

Start server (dev):

yarn dev

Start server (product):

yarn start

ESLint:

yarn lint

Generate the swagger file:

yarn swagger

Configuration

Create the .env file and add key-value pairs according to the table below. You can find an example in .env.example.

Key Description Default Value
PORT The server port. 8080
DATABASE_URL The URL to the MongoDB database. mongodb://localhost:27017
DATABASE_USERNAME The database auth username.
DATABASE_PASSWORD The database auth password.
CLIENT_URL The URL of the frontend or client. https://app.lipoic.org
ALLOWED_ORIGINS The server allowed origins (CORS).
GOOGLE_OAUTH_SECRET Google OAuth client secret.
GOOGLE_OAUTH_ID Google OAuth client id.
FACEBOOK_OAUTH_SECRET Facebook OAuth client secret.
FACEBOOK_OAUTH_ID Facebook OAuth client id.
CLOUDFLARE The server is proxied by Cloudflare. false
JWT_PRIVATE_KEY The ECDSA privacy key used to sign the token.
JWT_PUBLIC_KEY The ECDSA public key used to verify the token.
VERIFY_EMAIL_HOST The host IP address for send sign up verification emails.
VERIFY_EMAIL_PORT The host port for send sign up verification emails.
VERIFY_EMAIL_USER The host username for send sign up verification emails.
VERIFY_EMAIL_PASSWORD The host password for send sign up verification emails.
VERIFY_EMAIL_FROM The email address of the sender for send sign up verification emails. Lipoic Account <[email protected]>

Generate JWT keys

Generate keys for signing and verifying JWT tokens.

openssl ecparam -genkey -name prime256v1 -noout -out jwt_private_key.pem
openssl ec -in jwt_private_key.pem -pubout -out jwt_public_key.pem

Deployment

Use Docker to deploy the backend.

  1. Install docker-compose.
  2. Run ./script/gen_ecdsa_key.sh generate ECDSA private key and public key.
  3. Follow the configuration tutorial to set the variables.
  4. Run ./script/deploy.sh.

Note: If you are using Windows use cygwin to run the script.