|
| 1 | +import { Router } from 'express'; |
| 2 | + |
| 3 | +import request from 'nb-schemas/dist/nfts/tokens/request.js'; |
| 4 | + |
| 5 | +import { bearerAuth } from '#middlewares/passport'; |
| 6 | +import rateLimiter from '#middlewares/rateLimiter'; |
| 7 | +import { validate } from '#middlewares/validate'; |
| 8 | +import service from '#services/v3/nfts/token'; |
| 9 | + |
| 10 | +const route = Router(); |
| 11 | + |
| 12 | +const routes = (app: Router) => { |
| 13 | + app.use('/nfts', bearerAuth, rateLimiter, route); |
| 14 | + |
| 15 | + /** |
| 16 | + * @openapi |
| 17 | + * /v3/nfts/{contract}/tokens: |
| 18 | + * get: |
| 19 | + * summary: Get nft tokens |
| 20 | + * tags: |
| 21 | + * - V3 / NFTs |
| 22 | + * parameters: |
| 23 | + * - in: path |
| 24 | + * name: contract |
| 25 | + * required: true |
| 26 | + * description: Contract ID |
| 27 | + * schema: |
| 28 | + * type: string |
| 29 | + * - in: query |
| 30 | + * name: next |
| 31 | + * description: Next page cursor. Pass the next_page value returned from the previous response to retrieve the next page of results |
| 32 | + * schema: |
| 33 | + * type: string |
| 34 | + * - in: query |
| 35 | + * name: prev |
| 36 | + * description: Previous page cursor. Pass the prev_page value returned from the previous response to retrieve the previous page of results |
| 37 | + * schema: |
| 38 | + * type: string |
| 39 | + * - in: query |
| 40 | + * name: limit |
| 41 | + * description: The number of items to return. Each increment of 25 will count towards rate limit. For example, limit 50 will use 2 credits |
| 42 | + * schema: |
| 43 | + * type: integer |
| 44 | + * minimum: 1 |
| 45 | + * maximum: 100 |
| 46 | + * default: 25 |
| 47 | + * responses: |
| 48 | + * 200: |
| 49 | + * description: Success response |
| 50 | + */ |
| 51 | + route.get('/:contract/tokens', validate(request.list), service.list); |
| 52 | + |
| 53 | + /** |
| 54 | + * @openapi |
| 55 | + * /v3/nfts/{contract}/tokens/count: |
| 56 | + * get: |
| 57 | + * summary: Get nft tokens count |
| 58 | + * tags: |
| 59 | + * - V3 / NFTs |
| 60 | + * parameters: |
| 61 | + * - in: path |
| 62 | + * name: contract |
| 63 | + * required: true |
| 64 | + * description: Contract ID |
| 65 | + * schema: |
| 66 | + * type: string |
| 67 | + * responses: |
| 68 | + * 200: |
| 69 | + * description: Success response |
| 70 | + */ |
| 71 | + route.get( |
| 72 | + '/:contract/tokens/count', |
| 73 | + validate(request.tokenCount), |
| 74 | + service.tokenCount, |
| 75 | + ); |
| 76 | + |
| 77 | + /** |
| 78 | + * @openapi |
| 79 | + * /v3/nfts/{contract}/tokens/{token}: |
| 80 | + * get: |
| 81 | + * summary: Get nft token info |
| 82 | + * tags: |
| 83 | + * - V3 / NFTs |
| 84 | + * parameters: |
| 85 | + * - in: path |
| 86 | + * name: contract |
| 87 | + * required: true |
| 88 | + * description: Contract ID |
| 89 | + * schema: |
| 90 | + * type: string |
| 91 | + * - in: path |
| 92 | + * name: token |
| 93 | + * required: true |
| 94 | + * description: Token ID |
| 95 | + * schema: |
| 96 | + * type: string |
| 97 | + * responses: |
| 98 | + * 200: |
| 99 | + * description: Success response |
| 100 | + */ |
| 101 | + route.get('/:contract/tokens/:token', validate(request.token), service.token); |
| 102 | + |
| 103 | + /** |
| 104 | + * @openapi |
| 105 | + * /v3/nfts/{contract}/tokens/{token}/txns: |
| 106 | + * get: |
| 107 | + * summary: Get nft token transfers |
| 108 | + * tags: |
| 109 | + * - V3 / NFTs |
| 110 | + * parameters: |
| 111 | + * - in: path |
| 112 | + * name: contract |
| 113 | + * required: true |
| 114 | + * description: Contract ID |
| 115 | + * schema: |
| 116 | + * type: string |
| 117 | + * - in: path |
| 118 | + * name: token |
| 119 | + * required: true |
| 120 | + * description: Token ID |
| 121 | + * schema: |
| 122 | + * type: string |
| 123 | + * - in: query |
| 124 | + * name: before_ts |
| 125 | + * description: Timestamp in nanoseconds. Return results before this timestamp (exclusive) |
| 126 | + * schema: |
| 127 | + * type: string |
| 128 | + * minLength: 19 |
| 129 | + * maxLength: 19 |
| 130 | + * - in: query |
| 131 | + * name: next |
| 132 | + * description: Next page cursor. Pass the next_page value returned from the previous response to retrieve the next page of results |
| 133 | + * schema: |
| 134 | + * type: string |
| 135 | + * - in: query |
| 136 | + * name: prev |
| 137 | + * description: Previous page cursor. Pass the prev_page value returned from the previous response to retrieve the previous page of results |
| 138 | + * schema: |
| 139 | + * type: string |
| 140 | + * - in: query |
| 141 | + * name: limit |
| 142 | + * description: The number of items to return. Each increment of 25 will count towards rate limit. For example, limit 50 will use 2 credits |
| 143 | + * schema: |
| 144 | + * type: integer |
| 145 | + * minimum: 1 |
| 146 | + * maximum: 100 |
| 147 | + * default: 25 |
| 148 | + * responses: |
| 149 | + * 200: |
| 150 | + * description: Success response |
| 151 | + */ |
| 152 | + route.get( |
| 153 | + '/:contract/tokens/:token/txns', |
| 154 | + validate(request.txns), |
| 155 | + service.txns, |
| 156 | + ); |
| 157 | + |
| 158 | + /** |
| 159 | + * @openapi |
| 160 | + * /v3/nfts/{contract}/tokens/{token}/txns/count: |
| 161 | + * get: |
| 162 | + * summary: Get nft token transfers count |
| 163 | + * tags: |
| 164 | + * - V3 / NFTs |
| 165 | + * parameters: |
| 166 | + * - in: path |
| 167 | + * name: contract |
| 168 | + * required: true |
| 169 | + * description: Contract ID |
| 170 | + * schema: |
| 171 | + * type: string |
| 172 | + * - in: path |
| 173 | + * name: token |
| 174 | + * required: true |
| 175 | + * description: Token ID |
| 176 | + * schema: |
| 177 | + * type: string |
| 178 | + * - in: query |
| 179 | + * name: before_ts |
| 180 | + * description: Timestamp in nanoseconds. Return results before this timestamp (exclusive) |
| 181 | + * schema: |
| 182 | + * type: string |
| 183 | + * minLength: 19 |
| 184 | + * maxLength: 19 |
| 185 | + * responses: |
| 186 | + * 200: |
| 187 | + * description: Success response |
| 188 | + */ |
| 189 | + route.get( |
| 190 | + '/:contract/tokens/:token/txns/count', |
| 191 | + validate(request.txnCount), |
| 192 | + service.txnCount, |
| 193 | + ); |
| 194 | +}; |
| 195 | + |
| 196 | +export default routes; |
0 commit comments