Update plugins/federations.js
Browse files- plugins/federations.js +60 -0
plugins/federations.js
CHANGED
@@ -4,6 +4,66 @@ import { authenticateApiKey, apiLimiter } from '../middleware/midware.js';
|
|
4 |
import { Federation } from '../models.js';
|
5 |
const FedsRoutes = express.Router();
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
FedsRoutes.post("/api/v2/federation/newfed", authenticateApiKey, apiLimiter, async (req, res) => {
|
8 |
try {
|
9 |
const { name, owner } = req.body;
|
|
|
4 |
import { Federation } from '../models.js';
|
5 |
const FedsRoutes = express.Router();
|
6 |
|
7 |
+
/**
|
8 |
+
* @swagger
|
9 |
+
* /api/v2/federation/newfed:
|
10 |
+
* post:
|
11 |
+
* summary: Create a new federation
|
12 |
+
* tags: [Federation]
|
13 |
+
* description: Creates a new federation with a unique name and owner.
|
14 |
+
* security:
|
15 |
+
* - apiKeyAuth: []
|
16 |
+
* requestBody:
|
17 |
+
* required: true
|
18 |
+
* content:
|
19 |
+
* application/json:
|
20 |
+
* schema:
|
21 |
+
* type: object
|
22 |
+
* properties:
|
23 |
+
* name:
|
24 |
+
* type: string
|
25 |
+
* description: The unique name of the federation.
|
26 |
+
* owner:
|
27 |
+
* type: integer
|
28 |
+
* description: The user ID of the federation owner.
|
29 |
+
* parameters:
|
30 |
+
* - in: header
|
31 |
+
* name: x-api-key
|
32 |
+
* required: true
|
33 |
+
* description: API key for authentication.
|
34 |
+
* schema:
|
35 |
+
* type: string
|
36 |
+
* responses:
|
37 |
+
* 200:
|
38 |
+
* description: Federation created successfully.
|
39 |
+
* content:
|
40 |
+
* application/json:
|
41 |
+
* schema:
|
42 |
+
* type: object
|
43 |
+
* properties:
|
44 |
+
* message:
|
45 |
+
* type: string
|
46 |
+
* example: Federation created successfully
|
47 |
+
* federation:
|
48 |
+
* type: object
|
49 |
+
* properties:
|
50 |
+
* name:
|
51 |
+
* type: string
|
52 |
+
* owner:
|
53 |
+
* type: integer
|
54 |
+
* banned_users:
|
55 |
+
* type: array
|
56 |
+
* items:
|
57 |
+
* type: integer
|
58 |
+
* sub_federations:
|
59 |
+
* type: array
|
60 |
+
* items:
|
61 |
+
* type: string
|
62 |
+
* 400:
|
63 |
+
* description: Federation already exists or missing parameters.
|
64 |
+
* 500:
|
65 |
+
* description: Internal server error.
|
66 |
+
*/
|
67 |
FedsRoutes.post("/api/v2/federation/newfed", authenticateApiKey, apiLimiter, async (req, res) => {
|
68 |
try {
|
69 |
const { name, owner } = req.body;
|