From e5e254bb6e4c8ad1b62f736066809c30434db75f Mon Sep 17 00:00:00 2001 From: Ray Foss Date: Fri, 19 May 2023 11:50:45 -0500 Subject: [PATCH 1/6] fix: default custom-env-config settings caused name conflicts --- .../templates/{configuration.tpl.ts => configuration.tpl.tsS} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename packages/generators/src/app/templates/{configuration.tpl.ts => configuration.tpl.tsS} (97%) diff --git a/packages/generators/src/app/templates/configuration.tpl.ts b/packages/generators/src/app/templates/configuration.tpl.tsS similarity index 97% rename from packages/generators/src/app/templates/configuration.tpl.ts rename to packages/generators/src/app/templates/configuration.tpl.tsS index cc2d61810e..eaa4f27998 100644 --- a/packages/generators/src/app/templates/configuration.tpl.ts +++ b/packages/generators/src/app/templates/configuration.tpl.tsS @@ -15,10 +15,10 @@ const defaultConfig = ({}: AppGeneratorContext) => ({ const customEnvironment = { port: { - __name: 'PORT', + __name: 'FEATHERS_PORT', __format: 'number' }, - host: 'HOSTNAME', + host: 'FEATHERS_HOSTNAME', authentication: { secret: 'FEATHERS_SECRET' } From 31fe6cc054ade9410d8dbed1ac866bcdf5a4ec9e Mon Sep 17 00:00:00 2001 From: Ray Foss Date: Mon, 5 Jun 2023 14:24:42 -0500 Subject: [PATCH 2/6] Add origins configuration --- .../generators/src/app/templates/configuration.tpl.tsS | 7 ++++++- packages/generators/src/app/templates/index.tpl.ts | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/generators/src/app/templates/configuration.tpl.tsS b/packages/generators/src/app/templates/configuration.tpl.tsS index eaa4f27998..e92cf6aaf1 100644 --- a/packages/generators/src/app/templates/configuration.tpl.tsS +++ b/packages/generators/src/app/templates/configuration.tpl.tsS @@ -19,6 +19,10 @@ const customEnvironment = { __format: 'number' }, host: 'FEATHERS_HOSTNAME', + origins: { + __name: 'FEATHERS_ORIGINS', + __format: 'json' + }, authentication: { secret: 'FEATHERS_SECRET' } @@ -43,7 +47,8 @@ export const configurationSchema = { ...defaultAppSettings, host: { type: 'string' }, port: { type: 'number' }, - public: { type: 'string' } + public: { type: 'string' }, + origins: Type.Array(Type.String()) } } as const diff --git a/packages/generators/src/app/templates/index.tpl.ts b/packages/generators/src/app/templates/index.tpl.ts index 986bbf68a4..0a999d81f3 100644 --- a/packages/generators/src/app/templates/index.tpl.ts +++ b/packages/generators/src/app/templates/index.tpl.ts @@ -6,14 +6,14 @@ const template = ({}: AppGeneratorContext) => /* ts */ `import { app } from './a import { logger } from './logger' const port = app.get('port') -const host = app.get('host') +const origin = app.get('origins')[0] process.on('unhandledRejection', (reason) => logger.error('Unhandled Rejection %O', reason) ) app.listen(port).then(() => { - logger.info(\`Feathers app listening on http://\${host}:\${port}\`) + logger.info(\`Feathers app listening on \${origin}\`) }) ` From 4ab6a6a7c2dfc59ef9729cfd927c3bf071ccc787 Mon Sep 17 00:00:00 2001 From: Ray Foss Date: Mon, 5 Jun 2023 23:13:27 -0500 Subject: [PATCH 3/6] Update client.test.tpl.ts --- packages/generators/src/app/templates/client.test.tpl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/generators/src/app/templates/client.test.tpl.ts b/packages/generators/src/app/templates/client.test.tpl.ts index aae82ae08e..19e06a8035 100644 --- a/packages/generators/src/app/templates/client.test.tpl.ts +++ b/packages/generators/src/app/templates/client.test.tpl.ts @@ -11,7 +11,7 @@ import { createClient } from '../${lib}/client' import rest from '@feathersjs/rest-client' const port = app.get('port') -const appUrl = \`http://\${app.get('host')}:\${port}\` +const appUrl = \`http://localhost:\${port}\` describe('client tests', () => { const client = createClient(rest(appUrl).axios(axios)) From 08c5526bd7364678ba4854779a2fdd910583e137 Mon Sep 17 00:00:00 2001 From: Ray Foss Date: Mon, 5 Jun 2023 23:13:46 -0500 Subject: [PATCH 4/6] Update app.test.tpl.ts --- packages/generators/src/app/templates/app.test.tpl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/generators/src/app/templates/app.test.tpl.ts b/packages/generators/src/app/templates/app.test.tpl.ts index e798bcab08..e3f54e2903 100644 --- a/packages/generators/src/app/templates/app.test.tpl.ts +++ b/packages/generators/src/app/templates/app.test.tpl.ts @@ -11,7 +11,7 @@ import type { Server } from 'http' import { app } from '../${lib}/app' const port = app.get('port') -const appUrl = \`http://\${app.get('host')}:\${port}\` +const appUrl = \`http://localhost:\${port}\` describe('Feathers application tests', () => { let server: Server From 165d0ad126a7d1c09f4075f45c15f81f3d9df61e Mon Sep 17 00:00:00 2001 From: Ray Foss Date: Mon, 5 Jun 2023 23:14:51 -0500 Subject: [PATCH 5/6] Update configuration.tpl.tsS --- packages/generators/src/app/templates/configuration.tpl.tsS | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/generators/src/app/templates/configuration.tpl.tsS b/packages/generators/src/app/templates/configuration.tpl.tsS index e92cf6aaf1..19808dd8ef 100644 --- a/packages/generators/src/app/templates/configuration.tpl.tsS +++ b/packages/generators/src/app/templates/configuration.tpl.tsS @@ -45,7 +45,6 @@ export const configurationSchema = { required: [ 'host', 'port', 'public' ], properties: { ...defaultAppSettings, - host: { type: 'string' }, port: { type: 'number' }, public: { type: 'string' }, origins: Type.Array(Type.String()) From c41013af3585eec6dc27da771a49b50b54e8426a Mon Sep 17 00:00:00 2001 From: Ray Foss Date: Mon, 5 Jun 2023 23:55:13 -0500 Subject: [PATCH 6/6] Update configuration.tpl.tsS --- packages/generators/src/app/templates/configuration.tpl.tsS | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/generators/src/app/templates/configuration.tpl.tsS b/packages/generators/src/app/templates/configuration.tpl.tsS index 19808dd8ef..38a72895c7 100644 --- a/packages/generators/src/app/templates/configuration.tpl.tsS +++ b/packages/generators/src/app/templates/configuration.tpl.tsS @@ -47,7 +47,7 @@ export const configurationSchema = { ...defaultAppSettings, port: { type: 'number' }, public: { type: 'string' }, - origins: Type.Array(Type.String()) + origins: { type: 'array', items: { type: 'string' } } } } as const @@ -65,9 +65,9 @@ import { dataValidator } from './validators' export const configurationSchema = Type.Intersect([ defaultAppConfiguration, Type.Object({ - host: Type.String(), port: Type.Number(), - public: Type.String() + public: Type.String(), + origins: Type.Array(Type.String()) }) ])