Browse Source

Add service plugin

pull/1222/head
Hironsan 3 years ago
parent
commit
1376609f0c
2 changed files with 26 additions and 1 deletions
  1. 3
      frontend/nuxt.config.js
  2. 24
      frontend/plugins/services.ts

3
frontend/nuxt.config.js

@ -50,7 +50,8 @@ export default {
plugins: [
'~/plugins/filters.js',
'~/plugins/vue-youtube.js',
'~/plugins/vue-shortkey.js'
'~/plugins/vue-shortkey.js',
'~/plugins/services.ts'
],
/*
** Nuxt.js modules

24
frontend/plugins/services.ts

@ -0,0 +1,24 @@
import { Plugin } from '@nuxt/types'
import { FromApiLabelItemListRepository } from '@/repositories/label/api'
import { LabelApplicationService } from '@/services/application/label.service'
export interface Services {
label: LabelApplicationService
}
declare module 'vue/types/vue' {
interface Vue {
readonly $services: Services
}
}
const plugin: Plugin = (context, inject) => {
const labelRepository = new FromApiLabelItemListRepository()
const label = new LabelApplicationService(labelRepository)
const services: Services = {
label
}
inject('services', services)
}
export default plugin
Loading…
Cancel
Save