From 283193edb13d4c453cae46be341852615d074a30 Mon Sep 17 00:00:00 2001
From: Pranciskus Ambrazas
Date: Thu, 30 Nov 2023 15:08:53 +0200
Subject: [PATCH] public fishTypes
---
services/fishTypes.service.ts | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/services/fishTypes.service.ts b/services/fishTypes.service.ts
index a0c5ddc..6062590 100644
--- a/services/fishTypes.service.ts
+++ b/services/fishTypes.service.ts
@@ -1,7 +1,7 @@
'use strict';
-import moleculer from 'moleculer';
-import { Method, Service } from 'moleculer-decorators';
+import moleculer, { Context, RestSchema } from 'moleculer';
+import { Action, Method, Service } from 'moleculer-decorators';
import DbConnection from '../mixins/database.mixin';
import {
@@ -64,6 +64,21 @@ export type FishType<
},
})
export default class FishTypesService extends moleculer.Service {
+ @Action({
+ rest: {
+ method: 'GET',
+ basePath: '/public/fishTypes',
+ path: '/',
+ },
+ auth: RestrictionType.PUBLIC,
+ })
+ getPublicItems(ctx: Context) {
+ return this.findEntities(ctx, {
+ fields: ['id', 'label'],
+ sort: 'label',
+ });
+ }
+
@Method
async seedDB() {
await this.createEntities(null, [