@kapeta/local-cluster-service 0.8.2 → 0.8.3

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.8.3](https://github.com/kapetacom/local-cluster-service/compare/v0.8.2...v0.8.3) (2023-07-23)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Format ([736158b](https://github.com/kapetacom/local-cluster-service/commit/736158b8685aa2ac1193cdabbbb34d81f6d2e302))
7
+
1
8
  ## [0.8.2](https://github.com/kapetacom/local-cluster-service/compare/v0.8.1...v0.8.2) (2023-07-23)
2
9
 
3
10
 
package/definitions.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  declare module 'recursive-watch' {
2
- export default function watch(path:string, callback:(filename:string) => void):() => void;
2
+ export default function watch(path: string, callback: (filename: string) => void): () => void;
3
3
  }
4
4
 
5
5
  declare module '@kapeta/nodejs-registry-utils' {
package/dist/cjs/index.js CHANGED
@@ -38,19 +38,19 @@ function createServer() {
38
38
  res.send({
39
39
  ok: true,
40
40
  dockerStatus: await containerManager_1.containerManager.checkAlive(),
41
- socketStatus: socketManager_1.socketManager.isAlive()
41
+ socketStatus: socketManager_1.socketManager.isAlive(),
42
42
  });
43
43
  });
44
44
  app.get('/ping', async (req, res) => {
45
45
  res.send({
46
- ok: true
46
+ ok: true,
47
47
  });
48
48
  });
49
49
  app.use('/', (req, res) => {
50
50
  console.error('Invalid request: %s %s', req.method, req.originalUrl);
51
51
  res.status(400).send({
52
52
  ok: false,
53
- error: 'Unknown'
53
+ error: 'Unknown',
54
54
  });
55
55
  });
56
56
  const server = http_1.default.createServer(app);
@@ -20,21 +20,21 @@ router.put('/:handle/:name', async (req, res) => {
20
20
  if (!req.headers['content-type']) {
21
21
  res.status(400).send({
22
22
  status: 400,
23
- error: 'Missing content-type header'
23
+ error: 'Missing content-type header',
24
24
  });
25
25
  return;
26
26
  }
27
27
  if (!req.headers['content-length']) {
28
28
  res.status(400).send({
29
29
  status: 400,
30
- error: 'Missing content-length header'
30
+ error: 'Missing content-length header',
31
31
  });
32
32
  return;
33
33
  }
34
34
  if (!req.headers['content-disposition']) {
35
35
  res.status(400).send({
36
36
  status: 400,
37
- error: 'Missing content-disposition header'
37
+ error: 'Missing content-disposition header',
38
38
  });
39
39
  return;
40
40
  }
@@ -50,7 +50,7 @@ router.put('/:handle/:name', async (req, res) => {
50
50
  'content-length': req.headers['content-length'],
51
51
  'content-disposition': req.headers['content-disposition'],
52
52
  },
53
- body: req
53
+ body: req,
54
54
  });
55
55
  res.send(result);
56
56
  }
@@ -317,9 +317,7 @@ class BlockInstanceRunner {
317
317
  ...Object.entries(env).map(([key, value]) => `${key}=${value}`),
318
318
  ],
319
319
  HostConfig: {
320
- Binds: [
321
- `${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${innerHome}`,
322
- ],
320
+ Binds: [`${(0, containerManager_1.toLocalBindVolume)(local_cluster_config_1.default.getKapetaBasedir())}:${innerHome}`],
323
321
  },
324
322
  });
325
323
  try {
@@ -29,7 +29,7 @@ function isLinux() {
29
29
  }
30
30
  exports.isLinux = isLinux;
31
31
  function getBindHost(preferredHost = '127.0.0.1') {
32
- // On Linux we need to bind to 0.0.0.0 to be able to connect to it from docker containers.
32
+ // On Linux we need to bind to 0.0.0.0 to be able to connect to it from docker containers.
33
33
  // TODO: This might pose a security risk - so we should authenticate all requests using a shared secret/nonce that we pass around.
34
34
  return isLinux() ? '0.0.0.0' : preferredHost;
35
35
  }
package/dist/esm/index.js CHANGED
@@ -16,7 +16,7 @@ import AssetsRoutes from './src/assets/routes';
16
16
  import ProviderRoutes from './src/providers/routes';
17
17
  import AttachmentRoutes from './src/attachments/routes';
18
18
  import { getBindHost } from './src/utils/utils';
19
- import request from "request";
19
+ import request from 'request';
20
20
  let currentServer = null;
21
21
  function createServer() {
22
22
  const app = express();
@@ -33,19 +33,19 @@ function createServer() {
33
33
  res.send({
34
34
  ok: true,
35
35
  dockerStatus: await containerManager.checkAlive(),
36
- socketStatus: socketManager.isAlive()
36
+ socketStatus: socketManager.isAlive(),
37
37
  });
38
38
  });
39
39
  app.get('/ping', async (req, res) => {
40
40
  res.send({
41
- ok: true
41
+ ok: true,
42
42
  });
43
43
  });
44
44
  app.use('/', (req, res) => {
45
45
  console.error('Invalid request: %s %s', req.method, req.originalUrl);
46
46
  res.status(400).send({
47
47
  ok: false,
48
- error: 'Unknown'
48
+ error: 'Unknown',
49
49
  });
50
50
  });
51
51
  const server = HTTP.createServer(app);
@@ -1,7 +1,7 @@
1
1
  import Router from 'express-promise-router';
2
2
  import { KapetaAPI } from '@kapeta/nodejs-api-client';
3
3
  import { corsHandler } from '../middleware/cors';
4
- import { storageService } from "../storageService";
4
+ import { storageService } from '../storageService';
5
5
  const router = Router();
6
6
  const api = new KapetaAPI();
7
7
  const DEFAULT_REGISTRY_BASE = 'https://registry.kapeta.com';
@@ -15,21 +15,21 @@ router.put('/:handle/:name', async (req, res) => {
15
15
  if (!req.headers['content-type']) {
16
16
  res.status(400).send({
17
17
  status: 400,
18
- error: 'Missing content-type header'
18
+ error: 'Missing content-type header',
19
19
  });
20
20
  return;
21
21
  }
22
22
  if (!req.headers['content-length']) {
23
23
  res.status(400).send({
24
24
  status: 400,
25
- error: 'Missing content-length header'
25
+ error: 'Missing content-length header',
26
26
  });
27
27
  return;
28
28
  }
29
29
  if (!req.headers['content-disposition']) {
30
30
  res.status(400).send({
31
31
  status: 400,
32
- error: 'Missing content-disposition header'
32
+ error: 'Missing content-disposition header',
33
33
  });
34
34
  return;
35
35
  }
@@ -45,7 +45,7 @@ router.put('/:handle/:name', async (req, res) => {
45
45
  'content-length': req.headers['content-length'],
46
46
  'content-disposition': req.headers['content-disposition'],
47
47
  },
48
- body: req
48
+ body: req,
49
49
  });
50
50
  res.send(result);
51
51
  }
@@ -311,9 +311,7 @@ export class BlockInstanceRunner {
311
311
  ...Object.entries(env).map(([key, value]) => `${key}=${value}`),
312
312
  ],
313
313
  HostConfig: {
314
- Binds: [
315
- `${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${innerHome}`,
316
- ],
314
+ Binds: [`${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${innerHome}`],
317
315
  },
318
316
  });
319
317
  try {
@@ -19,7 +19,7 @@ export function isLinux() {
19
19
  return !isWindows() && !isMac();
20
20
  }
21
21
  export function getBindHost(preferredHost = '127.0.0.1') {
22
- // On Linux we need to bind to 0.0.0.0 to be able to connect to it from docker containers.
22
+ // On Linux we need to bind to 0.0.0.0 to be able to connect to it from docker containers.
23
23
  // TODO: This might pose a security risk - so we should authenticate all requests using a shared secret/nonce that we pass around.
24
24
  return isLinux() ? '0.0.0.0' : preferredHost;
25
25
  }
package/index.ts CHANGED
@@ -17,7 +17,7 @@ import AssetsRoutes from './src/assets/routes';
17
17
  import ProviderRoutes from './src/providers/routes';
18
18
  import AttachmentRoutes from './src/attachments/routes';
19
19
  import { getBindHost } from './src/utils/utils';
20
- import request from "request";
20
+ import request from 'request';
21
21
 
22
22
  export type LocalClusterService = HTTP.Server & { host?: string; port?: number };
23
23
 
@@ -40,13 +40,13 @@ function createServer() {
40
40
  res.send({
41
41
  ok: true,
42
42
  dockerStatus: await containerManager.checkAlive(),
43
- socketStatus: socketManager.isAlive()
43
+ socketStatus: socketManager.isAlive(),
44
44
  });
45
45
  });
46
46
 
47
47
  app.get('/ping', async (req, res) => {
48
48
  res.send({
49
- ok: true
49
+ ok: true,
50
50
  });
51
51
  });
52
52
 
@@ -54,7 +54,7 @@ function createServer() {
54
54
  console.error('Invalid request: %s %s', req.method, req.originalUrl);
55
55
  res.status(400).send({
56
56
  ok: false,
57
- error: 'Unknown'
57
+ error: 'Unknown',
58
58
  });
59
59
  });
60
60
 
@@ -84,7 +84,7 @@ export default {
84
84
  return currentServer.port;
85
85
  },
86
86
 
87
- ping: async function(host:string, port:number): Promise<{ ok:boolean }> {
87
+ ping: async function (host: string, port: number): Promise<{ ok: boolean }> {
88
88
  return new Promise((resolve, reject) => {
89
89
  request.get(`http://${host}:${port}/ping`, (err, res, body) => {
90
90
  if (err) {
@@ -93,8 +93,8 @@ export default {
93
93
  }
94
94
 
95
95
  resolve(JSON.parse(body));
96
- })
97
- })
96
+ });
97
+ });
98
98
  },
99
99
 
100
100
  /**
@@ -166,7 +166,9 @@ export default {
166
166
 
167
167
  const bindHost = getBindHost(host);
168
168
 
169
- currentServer.listen(port, bindHost, () => resolve({ host, port, dockerStatus: containerManager.isAlive() }));
169
+ currentServer.listen(port, bindHost, () =>
170
+ resolve({ host, port, dockerStatus: containerManager.isAlive() })
171
+ );
170
172
  currentServer.host = host;
171
173
  currentServer.port = port;
172
174
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapeta/local-cluster-service",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -3,7 +3,7 @@ import { KapetaAPI } from '@kapeta/nodejs-api-client';
3
3
 
4
4
  import { corsHandler } from '../middleware/cors';
5
5
  import { Request, Response } from 'express';
6
- import {storageService} from "../storageService";
6
+ import { storageService } from '../storageService';
7
7
 
8
8
  const router = Router();
9
9
  const api = new KapetaAPI();
@@ -22,7 +22,7 @@ router.put('/:handle/:name', async (req: Request, res: Response) => {
22
22
  if (!req.headers['content-type']) {
23
23
  res.status(400).send({
24
24
  status: 400,
25
- error: 'Missing content-type header'
25
+ error: 'Missing content-type header',
26
26
  });
27
27
  return;
28
28
  }
@@ -30,7 +30,7 @@ router.put('/:handle/:name', async (req: Request, res: Response) => {
30
30
  if (!req.headers['content-length']) {
31
31
  res.status(400).send({
32
32
  status: 400,
33
- error: 'Missing content-length header'
33
+ error: 'Missing content-length header',
34
34
  });
35
35
  return;
36
36
  }
@@ -38,15 +38,15 @@ router.put('/:handle/:name', async (req: Request, res: Response) => {
38
38
  if (!req.headers['content-disposition']) {
39
39
  res.status(400).send({
40
40
  status: 400,
41
- error: 'Missing content-disposition header'
41
+ error: 'Missing content-disposition header',
42
42
  });
43
43
  return;
44
44
  }
45
45
 
46
46
  try {
47
- const {handle, name} = req.params;
47
+ const { handle, name } = req.params;
48
48
  const url = `${endpoint}/${handle}/${name}/attachments`;
49
- const result = await api.send<{url:string}>({
49
+ const result = await api.send<{ url: string }>({
50
50
  method: 'PUT',
51
51
  url,
52
52
  auth: true,
@@ -55,10 +55,10 @@ router.put('/:handle/:name', async (req: Request, res: Response) => {
55
55
  'content-length': req.headers['content-length'],
56
56
  'content-disposition': req.headers['content-disposition'],
57
57
  },
58
- body: req
58
+ body: req,
59
59
  });
60
60
  res.send(result);
61
- } catch (e:any) {
61
+ } catch (e: any) {
62
62
  res.status(e.status ?? 500).send(e);
63
63
  }
64
64
  });
@@ -116,7 +116,7 @@ class ContainerManager {
116
116
  }
117
117
 
118
118
  try {
119
- await this._docker.ping()
119
+ await this._docker.ping();
120
120
  this._alive = true;
121
121
  } catch (e) {
122
122
  this._alive = false;
@@ -12,16 +12,15 @@ router.use('/', corsHandler);
12
12
  router.get('/current', async (req: Request, res: Response) => {
13
13
  try {
14
14
  res.send(await api.getCurrentIdentity());
15
- } catch (e:any) {
15
+ } catch (e: any) {
16
16
  res.status(e.status ?? 500).send(e);
17
17
  }
18
-
19
18
  });
20
19
 
21
20
  router.get('/:identityId/memberships', async (req: Request, res: Response) => {
22
21
  try {
23
22
  res.send(await api.getMemberships(req.params.identityId));
24
- } catch (e:any) {
23
+ } catch (e: any) {
25
24
  res.status(e.status ?? 500).send(e);
26
25
  }
27
26
  });
@@ -41,23 +41,23 @@ class RepositoryManager {
41
41
 
42
42
  console.log('Watching local repository for provider changes: %s', baseDir);
43
43
  try {
44
- this.watcher = watch(baseDir, (filename:string) => {
44
+ this.watcher = watch(baseDir, (filename: string) => {
45
45
  if (!filename) {
46
46
  return;
47
47
  }
48
-
48
+
49
49
  const [handle, name, version] = filename.toString().split(/\//g);
50
50
  if (!name || !version) {
51
51
  return;
52
52
  }
53
-
53
+
54
54
  if (!this.changeEventsEnabled) {
55
55
  return;
56
56
  }
57
-
57
+
58
58
  const ymlPath = Path.join(baseDir, handle, name, version, 'kapeta.yml');
59
59
  const newDefinitions = ClusterConfiguration.getDefinitions();
60
-
60
+
61
61
  const newDefinition = newDefinitions.find((d) => d.ymlPath === ymlPath);
62
62
  let currentDefinition = allDefinitions.find((d) => d.ymlPath === ymlPath);
63
63
  const ymlExists = FS.existsSync(ymlPath);
@@ -85,13 +85,13 @@ class RepositoryManager {
85
85
  return;
86
86
  }
87
87
  }
88
-
88
+
89
89
  const payload = {
90
90
  type,
91
91
  definition: currentDefinition?.definition,
92
92
  asset: { handle, name, version },
93
93
  };
94
-
94
+
95
95
  allDefinitions = newDefinitions;
96
96
  socketManager.emit(`assets`, 'changed', payload);
97
97
  });
@@ -53,7 +53,7 @@ class StorageService {
53
53
  this._writeConfig();
54
54
  }
55
55
 
56
- get<T = any>(section: string, property?: string, defaultValue?:T): T|undefined {
56
+ get<T = any>(section: string, property?: string, defaultValue?: T): T | undefined {
57
57
  if (!property) {
58
58
  return this.section(section);
59
59
  }
@@ -216,7 +216,7 @@ export class BlockInstanceRunner {
216
216
 
217
217
  PortBindings[dockerPort] = [
218
218
  {
219
- HostIp: bindHost,
219
+ HostIp: bindHost,
220
220
  HostPort: `${publicPort}`,
221
221
  },
222
222
  ];
@@ -380,9 +380,7 @@ export class BlockInstanceRunner {
380
380
  ...Object.entries(env).map(([key, value]) => `${key}=${value}`),
381
381
  ],
382
382
  HostConfig: {
383
- Binds: [
384
- `${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${innerHome}`,
385
- ],
383
+ Binds: [`${toLocalBindVolume(ClusterConfig.getKapetaBasedir())}:${innerHome}`],
386
384
  },
387
385
  });
388
386
 
@@ -24,7 +24,7 @@ export function isLinux() {
24
24
  }
25
25
 
26
26
  export function getBindHost(preferredHost = '127.0.0.1') {
27
- // On Linux we need to bind to 0.0.0.0 to be able to connect to it from docker containers.
27
+ // On Linux we need to bind to 0.0.0.0 to be able to connect to it from docker containers.
28
28
  // TODO: This might pose a security risk - so we should authenticate all requests using a shared secret/nonce that we pass around.
29
29
  return isLinux() ? '0.0.0.0' : preferredHost;
30
- }
30
+ }