Code Monkey home page Code Monkey logo

gatho-website's Introduction

Gatho Events

Invite friends to your event with a one-click RSVP link - no matter which chat/social app they use!

Gatho is an event planning app which works great standalone, but can integrate with a group chat on Matrix. It is a side project by Jake Coppinger (jakecoppinger.com).

Jake previously hosted it at gatho.party but has since shut down that instance. Feel free to spin up your own using the below instructions.

Architecture

Gatho uses Next.js in Typescript (React on the frontend), and Postgres as a database.

The matrix bot uses matrix-bot-sdk and sends RSVPs or new events to the Gatho backend server.

Architecture

It should work anywhere you can run a Next.js Node app.

  • Gatho uses NextAuth.js for authentication so no passwords are required to be stored.
  • API calls are checked for session token and that the requester owns the given event.
  • Database calls use SQL parameters.
  • No third party cookies are set and no third party JavaScript is run.

Get started building

Setting up database

Gatho uses Postgres. It gets the database location via the database URLs in the .env file.

Copy example-.env to .env as an example file to get started.

Make sure to populate all the example values.

See docs/installing-postgres.md for installation instructions if you'd like to setup a local server.

Creating the database tables

Run ./scripts/create-database-tables-local.sh

Running website dev server

  • npm i
  • npm run build
  • npm run dev

Debugging

Prisma

Gatho currently uses NextAuth.js for authentication. This reqires using a NextAuth database adapter - I haven't written my own at this stage so I used Prisma. This comes with some quirks.

Update: A vanilla postgres adapter has been merged - this could be used to remove Prisma usage: nextauthjs/next-auth#4933 (comment)

Error creating shadow database

I encountered this when using Heroku during development. See prisma/prisma#4571 (comment)

  • Change your prisma .env file to local db (mydb)

  • Delete prisma/migrations folder if any

  • Run npx prisma migrate dev --preview-feature to start a new migration

  • Change your prisma .env file back to the development db

  • Run npx prisma migrate resolve --applied "{{MIGRATION_FOLDER_NAME_GENERATED_BY_STEP_4}}" --preview-feature

  • npx prisma migrate reset

Debugging database issues

Some SQL tables use SERIAL keywords. If you delete a record the counter can become outdated. Run this snippet replacing "events" with the table you're having issues with

SELECT SETVAL((SELECT PG_GET_SERIAL_SEQUENCE('"events"', 'id')), (SELECT (MAX("id") + 1) FROM "events"), FALSE);

License

GNU Affero General Public License v3.0. See LICENSE.

Original author

Jake Coppinger (jakecoppinger.com).

gatho-website's People

Contributors

dependabot[bot] avatar jakecoppinger avatar maxwellbo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

maxwellbo

gatho-website's Issues

What is an RSVP?

This term appears multiple times on the site and I didn't know what it was before looking it up. Maybe it would be possible to use a more common term, or explain what an RSVP the first time it is mentioned.

Encountering `adapter_error_createVerificationToken` after local DB standup

next-auth][error][adapter_error_createVerificationToken]
https://next-auth.js.org/errors#adapter_error_createverificationtoken
Invalid p.verificationToken.create() invocation in
/Users/mb/gatho-website/node_modules/@next-auth/prisma-adapter/dist/index.js:34:64
  31 createSession: (data) => p.session.create({ data }),
  32 updateSession: (data) => p.session.update({ data, where: { sessionToken: data.sessionToken } }),
  33 deleteSession: (sessionToken) => p.session.delete({ where: { sessionToken } }),
→ 34 createVerificationToken: (data) => p.verificationToken.create(
  The provided database string is invalid. Error parsing connection string: invalid port number in database URL. Please refer to the documentation in https://www.prisma.io/docs/reference/database-reference/connection-urls for constructing a correct connection string. In some cases, certain characters must be escaped. Please check the string for any illegal characters. {
  message: '\n' +
    'Invalid p.verificationToken.create() invocation in\n' +
    '/Users/mb/gatho-website/node_modules/@next-auth/prisma-adapter/dist/index.js:34:64\n' +
    '\n' +
    '  31 createSession: (data) => p.session.create({ data }),\n' +
    '  32 updateSession: (data) => p.session.update({ data, where: { sessionToken: data.sessionToken } }),\n' +
    '  33 deleteSession: (sessionToken) => p.session.delete({ where: { sessionToken } }),\n' +
    '→ 34 createVerificationToken: (data) => p.verificationToken.create(\n' +
    '  The provided database string is invalid. Error parsing connection string: invalid port number in database URL. Please refer to the documentation in https://www.prisma.io/docs/reference/database-reference/connection-urls for constructing a correct connection string. In some cases, certain characters must be escaped. Please check the string for any illegal characters.',
  stack: 'Error: \n' +
    'Invalid p.verificationToken.create() invocation in\n' +
    '/Users/mb/gatho-website/node_modules/@next-auth/prisma-adapter/dist/index.js:34:64\n' +
    '\n' +
    '  31 createSession: (data) => p.session.create({ data }),\n' +
    '  32 updateSession: (data) => p.session.update({ data, where: { sessionToken: data.sessionToken } }),\n' +
    '  33 deleteSession: (sessionToken) => p.session.delete({ where: { sessionToken } }),\n' +
    '→ 34 createVerificationToken: (data) => p.verificationToken.create(\n' +
    '  The provided database string is invalid. Error parsing connection string: invalid port number in database URL. Please refer to the documentation in https://www.prisma.io/docs/reference/database-reference/connection-urls for constructing a correct connection string. In some cases, certain characters must be escaped. Please check the string for any illegal characters.\n' +
    '    at cb (/Users/mb/gatho-website/node_modules/@prisma/client/runtime/index.js:38681:17)',
  name: 'Error'
}

I assume this is to do with the fact that schema.prisma defines

datasource db {
  provider = "postgresql"
  url      = ""
}

you could define

url = env("DATABASE_URL_AU")

as per https://www.prisma.io/docs/reference/database-reference/connection-urls

but that simply recovers the uninterpolated DB URL "postgres://{username}:{password}@{database_url:{port}/{database_name}".

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.