diff --git a/README.md b/README.md index 679c36f1..407c893e 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ and say hi to us at #kampus-projects channel. ## Getting started +### 1. Cloning the project + - Fork `kamp-us/monorepo` under your personal account. - eg: `usirin/monorepo` - Clone the project to your local computer: @@ -28,6 +30,147 @@ git clone git@github.com:kamp-us/monorepo.git cd monorepo ``` +- Install dependencies. + +```sh +npm ci +``` + +### 2. Modifying `hosts` file + +- Add the following text block to [your `/etc/hosts` file](https://www.howtogeek.com/27350/beginner-geek-how-to-edit-your-hosts-file/). + +```text +127.0.0.1 localhost.kamp.us +127.0.0.1 pasaport.localhost.kamp.us +127.0.0.1 pano.localhost.kamp.us +127.0.0.1 sozluk.localhost.kamp.us +127.0.0.1 gql.localhost.kamp.us +``` + +### 3. Setting up `.env` files + +- Duplicate `.env.example` files and rename them as `.env` in the following folders: `db/prisma`, `apps/gql`, `apps/kampus`, `apps/pasaport`. + +### 4. Prisma Setup and Database Configuration + +- Move to `db/prisma` folder. + +```sh +cd db/prisma +``` + +- Start the image. (You should have docker installed.) + +```sh +docker-compose up -d +``` + +- Generate artifacts. (e.g. Prisma Client) + +```sh +npm run prisma:generate +``` + +- Push the Prisma schema state to the database. + +```sh +npm run prisma:push +``` + +- Run seed command to fill database with demo data. + +```sh +npm run prisma:seed +``` + +### 5. Running dev servers + +- Run the command below at the root folder. + +```sh +# Runs "gql", "kampus" and "pasaport" apps so the platform can be alive with 1 command. +npm run web +``` + +- Now you can go to [localhost.kamp.us:3000](localhost.kamp.us:3000) to see it live. 🚀 + +```sh +# Runs all "dev" commands on each package inside the workspace +npm run dev +``` + +```sh +# Runs only "gql" server so backend work can be done separetly. +npm run gql +``` + +### 6. Logging in on development server(optional) + +#### 6.1 GitHub + +- Go to [OAuth Apps page](https://github.com/settings/developers) on GitHub. +- Click on `New OAuth App`. + - Application name: "you can choose any name" + - Homepage URL: http://pasaport.localhost.kamp.us:3001/ + - Authorization callback URL: http://pasaport.localhost.kamp.us:3001/auth/callback/github +- Click on `Register Application`. +- On the application page, click on `Generate a new client secret`. +- Make the following changes to the corresponding files. + +```sh +# apps/kampus, apps/pasaport +GITHUB_ID= +GITHUB_SECRET= +``` + +- Now you can use `Sign in with GitHub` on development server. + + + ## Structure - `/apps`: services & apps @@ -37,8 +180,6 @@ cd monorepo These folders are [registered as workspaces in package.json](package.json#L4-L7) -## Running the projects - ## Use Correct Node Version If you haven't already install [Volta](https://volta.sh), you can install install it with: diff --git a/apps/gql/.env.example b/apps/gql/.env.example index efb9c797..5e7dc787 100644 --- a/apps/gql/.env.example +++ b/apps/gql/.env.example @@ -1,3 +1,3 @@ NODE_ENV=development DATABASE_URL=mysql://kampus:kampus@localhost:3306/kampus?schema=public -NEXTAUTH_URL=http://localhost:3001/auth +NEXTAUTH_URL=http://pasaport.localhost.kamp.us:3001/auth diff --git a/apps/kampus/.env.example b/apps/kampus/.env.example index 9bf7cf20..5a20d6fb 100644 --- a/apps/kampus/.env.example +++ b/apps/kampus/.env.example @@ -1,8 +1,8 @@ # update with the url after running `npm run dev` under `apps/gql` -NEXT_PUBLIC_GQL_URL=http://localhost:4000/graphql -NEXTAUTH_URL=http://localhost:3001/auth +NEXT_PUBLIC_GQL_URL=http://gql.localhost.kamp.us:4000/graphql +NEXTAUTH_URL=http://pasaport.localhost.kamp.us:3001/auth DATABASE_URL=mysql://root:kampus@localhost:3306/kampus -AUTH_COOKIE_DOMAIN='' +AUTH_COOKIE_DOMAIN='.localhost.kamp.us' GITHUB_ID='' GITHUB_SECRET='' DISCORD_ID='' diff --git a/apps/pasaport/.env.example b/apps/pasaport/.env.example index d441b50e..b7a89bac 100644 --- a/apps/pasaport/.env.example +++ b/apps/pasaport/.env.example @@ -1,7 +1,7 @@ NODE_ENV=development -NEXTAUTH_URL=http://localhost:3001/auth +NEXTAUTH_URL=http://pasaport.localhost.kamp.us:3001/auth DATABASE_URL=mysql://root:kampus@localhost:3306/kampus -AUTH_COOKIE_DOMAIN='' +AUTH_COOKIE_DOMAIN='.localhost.kamp.us' GITHUB_ID='' GITHUB_SECRET='' DISCORD_ID=''