Cinema Web Backend App

Installation

npm install

Dependency setup

For the application to run, you need to set up the following dependencies.

Database

Install PostgreSQL and create a database for the application.

Link to download PostgreSQL: PostgreSQL

S3 Storage

Create an S3 bucket in AWS and set up the required permissions.

Setting up Amazon S3

Email Service

Create an email account for sending emails. For example, you can use Gmail.

  1. First create a Gmail account.
  2. Create an Google app password. How to: App passwords
  3. Use the email and the app password in the environment variables.

Environment variables

After finishing the setup, create a .env file in the root directory of the project and add the required environment variables.

  1. APP_ENV: For development, set it to development and for production, set it to production. Example: APP_ENV=development
  2. APP_PORT: The port on which the application will run. Example: APP_PORT=3000
  3. DB_HOST: The host of the database. Example: DB_HOST=localhost
  4. DB_PORT: The port of the database. Example: DB_PORT=5432
  5. DB_NAME: The name of the database. Example: DB_NAME=database_name
  6. DB_USER: The username of the database. Example: DB_USER=username
  7. DB_PASS: The password of the database. Example: DB_PASSWORD=password
  8. DB_URL: The URL of the database. Example: DATABASE_URL=postgresql://username:password@localhost:5432/database_name
  9. DB_SHADOW_URL: The URL of the shadow database. This is used for migrations. Example: DB_SHADOW_URL=postgresql://username:password@localhost:5432/database_name
  10. AUTH_SECRET: The secret key used for JWT token generation. Example: AUTH_SECRET=secret
  11. AUTH_ACCESS_TOKEN_LIFE_SEC: The life of the access token in seconds. Example: AUTH_ACCESS=604800
  12. AUTH_REFRESH_TOKEN_LIFE_SEC: The life of the refresh token in seconds. Example: AUTH_REFRESH_TOKEN_LIFE_SEC=604800
  13. TOKEN_LIFE_SEC: The life of the email verification token and password reset token in seconds. Example: TOKEN_LIFE_SEC=604800
  14. TOKEN_PASSWORD_RESET_RENEWAL_SEC: The time in seconds after which the password reset token can be renewed. Example: TOKEN_PASSWORD_RESET_RENEWAL_SEC=604800
  15. TOKEN_EMAIL_VERIFICATION_RENEWAL_SEC: The time in seconds after which the email verification token can be renewed. Example: TOKEN_EMAIL_VERIFICATION_RENEWAL_SEC=604800
  16. TOKEN_DISABLE_HASHING: Set to true to disable hashing of the token. Example: TOKEN_DISABLE_HASHING=false
  17. EMAIL_HOST: The host of the email service. Example: EMAIL_HOST=smtp.gmail.com
  18. EMAIL_PORT: The port of the email service. Example: EMAIL_PORT=587
  19. EMAIL_USER: The username of the email service. Example: EMAIL_USER=username
  20. EMAIL_PASSWORD: The password of the email service. Example: EMAIL_PASSWORD=password
  21. EMAIL_DEFAULT_FROM: The default email address from which the emails will be sent. Example: "'My Cinema Website' noreply.cinemaweb@gmail.com"
  22. FILE_ENDPOINT: The endpoint of the S3 storage service. Example: FILE_ENDPOINT=http://localhost:3001
  23. FILE_REGION: The region of the S3 storage service. Example: FILE_REGION=us-east-1
  24. FILE_ACCESS_KEY: The access key of the S3 storage service. Example: FILE_ACCESS
  25. FILE_SECRET_KEY: The secret key of the S3 storage service. Example: FILE_SECRET_KEY=secret
  26. FILE_BUCKET_NAME: The name of the bucket in the S3 storage service. Example: FILE_BUCKET_NAME=bucket_name

Fake data generation

To generate fake data, run the following command:

npm run prisma:reset-and-seed

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod