/ src / services / masters / masters.service.ts
masters.service.ts
 1  // Initializes the `masters` service on path `/masters`
 2  import type { Application } from "../../declarations";
 3  import logger from "../../logger";
 4  import createModel from "../../models/masters.model";
 5  import { Masters } from "./masters.class";
 6  import hooks from "./masters.hooks";
 7  
 8  declare module "../../declarations" {
 9  	interface MastersServiceTypes {
10  		masters: Masters;
11  	}
12  }
13  
14  /**
15   * @swagger
16   * tags:
17   *   name: Masters
18   *   description: Masters management
19   */
20  
21  /**
22   * @swagger
23   * /masters:
24   *   get:
25   *     summary: Retrieve a list of masters
26   *     tags: [Masters]
27   *     responses:
28   *       200:
29   *         description: A list of masters
30   *         content:
31   *           application/json:
32   *             schema:
33   *               type: array
34   *               items:
35   *                 $ref: '#/components/schemas/Master'
36   */
37  export default function (app: Application): void {
38  	const Model = createModel(app);
39  	const paginate = app.get("paginate");
40  
41  	const options = {
42  		Model,
43  		paginate,
44  	};
45  
46  	// Initialize our service with any options it requires
47  	app.use("masters", new Masters(options, app));
48  
49  	// Get our initialized service so that we can register hooks
50  	const service = app.service("masters");
51  
52  	service.hooks(hooks);
53  	logger.info("Masters service is hooked");
54  }