@nextsparkjs/plugin-social-media-publisher 0.1.0-beta.50 → 0.1.0-beta.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,7 @@
18
18
 
19
19
  import { NextRequest, NextResponse } from 'next/server'
20
20
  import { authenticateRequest } from '@nextsparkjs/core/lib/api/auth/dual-auth'
21
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
21
22
  import { TokenEncryption } from '@nextsparkjs/core/lib/oauth/encryption'
22
23
  import { FacebookAPI } from '../../../../lib/providers/facebook'
23
24
  import {
@@ -26,7 +27,7 @@ import {
26
27
  } from '../../../../lib/oauth-helper'
27
28
  import { mutateWithRLS } from '@nextsparkjs/core/lib/db'
28
29
 
29
- export async function GET(request: NextRequest) {
30
+ const getHandler = async (request: NextRequest) => {
30
31
  try {
31
32
  // 1. Parse state to extract clientId, platform, and mode
32
33
  const { searchParams } = new URL(request.url)
@@ -667,3 +668,5 @@ export async function GET(request: NextRequest) {
667
668
  })
668
669
  }
669
670
  }
671
+
672
+ export const GET = withRateLimitTier(getHandler, 'read')
@@ -7,6 +7,7 @@
7
7
 
8
8
  import { NextRequest, NextResponse } from 'next/server'
9
9
  import { authenticateRequest } from '@nextsparkjs/core/lib/api/auth/dual-auth'
10
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
10
11
  import { TokenEncryption } from '@nextsparkjs/core/lib/oauth/encryption'
11
12
  import { FacebookAPI } from '../../../lib/providers/facebook'
12
13
  import { ConnectAccountSchema } from '../../../lib/validation'
@@ -18,7 +19,7 @@ import { mutateWithRLS } from '@nextsparkjs/core/lib/db'
18
19
  * GET - Initiate OAuth flow
19
20
  * Redirects user to Facebook OAuth authorization page
20
21
  */
21
- export async function GET(request: NextRequest) {
22
+ const getHandler = async (request: NextRequest) => {
22
23
  try {
23
24
  const { searchParams } = new URL(request.url)
24
25
  const platform = searchParams.get('platform') || 'instagram_business'
@@ -96,11 +97,13 @@ export async function GET(request: NextRequest) {
96
97
  }
97
98
  }
98
99
 
100
+ export const GET = withRateLimitTier(getHandler, 'read')
101
+
99
102
  /**
100
103
  * POST - Handle OAuth callback (deprecated - use /callback endpoint instead)
101
104
  * This endpoint receives the authorization code and exchanges it for access token
102
105
  */
103
- export async function POST(request: NextRequest) {
106
+ const postHandler = async (request: NextRequest) => {
104
107
  try {
105
108
  // 1. Authentication
106
109
  const authResult = await authenticateRequest(request)
@@ -325,3 +328,5 @@ export async function POST(request: NextRequest) {
325
328
  )
326
329
  }
327
330
  }
331
+
332
+ export const POST = withRateLimitTier(postHandler, 'write')
@@ -7,10 +7,11 @@
7
7
 
8
8
  import { NextRequest, NextResponse } from 'next/server'
9
9
  import { authenticateRequest } from '@nextsparkjs/core/lib/api/auth/dual-auth'
10
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
10
11
  import { DisconnectAccountSchema } from '../../../lib/validation'
11
12
  import { queryOneWithRLS, mutateWithRLS } from '@nextsparkjs/core/lib/db'
12
13
 
13
- export async function POST(request: NextRequest) {
14
+ const postHandler = async (request: NextRequest) => {
14
15
  try {
15
16
  // 1. Authentication
16
17
  const authResult = await authenticateRequest(request)
@@ -134,13 +135,15 @@ export async function POST(request: NextRequest) {
134
135
  }
135
136
  }
136
137
 
138
+ export const POST = withRateLimitTier(postHandler, 'write')
139
+
137
140
  /**
138
141
  * DELETE method - Alternative endpoint using accountId in URL
139
142
  */
140
- export async function DELETE(
143
+ const deleteHandler = async (
141
144
  request: NextRequest,
142
145
  { params }: { params: Promise<{ accountId: string }> }
143
- ) {
146
+ ) => {
144
147
  try {
145
148
  // 1. Authentication
146
149
  const authResult = await authenticateRequest(request)
@@ -185,3 +188,5 @@ export async function DELETE(
185
188
  )
186
189
  }
187
190
  }
191
+
192
+ export const DELETE = withRateLimitTier(deleteHandler, 'write')
@@ -16,13 +16,14 @@
16
16
 
17
17
  import { NextRequest, NextResponse } from 'next/server'
18
18
  import { authenticateRequest } from '@nextsparkjs/core/lib/api/auth/dual-auth'
19
+ import { withRateLimitTier } from '@nextsparkjs/core/lib/api/rate-limit'
19
20
  import { TokenEncryption } from '@nextsparkjs/core/lib/oauth/encryption'
20
21
  import { FacebookAPI } from '../../../lib/providers/facebook'
21
22
  import { InstagramAPI } from '../../../lib/providers/instagram'
22
23
  import { PublishPhotoSchema, validateImageUrl, validateCaption, platformRequiresImage } from '../../../lib/validation'
23
24
  import { queryOneWithRLS, mutateWithRLS } from '@nextsparkjs/core/lib/db'
24
25
 
25
- export async function POST(request: NextRequest) {
26
+ const postHandler = async (request: NextRequest) => {
26
27
  try {
27
28
  // 1. Authentication
28
29
  const authResult = await authenticateRequest(request)
@@ -302,6 +303,8 @@ export async function POST(request: NextRequest) {
302
303
  }
303
304
  }
304
305
 
306
+ export const POST = withRateLimitTier(postHandler, 'write')
307
+
305
308
  /**
306
309
  * Refresh OAuth token for a social media account
307
310
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextsparkjs/plugin-social-media-publisher",
3
- "version": "0.1.0-beta.50",
3
+ "version": "0.1.0-beta.52",
4
4
  "private": false,
5
5
  "main": "./plugin.config.ts",
6
6
  "requiredPlugins": [],
@@ -10,7 +10,7 @@
10
10
  "react": "^19.0.0",
11
11
  "react-dom": "^19.0.0",
12
12
  "zod": "^4.0.0",
13
- "@nextsparkjs/core": "0.1.0-beta.50"
13
+ "@nextsparkjs/core": "0.1.0-beta.52"
14
14
  },
15
15
  "nextspark": {
16
16
  "type": "plugin",