-
-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Install Yarn as the package manager. All npm commands should be using yarn and not npm.
You probably have the latest 3.x.x version of Yarn. Switch to Yarn 1 using yarn set version 1.x
(necessary as using different Yarn pkg version will completely change the yarn.lock file).
After installing Yarn
- Run yarn once at the
backend
directory. - Run yarn once at the
frontend
directory.
yarn
You need your own Telegram Bot for the app login to work.
Create a bot with BotFather
- Send /newbot to create a new Telegram bot.
- When asked, enter a name for the bot.
- Give the Telegram bot a unique username.
- Copy and save the Telegram bot's access token for later steps
Make a copy of backend/.env.example
to backend/.env
.
cp backend/.env.example backend/.env
-
JWT Tokens
-
ACCESS_TOKEN_SECRET
andREFRESH_TOKEN_SECRET
: To sign the respective JWT tokens. Any random string will do for each secret. -
ACCESS_TOKEN_EXPIRY
andREFRESH_TOKEN_EXPIRY
: The amount of time the respective JWT tokens are valid for from the time of generation. E.g.10s
,30m
,7d
-
-
Telegram OAuth
-
OAUTH_TELEGRAM_BOT_TOKEN
: Token of the bot you registered with BotFather.
-
-
Telegram Jio Notification
-
TELEGRAM_MAIN_CHAT_GROUP_ID
: Telegram chat_id of the chat that the above OAuth bot will send a notification to when a 'jio' is created. You can refer to this StackOverflow post on how to obtain your own chat_id or a group's chat_id.
-
-
Telegram Alerts (interim way of sending logs, metric updates and alerts to the team - optional to configure if not needed)
-
TELEGRAM_ALERTS_BOT_TOKEN
: The bot token for the alerts bot. (You can reuse the one inOAUTH_TELEGRAM_BOT_TOKEN
above in local dev if don't want to create a separate bot) -
TELEGRAM_ALERTS_CHAT_ID
: The Telegram chat_id of the chat to send these alerts to.
-
-
Postgres Database Connection Details
-
DATABASE_HOST
: Your local Postgres database URL. (You can try leaving this empty, to see if the library defaults work) -
DATABASE_PORT
: The port to connect to. Should be5432
if the default Postgres port is used. -
DATABASE_USER
: Your username used to login to the Postgres database. -
DATABASE_PASSWORD
: Your corresponding password used to login to the Postgres database. -
DATABASE_NAME
: The database name to connect to. E.g.climbjios-dev
-
-
CloudFlare Stream (refer to CloudFlare's Documentation)
-
CLOUDFLARE_ACCOUNT_ID
: Your CloudFlare account ID. -
CLOUDFLARE_STREAM_API_TOKEN
: Your CloudFlare Stream API token. - (please ping Ri Zhao or En Rong if you require access to the dev CloudFlare credentials)
-
-
AWS S3 (refer to AWS's Documentation)
-
AWS_ACCESS_KEY_ID
: The access key ID (with S3 read write permissions). -
AWS_SECRET_ACCESS_KEY
: The corresponding access key secret. -
AWS_S3_BUCKET_NAME
: The S3 bucket name that you have pre-created on AWS console. -
AWS_REGION
: The AWS region that the S3 bucket is hosted in. (We useap-southeast-1
which is located in Singapore) - (please ping En Rong if you require access to the dev S3 bucket)
-
-
CORS
-
CORS_ORIGIN
: The CORS origin for the backend server. You can usehttp://localhost:3000
for local dev.
-
-
Backend Ports
-
PORT
: The port that the main backend runs on. Defaults to4000
if unspecified. -
CRONJOB_PORT
: The port that the cronjob service runs on. Defaults to4001
if unspecified.
-
-
Google OAuth (can be ignored for now since we deprecated Google Login in favor of users onboarding with their verified Telegram username)
-
OAUTH_GOOGLE_ID
: OAuth2 Client ID generated from Google Developer Console. -
OAUTH_GOOGLE_SECRET
: OAuth2 Secret generated from Google Developer Console. -
OAUTH_GOOGLE_REDIRECT_URL
: The URL that Google will redirect to upon successful login on Google's side. Should behttp://localhost:4000/v1/auth/google/redirect
in local dev. - NOTE: Put in a placeholder value for all these for backend to run e.g. (xyz)
-
Make a copy of frontend/.env.example
to frontend/.env
.
cp frontend/.env.example frontend/.env
-
VITE_HOST_API_KEY
: Host key of backend. Should behttp://localhost:4000
in local dev. -
VITE_DEBUG
: Will show debug messages only if true. Should be settrue
in local dev. -
VITE_TELEGRAM_OAUTH_BOT_USERNAME
: Username of the bot you registered with BotFather. E.g.climbjios_rz_bot
.
After setting up the environment variables and installing the requisite dependencies:
- Start the Postgres server.
- If you don't have a local Postgres instance & too lazy to download Postgres, you can try using supabase.io. Just find their connection strings and put it in the backend env variables.
- In
backend
directory- Run
yarn migrate
to run all database migrations (this command creates the database if it does not yet exist) - Run
yarn seed
to add seed data - Run
yarn start:dev
to start the main server locally - (Optional) Run
yarn start:dev:cronjob
to start the cronjob microservice locally
- Run
- In
frontend
directory, runyarn start
- Setup ngrok tunneling
- Install ngrok and configure your ngrok auth token (instructions here)
- Run
ngrok http 3000
to start the tunnel (you will be exposing your local machine port to the internet at the given URL) - On Telegram's @BotFather, run the
/setdomain
command. Select bot your created above, then paste the URL received when running step 2. - Access your local machine deployment via the URL received in step 2. The Telegram login widget should appear as a button.
Area | Choice | What is it |
---|---|---|
Language | TypeScript | Statically typed JavaScript |
View | React | Most popular UI library |
Backend Framework | Nest.js | A progressive Node.js framework for building efficient, reliable and scalable server-side applications. |
Data Fetching | ahooks useRequest | Powerful hooks library for data fetching |
ORM | Objection.js | An SQL-friendly ORM (Object Relation Mapping) for Node.js |
SQL Query Builder | Knex.js | Build SQL queries for App logic and migrations |
Database | PostgreSQL | Popular open source relational database |
-
main
is release branch and should remain stable at all times. - Create feature branches for your in-progress features and using the format
<username>/my-feature
(doesn't have to be your GitHub username, just use something identifiable and be consistent about it). - We use Conventional Commits specification for commit messages:
- E.g.
feat: my commit message
.
- E.g.
- Delete your branch after merging into
main
.
Credits: This guidebook is heavily inspired by TechInterviewHandbook's wiki.