@appsemble/node-utils 0.25.1 → 0.26.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.
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.25.1/config/assets/logo.svg) Appsemble Node Utilities
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.26.0/config/assets/logo.svg) Appsemble Node Utilities
2
2
 
3
3
  > NodeJS utilities used by Appsemble internally.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@appsemble/node-utils)](https://www.npmjs.com/package/@appsemble/node-utils)
6
- [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.25.1/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.25.1)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.26.0/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.26.0)
7
7
  [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)
8
8
 
9
9
  ## Table of Contents
@@ -26,5 +26,5 @@ compatibility is not guaranteed.
26
26
 
27
27
  ## License
28
28
 
29
- [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.25.1/LICENSE.md) ©
29
+ [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.26.0/LICENSE.md) ©
30
30
  [Appsemble](https://appsemble.com)
@@ -26,11 +26,12 @@ export async function frontend(webpackConfigs, argv, serveStudio = false) {
26
26
  return next();
27
27
  },
28
28
  (ctx, next) => {
29
- const { hostname } = ctx;
29
+ const { app, hostname } = ctx;
30
30
  if (!skipRoute.test(ctx.path)) {
31
31
  return koaDevMiddleware(ctx, next);
32
32
  }
33
- if (new URL(argv.host).hostname === hostname || isIP(hostname)) {
33
+ if ((new URL(argv.host).hostname === hostname && app.env !== 'development') ||
34
+ isIP(hostname)) {
34
35
  return next();
35
36
  }
36
37
  return koaDevMiddleware(ctx, next);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/node-utils",
3
- "version": "0.25.1",
3
+ "version": "0.26.0",
4
4
  "description": "NodeJS utilities used by Appsemble internally.",
5
5
  "keywords": [
6
6
  "app",
@@ -38,8 +38,8 @@
38
38
  "test": "vitest"
39
39
  },
40
40
  "dependencies": {
41
- "@appsemble/types": "0.25.1",
42
- "@appsemble/utils": "0.25.1",
41
+ "@appsemble/types": "0.26.0",
42
+ "@appsemble/utils": "0.26.0",
43
43
  "@formatjs/fast-memoize": "^2.0.0",
44
44
  "@fortawesome/fontawesome-free": "^6.0.0",
45
45
  "@koa/cors": "^4.0.0",
@@ -25,7 +25,7 @@ export function createAppRouter(options) {
25
25
  },
26
26
  {
27
27
  route: '/robots.txt',
28
- get: createRobotsHandler(),
28
+ get: createRobotsHandler(options),
29
29
  },
30
30
  {
31
31
  route: '/service-worker.js',
@@ -52,6 +52,7 @@ export function createIndexHandler({ createSettings, getApp, getAppDetails, getA
52
52
  const updated = app.$updated ? new Date(app.$updated) : new Date();
53
53
  return render(ctx, 'app/index.html', {
54
54
  app,
55
+ noIndex: app.visibility !== 'public',
55
56
  appUrl: String(appUrl),
56
57
  host,
57
58
  locale: defaultLanguage,
@@ -1,2 +1,3 @@
1
+ import { type Options } from '@appsemble/node-utils';
1
2
  import { type Middleware } from 'koa';
2
- export declare function createRobotsHandler(): Middleware;
3
+ export declare function createRobotsHandler({ getApp }: Options): Middleware;
@@ -1,6 +1,20 @@
1
- export function createRobotsHandler() {
2
- return (ctx) => {
3
- ctx.body = 'User-agent: *\nAllow: *\n';
1
+ import { logger } from '@appsemble/node-utils';
2
+ export function createRobotsHandler({ getApp }) {
3
+ return async (ctx) => {
4
+ const app = await getApp({ context: ctx });
5
+ switch (app.visibility) {
6
+ case 'public':
7
+ ctx.body = 'User-agent: *\nAllow: *\n';
8
+ break;
9
+ case 'unlisted':
10
+ case 'private':
11
+ ctx.body = 'User-agent: *\nDisallow: /\n';
12
+ break;
13
+ default:
14
+ logger.error('Unknown visibility', { visibility: app.visibility });
15
+ ctx.status = 500;
16
+ break;
17
+ }
4
18
  };
5
19
  }
6
20
  //# sourceMappingURL=robotsHandler.js.map
package/server/types.d.ts CHANGED
@@ -96,6 +96,7 @@ declare module 'koas-parameters' {
96
96
  startIndex: number;
97
97
  view: string;
98
98
  resources: boolean;
99
+ assets: boolean;
99
100
  roles: string[];
100
101
  }
101
102
  }