Skip to content

KennethImphean/jupiter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jupiter

A tool to find ways to get involved on campus.

Contributing

We are always open to contributions to the project. If you would like to contribute and want some guidance on where to start, please join our Discord and ask for drop a message in the #jupiter-chat channel or DM Ruben for more details.

Currently, we're tracking all issues via GitHub Issues. If you would like to work on an issue, please comment on the issue and we will assign it to you. If you see anything that you think could be improved, please create an issue and we will look into it.

Getting Started

Please make sure you have at least NodeJS v18.0.0 or greater installed before continuing.

Start by cloning the repository to your local machine.

git clone https://github.com/UTDNebula/jupiter.git

Next, navigate to the project directory and install the dependencies.

cd jupiter
npm install

Make sure you have a .env file in the root of the project. If you do not, copy the .env.example file and rename it to .env

Environment Variables

This project uses NextAuth for authentication. In order to use NextAuth, you will need to create a Google OAuth Client ID and Client Secret. You can do this by following the instructions here.

Once you have your Client ID and Client Secret, add them to your .env file.

The NEXTAUTH_URL variable should be set to http://localhost:3000 for local development. The NEXTAUTH_SECRET variable should be set to a random string of characters. You can generate one here. or by running the following command in your terminal.

openssl rand -hex 32

Jupiter uses an ORM called Drizzle to interact with the database. In order to connect to the database, you will need to add the DATABASE_URL variable to your .env file.

We're using Supabase as our database provider. You can create a supabase account here. Once you have created an account, you can create a new project and add the DATABASE_URL to your .env file. From a Supabase project, you can find the DATABASE_URL by navigating to the Settings tab and clicking on the Database tab.

Database Migrations

In your SQL editor, you will have to run a couple commands in order to properly set up the database

Nanoid

Run the following command to install the nanoid extension.

CREATE EXTENSION IF NOT EXISTS pgcrypto;

CREATE OR REPLACE FUNCTION nanoid(size int DEFAULT 21, alphabet text DEFAULT '_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
    RETURNS text
    LANGUAGE plpgsql
    volatile
AS
$$
DECLARE
    idBuilder text := '';
    i int := 0;
    bytes bytea;
    alphabetIndex int;
    mask int;
    step int;
BEGIN
    mask := (2 << cast(floor(log(length(alphabet) - 1) / log(2)) as int)) - 1;
    step := cast(ceil(1.6 * mask * size / length(alphabet)) AS int);

    while true
        loop
            bytes := gen_random_bytes(size);
            while i < size
                loop
                    alphabetIndex := (get_byte(bytes, i) & mask) + 1;
                    if alphabetIndex <= length(alphabet) then
                        idBuilder := idBuilder || substr(alphabet, alphabetIndex, 1);
                        if length(idBuilder) = size then
                            return idBuilder;
                        end if;
                    end if;
                    i = i + 1;
                end loop;

            i := 0;
        end loop;
END
$$;
Enums

Currently, drizzle does not automatically create enums for you. You will have to create them manually. This link should give you a good idea of how to create enums in postgres.


Once you have added the DATABASE_URL to your .env file, and have all the necessary extensions as well as enums, you will need to run the following commands to create the tables in your database.

npm run drizzle:generate
npm run drizzle:push

These commands will create the tables in your database based on the models defined in the src/server/db/schema.ts directory. You would also run these commands anytime there are changes to schema.ts in order to update the database.

Finally, start the development server.

npm run dev

Branching

When working on a new feature, please create a new branch with the following naming convention:

git checkout -b feature/<feature-name>

When you are ready to merge your branch into the develop branch, please create a pull request and request a review from the Jupiter Dev Team. Please include details about what issue you are addressing with the pull request, what changes you made, and any other relevant information.

About

A tool to help students get involved on campus

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 89.8%
  • JavaScript 7.7%
  • CSS 2.5%