A platform for internal tools at Coding Blocks, hosted at https://tools.codingblocks.com. This project is part of boss, please check for issues here. For any queries regarding setup or contribution, feel free to join discord and post in #gondor channel.
yarn
Follow the postgresql guidelines, download an install postgres v9.6.
Create Database
psql -U postgres
> create database gondor;
> \q
Update Env Vars
touch .env
#.env
DB_HOST=127.0.0.1 #optional
DB_USERNAME=postgres #or any other postgres username
DB_NAME=gondor #optional
DB_PASSWORD= #postgres user password if any
Run Migrations
yarn sequelize db:migrate
This project uses OneAuth as a single sign on server. For authentication it is required for OneAuth to be either running locally or to have a client application created here.
(optional) Please follow the instructions here to setup up OneAuth locally.
Config for OneAuth Client App
domain = http://localhost:3000
default url = http://localhost:3000
callback url = http://localhost:3000/api/login/callback
If you have setup OneAuth locally, then create a client application, get the ONEAUTH_CLIENT_ID
& ONEAUTH_CLIENT_SECRET
and add it to your .env
.
Otherwise, similarly create a client application for authentication here, get the ONEAUTH_CLIENT_ID
& ONEAUTH_CLIENT_SECRET
and add it to your .env
.
Add Env Vars
#.env
ONEAUTH_URL=http://localhost:3838 #include only if oneauth setup locally
ONEAUTH_CLIENT_ID=<client_id>
ONEAUTH_CLIENT_SECRET=<client_scret>
yarn dev
Open http://localhost:3000 with your browser to see the result.
Run the following command from root of the project:
bash ./bin/windows_start.sh
You might be needed to enable Windows Subsystem for Linux feature on your OS or run the command inside git bash.
There are multiple tools used to make developer experience smooth. You can suggest your ideas in form of issues.
If you don't have a local OneAuth setup and want to seed database with random users, you can use the command below. The caveat is that you won't be able to login through their accounts. But you may impersonate them using your own account (admin role required).
npx babel-node api/bin/seedUsers.js
Applications has 3 user roles with different AuthorizationPolicy attached to them. Due to missing user management feature in the UI, use the following script to update the role of any user.
npx babel-node api/bin/updateRole <username> <role(Admin, Member, User)>
During local development setup, it takes a lot of time to login and log out of different user profile for testing various features. To solve this problem there exists the impersonate user functionality.
If your logged in user is an Admin, you can add a cookie named iuid
with the value of any other user's id. On reload you will be logged in as the other user. Removing the cookie and reloading will login you back as the original user.
The same functionality can be used for debugging on production.
Take a look at the following resources:
- Next.js Documentation - learn about Next.js features.
- Graphql - learn graphql specification.
- Apollo Server - learn about graphql api server.
- Apollo Client - learn about graphql react client.
- DataLoader - learn how to fix N+1 query problem.
- ReactStrap - learn bootstrap components for react.