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.exampleto.envand fill in the environment variables - Run
npm installto install dependencies - Run
npx prisma generateto generate the local Prisma client (used for database interactions) - Run
npm run devto 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 pullwhich will automatically update theprisma.schemafile with the changes you made - Run
npx prisma migrate devto 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.