-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstandards.js
56 lines (50 loc) · 1.27 KB
/
standards.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import prisma from '../../lib/prisma';
import requiresAuth from '../../lib/requiresAuthApiMiddleware';
/**
* @swagger
* tags:
* name: standards
* description: Health & Care Standards
*/
/**
* @swagger
* components:
* schemas:
* standard:
* properties:
* id:
* type: integer
* example: 1
* name:
* type: string
* example: Timely Care
*/
/**
* @swagger
* /standards:
* get:
* summary: Retrieve the list of standards stored in the system
* description: Retrieve the list of standards stored in the system, with their ID and name
* tags: [standards]
* responses:
* 200:
* description: Success
* content:
* application/json:
* schema:
* type: array
* items:
* $ref: '#/components/schemas/standard'
* 401:
* $ref: '#/components/responses/unauthorized'
* 500:
* $ref: '#/components/responses/internal_server_error'
*/
const handler = async (req, res) => {
if (req.method === 'GET') {
const standards = await prisma.standards.findMany();
return res.json(standards);
}
res.status(405).json({ error: true, message: 'Method Not Allowed' });
};
export default requiresAuth(handler);