@flowerforce/flowerbase 1.6.2 → 1.6.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +49 -87
  2. package/dist/auth/controller.d.ts.map +1 -1
  3. package/dist/auth/controller.js +15 -3
  4. package/dist/auth/providers/anon-user/controller.d.ts.map +1 -1
  5. package/dist/auth/providers/anon-user/controller.js +5 -1
  6. package/dist/auth/providers/custom-function/schema.d.ts +1 -0
  7. package/dist/auth/providers/custom-function/schema.d.ts.map +1 -1
  8. package/dist/auth/providers/custom-function/schema.js +1 -0
  9. package/dist/auth/utils.d.ts +7 -0
  10. package/dist/auth/utils.d.ts.map +1 -1
  11. package/dist/auth/utils.js +6 -0
  12. package/dist/constants.d.ts +12 -0
  13. package/dist/constants.d.ts.map +1 -1
  14. package/dist/constants.js +26 -5
  15. package/dist/features/endpoints/utils.d.ts.map +1 -1
  16. package/dist/features/endpoints/utils.js +18 -0
  17. package/dist/features/functions/controller.d.ts.map +1 -1
  18. package/dist/features/functions/controller.js +10 -2
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +11 -1
  21. package/dist/monitoring/plugin.d.ts +7 -0
  22. package/dist/monitoring/plugin.d.ts.map +1 -0
  23. package/dist/monitoring/plugin.js +1347 -0
  24. package/dist/utils/initializer/exposeRoutes.d.ts.map +1 -1
  25. package/dist/utils/initializer/exposeRoutes.js +10 -2
  26. package/dist/utils/initializer/registerPlugins.d.ts.map +1 -1
  27. package/dist/utils/initializer/registerPlugins.js +10 -1
  28. package/package.json +5 -3
  29. package/src/auth/controller.ts +15 -1
  30. package/src/auth/providers/anon-user/controller.ts +5 -0
  31. package/src/auth/providers/custom-function/schema.ts +23 -24
  32. package/src/auth/utils.ts +6 -0
  33. package/src/constants.ts +22 -0
  34. package/src/features/endpoints/utils.ts +18 -0
  35. package/src/features/functions/controller.ts +10 -2
  36. package/src/index.ts +10 -1
  37. package/src/monitoring/plugin.ts +1528 -0
  38. package/src/monitoring/ui.css +983 -0
  39. package/src/monitoring/ui.html +289 -0
  40. package/src/monitoring/ui.js +1826 -0
  41. package/src/utils/initializer/exposeRoutes.ts +10 -2
  42. package/src/utils/initializer/registerPlugins.ts +13 -2
@@ -13,7 +13,11 @@ import { hashPassword } from '../crypto'
13
13
  */
14
14
  export const exposeRoutes = async (fastify: FastifyInstance) => {
15
15
  try {
16
- fastify.get(`${API_VERSION}/app/:appId/location`, async (req) => {
16
+ fastify.get(`${API_VERSION}/app/:appId/location`, {
17
+ schema: {
18
+ tags: ['System']
19
+ }
20
+ }, async (req) => {
17
21
  const schema = DEFAULT_CONFIG?.HTTPS_SCHEMA ?? 'http'
18
22
  const headerHost = req.headers.host ?? 'localhost:3000'
19
23
  const hostname = headerHost.split(':')[0]
@@ -29,7 +33,11 @@ export const exposeRoutes = async (fastify: FastifyInstance) => {
29
33
  }
30
34
  })
31
35
 
32
- fastify.get('/health', async () => ({
36
+ fastify.get('/health', {
37
+ schema: {
38
+ tags: ['System']
39
+ }
40
+ }, async () => ({
33
41
  status: 'ok',
34
42
  uptime: uptime()
35
43
  }))
@@ -8,8 +8,9 @@ import jwtAuthPlugin from '../../auth/plugins/jwt'
8
8
  import { anonUserController } from '../../auth/providers/anon-user/controller'
9
9
  import { customFunctionController } from '../../auth/providers/custom-function/controller'
10
10
  import { localUserPassController } from '../../auth/providers/local-userpass/controller'
11
- import { API_VERSION } from '../../constants'
11
+ import { API_VERSION, DEFAULT_CONFIG } from '../../constants'
12
12
  import { Functions } from '../../features/functions/interface'
13
+ import monitoringPlugin from '../../monitoring/plugin'
13
14
 
14
15
  type RegisterFunction = FastifyInstance['register']
15
16
  type RegisterParameters = Parameters<RegisterFunction>
@@ -83,7 +84,7 @@ const getRegisterConfig = async ({
83
84
  methods: ['POST', 'GET']
84
85
  }
85
86
 
86
- return [
87
+ const baseConfig = [
87
88
  {
88
89
  pluginName: 'cors',
89
90
  plugin: cors,
@@ -143,4 +144,14 @@ const getRegisterConfig = async ({
143
144
  }
144
145
  }
145
146
  ] as RegisterConfig[]
147
+
148
+ if (DEFAULT_CONFIG.MONIT_ENABLED) {
149
+ baseConfig.splice(2, 0, {
150
+ pluginName: 'monitoringPlugin',
151
+ plugin: monitoringPlugin,
152
+ options: { basePath: '/monit' }
153
+ } as RegisterConfig)
154
+ }
155
+
156
+ return baseConfig
146
157
  }