admin管理员组

文章数量:1122846

i am having issue with deploying my solana blink and make uref on X in express js. how do i go about the action.json file in express js, most tutorial are in next js

i have a action.ts file in the root of the application,

see what i have odne so far ..

import { ActionsJson, ACTIONS_CORS_HEADERS } from '@solana/actions';
import { Request, Response, NextFunction } from 'express';
import express from 'express';

const router = express.Router();

export const GET = async (req: Request, res: Response, next: NextFunction) => {
  try {
    const payload: ActionsJson = {
      rules: [
        {
          pathPattern: '/example-path',
          apiPath: '/api/endpoint',
        },
      ],
    };

    // Set CORS headers for the response
    Object.entries(ACTIONS_CORS_HEADERS).forEach(([key, value]) => {
      res.setHeader(key, value);
    });

    // Respond with JSON payload
    res.status(200).json(payload);
  } catch (error) {
    next(error);
  }
};

export const OPTIONS = (req: Request, res: Response) => {
  // Set CORS headers for preflight response
  Object.entries(ACTIONS_CORS_HEADERS).forEach(([key, value]) => {
    res.setHeader(key, value);
  });

  res.sendStatus(204);
};

// route
router.get('/api/actions', GET);

export default router;``

本文标签: solana actions and blinks in express jsStack Overflow