This is the code for [https://enghub.io] -- the room booking system for the UCL Engineering Hub.
This is a Next.js app using Prisma as an ORM for an EngHub PostgreSQL database.
Authentication is done using UCL API's OAuth system via NextAuth.js.
The API routes are in ./pages/api
. All files in this directory are treated as API routes instead of React pages.
- Clone this repository
- Copy
.env.example
to.env
and fill in the environment variables - Run
npm install
to install dependencies - Run
npx prisma generate
to generate the local Prisma client (used for database interactions) - Run
npm run dev
to run the development server (with hot reloading etc.) -- by default this will be on port 3000
Open http://localhost:3000 with your browser to see the result.
Migrations are managed through Prisma. One potential workflow is:
- Update your local database manually and run
npx prisma db pull
which will automatically update theprisma.schema
file with the changes you made - Run
npx prisma migrate dev
to automatically create a migration based on this change -- you will be prompted to enter a short descriptive name (e.g.,alphanumeric_booking_ids
)
All changes to files under prisma/
should be committed to Git.
EngHub uses UCL API's OAuth system. See the docs for more information.
NextAuth.js is used to integrate the OAuth: see the ./pages/api/auth/[...nextauth].js
file to see how this is implemented, with inline comments explaining how it works.