Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: posts api #4075

Merged
merged 14 commits into from
Jul 25, 2024
Merged

feat: posts api #4075

merged 14 commits into from
Jul 25, 2024

Conversation

sywhb
Copy link
Contributor

@sywhb sywhb commented Jun 18, 2024

Post

a public link omnivore.app/list/userId/posts/id which omnivore user shares through social apps

  • a list of library items
  • selected highlights (optional)
  • thoughts (optional)
  • thumbnail picture (optional)

List

a link omnivore.app/list/userId/posts contains a list of "Post" shared by the user which user can share through social apps.

It can be accessed if user make the profile public

Changes

  • create post table and entity
  • add list posts api and tests
  • tidy
  • add get post graphql api and tests
  • add create post graphql api and tests
  • add update post graphql api and tests
  • add delete post graphql api and tests

Copy link

vercel bot commented Jun 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
omnivore-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2024 2:54am
omnivore-prod ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2024 2:54am

@sywhb
Copy link
Contributor Author

sywhb commented Jun 18, 2024

There are lots of "tidy" changes in this PR which you can ignore

Copy link

github-actions bot commented Jun 19, 2024

Squawk Report

✅ 0 violations across 1 file(s)


packages/db/migrations/0184.do.post.sql

-- Type: DO
-- Name: post
-- Description: Create a post table

BEGIN;

CREATE TABLE omnivore.post (
    id UUID PRIMARY KEY DEFAULT uuid_generate_v1mc(),
    user_id UUID NOT NULL REFERENCES omnivore.user(id) ON DELETE CASCADE,
    library_item_ids UUID[] NOT NULL,
	highlight_ids UUID[],
    title TEXT NOT NULL,
	content TEXT NOT NULL, -- generated from template
	thumbnail TEXT,
	thought TEXT,
    created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX post_user_id_idx ON omnivore.post(user_id);

GRANT SELECT, INSERT, UPDATE, DELETE ON omnivore.post TO omnivore_user;

ALTER TABLE omnivore.post ENABLE ROW LEVEL SECURITY;

CREATE POLICY read_post ON omnivore.post
    FOR SELECT TO omnivore_user
    USING (true);

CREATE POLICY write_post ON omnivore.post
    FOR INSERT TO omnivore_user
    WITH CHECK (user_id = omnivore.get_current_user_id());

CREATE POLICY update_post ON omnivore.post
    FOR UPDATE TO omnivore_user
    USING (user_id = omnivore.get_current_user_id());

CREATE POLICY delete_post ON omnivore.post
    FOR DELETE TO omnivore_user
    USING (user_id = omnivore.get_current_user_id());

COMMIT;

✅ Rule Violations (0)

No violations found.


📚 More info on rules

⚡️ Powered by Squawk (1.1.2), a linter for PostgreSQL, focused on migrations

userId: loginUser.id,
})

expect(response.body.data.posts.errorCodes).to.eql(['BAD_REQUEST'])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newbie question. What is the invalid arg here ?? I see a similar request below, testing for an empty array.. Is 100 the invalid arg here ?

 it('should return empty array', async () => {
          const response = await graphqlRequest(query, '', {
            first: 10,
            userId: loginUser.id,
          })

          expect(response.body.data.posts.edges).to.be.empty
        })

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @pradeepmurugesan , sorry for the late reply.

I should be more clear here but yes 100 is invalid because the maximum number of posts allowed to requests a time is 50.

@sywhb sywhb merged commit ee5e66d into main Jul 25, 2024
7 checks passed
@sywhb sywhb deleted the feature/posts branch July 25, 2024 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants