Skip to content

GeneralMagicio/pdoge-backend

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Discord Backers on Open Collective Sponsors on Open Collective Donate us Support us Follow us on Twitter

Description

Nest framework TypeScript starter repository.

Project setup

$ yarn install

Compile and run the project

# development
$ yarn run start

# watch mode
$ yarn run start:dev

# production mode
$ yarn run start:prod

Run tests

# unit tests
$ yarn run test

# e2e tests
$ yarn run test:e2e

# test coverage
$ yarn run test:cov

Deployment

When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the deployment documentation for more information.

If you are looking for a cloud-based platform to deploy your NestJS application, check out Mau, our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:

$ yarn install -g @nestjs/mau
$ mau deploy

With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.

Resources

Check out a few resources that may come in handy when working with NestJS:

  • Visit the NestJS Documentation to learn more about the framework.
  • For questions and support, please visit our Discord channel.
  • To dive deeper and get more hands-on experience, check out our official video courses.
  • Deploy your application to AWS with the help of NestJS Mau in just a few clicks.
  • Visualize your application graph and interact with the NestJS application in real-time using NestJS Devtools.
  • Need help with your project (part-time to full-time)? Check out our official enterprise support.
  • To stay in the loop and get updates, follow us on X and LinkedIn.
  • Looking for a job, or have a job to offer? Check out our official Jobs board.

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

EOA Signature Auth (JWT)

Setup

  1. Set environment variables:
export DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DBNAME?schema=public"
export JWT_SECRET="replace-with-strong-secret"
  1. Generate Prisma client and run migrations:
yarn prisma:generate
yarn prisma:migrate --name init
  1. Start the server:
yarn start:dev

Endpoints

  • POST POST /auth/request-message
    • body: { "address": "0x..." }
    • returns: { message, expiresAt }
  • POST POST /auth/verify
    • body: { "address": "0x...", "signature": "0x..." }
    • returns: { accessToken, expiresInSeconds, address }
  • GET GET /auth/me with Authorization: Bearer <token>

The message is deterministic per nonce: Sign in to PDoge\n\nNonce: <nonce>. Clients should sign exactly this string with their wallet (e.g., MetaMask) and submit the signature to /auth/verify.

Token Analyses Cache & Twitter Autoposter

LLM analysis storage

  • POST /token-analyses accepts the raw LLM response plus optional metadata so we can cache trending contract reviews.
  • Minimum payload:
{
  "tokenAddress": "0x1234...",
  "tokenName": "PolyDoge",
  "tokenSymbol": "PDOGE",
  "content": "Full markdown/text response from the LLM",
  "verdictLine": "Final verdict snippet",
  "metrics": [{ "key": "liq", "label": "Liquidity", "value": "$14M" }],
  "vulnerabilities": [{ "severity": 8.5, "text": "Severity: 8/10 – Proxy not upgrade-safe" }],
  "aiModel": "gpt-4.1",
  "analysisType": "contract",
  "trendScore": 0.82,
  "trendingUntil": "2025-11-17T02:30:00.000Z",
  "isTrending": true,
  "metadata": { "promptVersion": "v6" }
}
  • GET /token-analyses/token/:address returns the latest cached analysis for a contract.
  • GET /token-analyses/trending?limit=10 surfaces the most recent trending cache entries that are eligible for reuse by the UI or bots.

All responses follow the same structure, returning stored metrics, verdict lines, parsed vulnerabilities, and trend metadata while hiding the internal content hash.

Twitter autoposter

The backend now keeps a background worker alive that tweets one cached analysis every ~2 hours (interval is configurable). Tweets reuse the same copy as the front-end share button: header banner, token metadata, emoji-coded severity lines capped at 280 characters, and automatic threading when a single analysis produces multiple findings.

Configure via environment variables:

Variable Description
TWITTER_CONSUMER_KEY API Key from X developer portal
TWITTER_CONSUMER_SECRET API Key secret
TWITTER_ACCESS_TOKEN OAuth1.0a access token with write scope
TWITTER_ACCESS_SECRET OAuth1.0a access token secret
TWITTER_AUTOPOST Set to false to disable the cron without removing creds
TWITTER_POST_INTERVAL_MS Optional override for the 2h cadence
TWITTER_INITIAL_DELAY_MS Optional delay before the first automatic post

The autoposter only uses analyses that are marked trending, have not been tweeted in the last 12 hours, and still contain meaningful content. Each successful run updates lastTweetedAt so the same contract is not spammed repeatedly. Errors are logged but never crash the API server.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published