Cover photo

s5 update #4

龴ↀ◡ↀ龴 qcast 龴ↀ◡ↀ龴

_tldr_

  • studied & revised a lot of concepts and tools: neynar, nextjs vs express, fetch api, postman vs swagger.

  • building toy version = cast from script, no frontend

  • last update

_toy version_

1. project setup
- set up nextjs repo
- structure folders like this https://nextjs.org/docs/getting-started/project-structure

2. write logic to connect signer, neynar api key, neynar client and post cast
- first read docs for posting a cast https://docs.neynar.com/reference/post-cast then write all logic in one file neynar.ts but use these 2 github links as examples:
- main logic will be similar to this (search createcast) https://github.com/builders-garden/pulse-api/blob/main/src/modules/farcaster/farcaster.service.ts
- get neynar client from neynar api key https://github.com/builders-garden/pulse-api/blob/main/src/utils/neynar.ts

3. test the api call with postman
- study this about fetching apis https://developer.mozilla.org/en-us/docs/web/api/fetch_api/using_fetch
- set an endpoint and test with postman or swagger https://nextjs.org/docs/pages/building-your-application/routing/api-routes
localhost3000/api/qcast ... this will call route.ts inside api/qcast

_later_
4. endpoint accept calls only from my frontend
- to protect endpoint: create a x-secret in the .env
- pass to the api - in postman headers (or in frontend headers later) set it to be the same

5. in my frontend, only specific farcaster user can call api
- in page body, use neynar authentication so it gets the signeruuid from the fid
authentication https://docs.neynar.com/docs/how-to-let-users-connect-farcaster-accounts-with-write-access-for-free-using-sign-in-with-neynar-siwn