@feathersjs/cli 5.0.0-pre.28 → 5.0.0-pre.30
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 +28 -28
- package/bin/feathers +3 -6
- package/lib/app/index.js +34 -11
- package/lib/app/index.js.map +1 -1
- package/lib/app/index.ts +81 -53
- package/lib/app/templates/app.test.tpl.js +1 -1
- package/lib/app/templates/app.test.tpl.js.map +1 -1
- package/lib/app/templates/app.test.tpl.ts +1 -2
- package/lib/app/templates/app.tpl.js +24 -12
- package/lib/app/templates/app.tpl.js.map +1 -1
- package/lib/app/templates/app.tpl.ts +28 -14
- package/lib/app/templates/channels.tpl.js +1 -1
- package/lib/app/templates/channels.tpl.js.map +1 -1
- package/lib/app/templates/channels.tpl.ts +1 -2
- package/lib/app/templates/client.tpl.js +3 -3
- package/lib/app/templates/client.tpl.js.map +1 -1
- package/lib/app/templates/client.tpl.ts +3 -4
- package/lib/app/templates/config.tpl.js +10 -1
- package/lib/app/templates/config.tpl.js.map +1 -1
- package/lib/app/templates/config.tpl.ts +10 -0
- package/lib/app/templates/declarations.tpl.js +3 -3
- package/lib/app/templates/declarations.tpl.js.map +1 -1
- package/lib/app/templates/declarations.tpl.ts +5 -4
- package/lib/app/templates/index.html.tpl.js +12 -52
- package/lib/app/templates/index.html.tpl.js.map +1 -1
- package/lib/app/templates/index.html.tpl.ts +12 -53
- package/lib/app/templates/index.tpl.js +1 -1
- package/lib/app/templates/index.tpl.js.map +1 -1
- package/lib/app/templates/index.tpl.ts +1 -2
- package/lib/app/templates/logger.tpl.js +1 -1
- package/lib/app/templates/logger.tpl.js.map +1 -1
- package/lib/app/templates/logger.tpl.ts +2 -2
- package/lib/app/templates/package.json.tpl.js +4 -3
- package/lib/app/templates/package.json.tpl.js.map +1 -1
- package/lib/app/templates/package.json.tpl.ts +5 -3
- package/lib/app/templates/readme.md.tpl.js +11 -7
- package/lib/app/templates/readme.md.tpl.js.map +1 -1
- package/lib/app/templates/readme.md.tpl.ts +15 -8
- package/lib/app/templates/{configuration.tpl.d.ts → schemas.tpl.d.ts} +0 -0
- package/lib/app/templates/schemas.tpl.js +76 -0
- package/lib/app/templates/schemas.tpl.js.map +1 -0
- package/lib/app/templates/schemas.tpl.ts +90 -0
- package/lib/app/templates/services.tpl.js +1 -1
- package/lib/app/templates/services.tpl.js.map +1 -1
- package/lib/app/templates/services.tpl.ts +1 -2
- package/lib/authentication/index.d.ts +4 -3
- package/lib/authentication/index.js +12 -3
- package/lib/authentication/index.js.map +1 -1
- package/lib/authentication/index.ts +23 -5
- package/lib/authentication/templates/authentication.tpl.js +4 -6
- package/lib/authentication/templates/authentication.tpl.js.map +1 -1
- package/lib/authentication/templates/authentication.tpl.ts +6 -9
- package/lib/authentication/templates/config.tpl.js +10 -6
- package/lib/authentication/templates/config.tpl.js.map +1 -1
- package/lib/authentication/templates/config.tpl.ts +40 -34
- package/lib/authentication/templates/declarations.tpl.js +3 -3
- package/lib/authentication/templates/declarations.tpl.js.map +1 -1
- package/lib/authentication/templates/declarations.tpl.ts +9 -4
- package/lib/authentication/templates/knex.tpl.js +5 -4
- package/lib/authentication/templates/knex.tpl.js.map +1 -1
- package/lib/authentication/templates/knex.tpl.ts +5 -4
- package/lib/authentication/templates/{user.resolver.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
- package/lib/authentication/templates/schema.json.tpl.js +92 -0
- package/lib/authentication/templates/schema.json.tpl.js.map +1 -0
- package/lib/authentication/templates/schema.json.tpl.ts +108 -0
- package/lib/authentication/templates/{user.schema.tpl.d.ts → schema.typebox.tpl.d.ts} +1 -0
- package/lib/authentication/templates/schema.typebox.tpl.js +79 -0
- package/lib/authentication/templates/schema.typebox.tpl.js.map +1 -0
- package/lib/authentication/templates/schema.typebox.tpl.ts +94 -0
- package/lib/authentication/templates/test.tpl.js +2 -2
- package/lib/authentication/templates/test.tpl.js.map +1 -1
- package/lib/authentication/templates/test.tpl.ts +6 -3
- package/lib/cli.d.ts +6 -0
- package/lib/cli.js +75 -0
- package/lib/cli.js.map +1 -0
- package/lib/cli.ts +68 -0
- package/lib/commons.d.ts +14 -1
- package/lib/commons.js +24 -4
- package/lib/commons.js.map +1 -1
- package/lib/commons.ts +29 -1
- package/lib/connection/index.d.ts +5 -3
- package/lib/connection/index.js +5 -3
- package/lib/connection/index.js.map +1 -1
- package/lib/connection/index.ts +19 -5
- package/lib/connection/templates/knex.tpl.js +2 -12
- package/lib/connection/templates/knex.tpl.js.map +1 -1
- package/lib/connection/templates/knex.tpl.ts +6 -20
- package/lib/connection/templates/mongodb.tpl.js +1 -3
- package/lib/connection/templates/mongodb.tpl.js.map +1 -1
- package/lib/connection/templates/mongodb.tpl.ts +1 -12
- package/lib/hook/index.d.ts +1 -1
- package/lib/hook/index.js +3 -0
- package/lib/hook/index.js.map +1 -1
- package/lib/hook/index.ts +3 -1
- package/lib/hook/templates/hook.tpl.js +2 -3
- package/lib/hook/templates/hook.tpl.js.map +1 -1
- package/lib/hook/templates/hook.tpl.ts +5 -3
- package/lib/index.d.ts +2 -16
- package/lib/index.js +16 -24
- package/lib/index.js.map +1 -1
- package/lib/index.ts +2 -28
- package/lib/service/index.d.ts +10 -2
- package/lib/service/index.js +79 -41
- package/lib/service/index.js.map +1 -1
- package/lib/service/index.ts +54 -6
- package/lib/service/templates/client.tpl.js +26 -6
- package/lib/service/templates/client.tpl.js.map +1 -1
- package/lib/service/templates/client.tpl.ts +41 -12
- package/lib/service/templates/{class.tpl.d.ts → schema.json.tpl.d.ts} +0 -0
- package/lib/service/templates/schema.json.tpl.js +73 -0
- package/lib/service/templates/schema.json.tpl.js.map +1 -0
- package/lib/service/templates/schema.json.tpl.ts +85 -0
- package/lib/service/templates/{resolver.tpl.d.ts → schema.typebox.tpl.d.ts} +0 -0
- package/lib/service/templates/schema.typebox.tpl.js +58 -0
- package/lib/service/templates/schema.typebox.tpl.js.map +1 -0
- package/lib/service/templates/schema.typebox.tpl.ts +70 -0
- package/lib/service/templates/service.tpl.d.ts +1 -0
- package/lib/service/templates/service.tpl.js +67 -15
- package/lib/service/templates/service.tpl.js.map +1 -1
- package/lib/service/templates/service.tpl.ts +98 -19
- package/lib/service/templates/test.tpl.js +1 -1
- package/lib/service/templates/test.tpl.js.map +1 -1
- package/lib/service/templates/test.tpl.ts +1 -2
- package/lib/service/type/custom.tpl.d.ts +1 -2
- package/lib/service/type/custom.tpl.js +32 -25
- package/lib/service/type/custom.tpl.js.map +1 -1
- package/lib/service/type/custom.tpl.ts +44 -35
- package/lib/service/type/knex.tpl.d.ts +1 -3
- package/lib/service/type/knex.tpl.js +33 -23
- package/lib/service/type/knex.tpl.js.map +1 -1
- package/lib/service/type/knex.tpl.ts +51 -29
- package/lib/service/type/mongodb.tpl.d.ts +1 -2
- package/lib/service/type/mongodb.tpl.js +30 -20
- package/lib/service/type/mongodb.tpl.js.map +1 -1
- package/lib/service/type/mongodb.tpl.ts +47 -29
- package/package.json +23 -24
- package/lib/app/templates/configuration.tpl.js +0 -39
- package/lib/app/templates/configuration.tpl.js.map +0 -1
- package/lib/app/templates/configuration.tpl.ts +0 -44
- package/lib/authentication/templates/user.resolver.tpl.js +0 -98
- package/lib/authentication/templates/user.resolver.tpl.js.map +0 -1
- package/lib/authentication/templates/user.resolver.tpl.ts +0 -111
- package/lib/authentication/templates/user.schema.tpl.js +0 -79
- package/lib/authentication/templates/user.schema.tpl.js.map +0 -1
- package/lib/authentication/templates/user.schema.tpl.ts +0 -87
- package/lib/service/templates/class.tpl.js +0 -63
- package/lib/service/templates/class.tpl.js.map +0 -1
- package/lib/service/templates/class.tpl.ts +0 -79
- package/lib/service/templates/resolver.tpl.js +0 -73
- package/lib/service/templates/resolver.tpl.js.map +0 -1
- package/lib/service/templates/resolver.tpl.ts +0 -78
- package/lib/service/templates/schema.tpl.d.ts +0 -2
- package/lib/service/templates/schema.tpl.js +0 -75
- package/lib/service/templates/schema.tpl.js.map +0 -1
- package/lib/service/templates/schema.tpl.ts +0 -80
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
-
const template = ({ name, description }) => `# ${name}
|
|
5
|
+
const template = ({ name, description, language, database }) => /* md */ `# ${name}
|
|
6
6
|
|
|
7
7
|
> ${description}
|
|
8
8
|
|
|
@@ -22,7 +22,13 @@ This project uses [Feathers](http://feathersjs.com). An open source framework fo
|
|
|
22
22
|
|
|
23
23
|
3. Start your app
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
\`\`\`${language === 'ts'
|
|
26
|
+
? `
|
|
27
|
+
npm run compile # Compile TypeScript source`
|
|
28
|
+
: ''}${database !== 'mongodb'
|
|
29
|
+
? `
|
|
30
|
+
npm run migrate # Run migrations to set up the database`
|
|
31
|
+
: ''}
|
|
26
32
|
npm start
|
|
27
33
|
\`\`\`
|
|
28
34
|
|
|
@@ -32,13 +38,11 @@ Run \`npm test\` and all your tests in the \`test/\` directory will be run.
|
|
|
32
38
|
|
|
33
39
|
## Scaffolding
|
|
34
40
|
|
|
35
|
-
|
|
41
|
+
This app comes with a powerful command line interface for Feathers. Here are a few things it can do:
|
|
36
42
|
|
|
37
43
|
\`\`\`
|
|
38
|
-
$
|
|
39
|
-
|
|
40
|
-
$ feathers generate service # Generate a new Service
|
|
41
|
-
$ feathers help # Show all commands
|
|
44
|
+
$ npx feathers help # Show all commands
|
|
45
|
+
$ npx feathers generate service # Generate a new Service
|
|
42
46
|
\`\`\`
|
|
43
47
|
|
|
44
48
|
## Help
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readme.md.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/readme.md.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsE;AAGtE,MAAM,QAAQ,GAAG,CAAC,EAAE,IAAI,EAAE,WAAW,EAAuB,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"readme.md.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/readme.md.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsE;AAGtE,MAAM,QAAQ,GAAG,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,IAAI;;IAEnG,WAAW;;;;;;;;;;;;iBAYE,IAAI;;;;;;YAOf,QAAQ,KAAK,IAAI;IACf,CAAC,CAAC;gDACsC;IACxC,CAAC,CAAC,EACN,GACF,QAAQ,KAAK,SAAS;IACpB,CAAC,CAAC;4DACsD;IACxD,CAAC,CAAC,EACN;;;;;;;;;;;;;;;;;;;;CAoBC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAA,uBAAc,EAAC,QAAQ,EAAE,IAAA,eAAM,EAAC,WAAW,CAAC,CAAC,CAAC,CAAA;AADvD,QAAA,QAAQ,YAC+C"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { generator, renderTemplate, toFile } from '@feathershq/pinion'
|
|
2
2
|
import { AppGeneratorContext } from '../index'
|
|
3
3
|
|
|
4
|
-
const template = ({ name, description }: AppGeneratorContext) =>
|
|
5
|
-
`# ${name}
|
|
4
|
+
const template = ({ name, description, language, database }: AppGeneratorContext) => /* md */ `# ${name}
|
|
6
5
|
|
|
7
6
|
> ${description}
|
|
8
7
|
|
|
@@ -22,7 +21,17 @@ This project uses [Feathers](http://feathersjs.com). An open source framework fo
|
|
|
22
21
|
|
|
23
22
|
3. Start your app
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
\`\`\`${
|
|
25
|
+
language === 'ts'
|
|
26
|
+
? `
|
|
27
|
+
npm run compile # Compile TypeScript source`
|
|
28
|
+
: ''
|
|
29
|
+
}${
|
|
30
|
+
database !== 'mongodb'
|
|
31
|
+
? `
|
|
32
|
+
npm run migrate # Run migrations to set up the database`
|
|
33
|
+
: ''
|
|
34
|
+
}
|
|
26
35
|
npm start
|
|
27
36
|
\`\`\`
|
|
28
37
|
|
|
@@ -32,13 +41,11 @@ Run \`npm test\` and all your tests in the \`test/\` directory will be run.
|
|
|
32
41
|
|
|
33
42
|
## Scaffolding
|
|
34
43
|
|
|
35
|
-
|
|
44
|
+
This app comes with a powerful command line interface for Feathers. Here are a few things it can do:
|
|
36
45
|
|
|
37
46
|
\`\`\`
|
|
38
|
-
$
|
|
39
|
-
|
|
40
|
-
$ feathers generate service # Generate a new Service
|
|
41
|
-
$ feathers help # Show all commands
|
|
47
|
+
$ npx feathers help # Show all commands
|
|
48
|
+
$ npx feathers generate service # Generate a new Service
|
|
42
49
|
\`\`\`
|
|
43
50
|
|
|
44
51
|
## Help
|
|
File without changes
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generate = void 0;
|
|
4
|
+
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
+
const commons_1 = require("../../commons");
|
|
6
|
+
const validatorTemplate = /* ts */ `import { Ajv, addFormats } from '@feathersjs/schema'
|
|
7
|
+
import type { FormatsPluginOptions } from '@feathersjs/schema'
|
|
8
|
+
|
|
9
|
+
const formats: FormatsPluginOptions = [
|
|
10
|
+
'date-time',
|
|
11
|
+
'time',
|
|
12
|
+
'date',
|
|
13
|
+
'email',
|
|
14
|
+
'hostname',
|
|
15
|
+
'ipv4',
|
|
16
|
+
'ipv6',
|
|
17
|
+
'uri',
|
|
18
|
+
'uri-reference',
|
|
19
|
+
'uuid',
|
|
20
|
+
'uri-template',
|
|
21
|
+
'json-pointer',
|
|
22
|
+
'relative-json-pointer',
|
|
23
|
+
'regex'
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
export const dataValidator = addFormats(new Ajv({}), formats)
|
|
27
|
+
|
|
28
|
+
export const queryValidator = addFormats(new Ajv({
|
|
29
|
+
coerceTypes: true
|
|
30
|
+
}), formats)
|
|
31
|
+
`;
|
|
32
|
+
const configurationJsonTemplate = ({}) => /* ts */ `import { defaultAppSettings, jsonSchema } from '@feathersjs/schema'
|
|
33
|
+
import type { FromSchema } from '@feathersjs/schema'
|
|
34
|
+
|
|
35
|
+
import { dataValidator } from './validators'
|
|
36
|
+
|
|
37
|
+
export const configurationSchema = {
|
|
38
|
+
type: 'object',
|
|
39
|
+
additionalProperties: false,
|
|
40
|
+
required: [ 'host', 'port', 'public' ],
|
|
41
|
+
properties: {
|
|
42
|
+
...defaultAppSettings,
|
|
43
|
+
host: { type: 'string' },
|
|
44
|
+
port: { type: 'number' },
|
|
45
|
+
public: { type: 'string' }
|
|
46
|
+
}
|
|
47
|
+
} as const
|
|
48
|
+
|
|
49
|
+
export const configurationValidator = jsonSchema.getValidator(configurationSchema, dataValidator)
|
|
50
|
+
|
|
51
|
+
export type ApplicationConfiguration = FromSchema<typeof configurationSchema>
|
|
52
|
+
`;
|
|
53
|
+
const configurationTypeboxTemplate = ({}) => /* ts */ `import { jsonSchema } from '@feathersjs/schema'
|
|
54
|
+
import { Type, defaultAppConfiguration } from '@feathersjs/typebox'
|
|
55
|
+
import type { Static } from '@feathersjs/typebox'
|
|
56
|
+
|
|
57
|
+
import { dataValidator } from './validators'
|
|
58
|
+
|
|
59
|
+
export const configurationSchema = Type.Intersect([
|
|
60
|
+
defaultAppConfiguration,
|
|
61
|
+
Type.Object({
|
|
62
|
+
host: Type.String(),
|
|
63
|
+
port: Type.Number(),
|
|
64
|
+
public: Type.String()
|
|
65
|
+
})
|
|
66
|
+
])
|
|
67
|
+
|
|
68
|
+
export type ApplicationConfiguration = Static<typeof configurationSchema>
|
|
69
|
+
|
|
70
|
+
export const configurationValidator = jsonSchema.getValidator(configurationSchema, dataValidator)
|
|
71
|
+
`;
|
|
72
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
73
|
+
.then((0, commons_1.renderSource)(async (ctx) => ctx.schema === 'typebox' ? configurationTypeboxTemplate(ctx) : configurationJsonTemplate(ctx), (0, pinion_1.toFile)(({ lib }) => lib, 'schemas', 'configuration')))
|
|
74
|
+
.then((0, commons_1.renderSource)(validatorTemplate, (0, pinion_1.toFile)(({ lib }) => lib, 'schemas', 'validators')));
|
|
75
|
+
exports.generate = generate;
|
|
76
|
+
//# sourceMappingURL=schemas.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/schemas.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,iBAAiB,GAAG,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAyBlC,CAAA;AAED,MAAM,yBAAyB,GAC7B,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;CAoBvC,CAAA;AAED,MAAM,4BAA4B,GAChC,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;CAkBvC,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,KAAK,EAAE,GAAG,EAAE,EAAE,CACZ,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,4BAA4B,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,GAAG,CAAC,EAC/F,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,eAAe,CAAC,CAC1E,CACF;KACA,IAAI,CACH,IAAA,sBAAY,EACV,iBAAiB,EACjB,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,YAAY,CAAC,CACvE,CACF,CAAA;AAdQ,QAAA,QAAQ,YAchB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { AppGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const validatorTemplate = /* ts */ `import { Ajv, addFormats } from '@feathersjs/schema'
|
|
6
|
+
import type { FormatsPluginOptions } from '@feathersjs/schema'
|
|
7
|
+
|
|
8
|
+
const formats: FormatsPluginOptions = [
|
|
9
|
+
'date-time',
|
|
10
|
+
'time',
|
|
11
|
+
'date',
|
|
12
|
+
'email',
|
|
13
|
+
'hostname',
|
|
14
|
+
'ipv4',
|
|
15
|
+
'ipv6',
|
|
16
|
+
'uri',
|
|
17
|
+
'uri-reference',
|
|
18
|
+
'uuid',
|
|
19
|
+
'uri-template',
|
|
20
|
+
'json-pointer',
|
|
21
|
+
'relative-json-pointer',
|
|
22
|
+
'regex'
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
export const dataValidator = addFormats(new Ajv({}), formats)
|
|
26
|
+
|
|
27
|
+
export const queryValidator = addFormats(new Ajv({
|
|
28
|
+
coerceTypes: true
|
|
29
|
+
}), formats)
|
|
30
|
+
`
|
|
31
|
+
|
|
32
|
+
const configurationJsonTemplate =
|
|
33
|
+
({}: AppGeneratorContext) => /* ts */ `import { defaultAppSettings, jsonSchema } from '@feathersjs/schema'
|
|
34
|
+
import type { FromSchema } from '@feathersjs/schema'
|
|
35
|
+
|
|
36
|
+
import { dataValidator } from './validators'
|
|
37
|
+
|
|
38
|
+
export const configurationSchema = {
|
|
39
|
+
type: 'object',
|
|
40
|
+
additionalProperties: false,
|
|
41
|
+
required: [ 'host', 'port', 'public' ],
|
|
42
|
+
properties: {
|
|
43
|
+
...defaultAppSettings,
|
|
44
|
+
host: { type: 'string' },
|
|
45
|
+
port: { type: 'number' },
|
|
46
|
+
public: { type: 'string' }
|
|
47
|
+
}
|
|
48
|
+
} as const
|
|
49
|
+
|
|
50
|
+
export const configurationValidator = jsonSchema.getValidator(configurationSchema, dataValidator)
|
|
51
|
+
|
|
52
|
+
export type ApplicationConfiguration = FromSchema<typeof configurationSchema>
|
|
53
|
+
`
|
|
54
|
+
|
|
55
|
+
const configurationTypeboxTemplate =
|
|
56
|
+
({}: AppGeneratorContext) => /* ts */ `import { jsonSchema } from '@feathersjs/schema'
|
|
57
|
+
import { Type, defaultAppConfiguration } from '@feathersjs/typebox'
|
|
58
|
+
import type { Static } from '@feathersjs/typebox'
|
|
59
|
+
|
|
60
|
+
import { dataValidator } from './validators'
|
|
61
|
+
|
|
62
|
+
export const configurationSchema = Type.Intersect([
|
|
63
|
+
defaultAppConfiguration,
|
|
64
|
+
Type.Object({
|
|
65
|
+
host: Type.String(),
|
|
66
|
+
port: Type.Number(),
|
|
67
|
+
public: Type.String()
|
|
68
|
+
})
|
|
69
|
+
])
|
|
70
|
+
|
|
71
|
+
export type ApplicationConfiguration = Static<typeof configurationSchema>
|
|
72
|
+
|
|
73
|
+
export const configurationValidator = jsonSchema.getValidator(configurationSchema, dataValidator)
|
|
74
|
+
`
|
|
75
|
+
|
|
76
|
+
export const generate = (ctx: AppGeneratorContext) =>
|
|
77
|
+
generator(ctx)
|
|
78
|
+
.then(
|
|
79
|
+
renderSource(
|
|
80
|
+
async (ctx) =>
|
|
81
|
+
ctx.schema === 'typebox' ? configurationTypeboxTemplate(ctx) : configurationJsonTemplate(ctx),
|
|
82
|
+
toFile<AppGeneratorContext>(({ lib }) => lib, 'schemas', 'configuration')
|
|
83
|
+
)
|
|
84
|
+
)
|
|
85
|
+
.then(
|
|
86
|
+
renderSource(
|
|
87
|
+
validatorTemplate,
|
|
88
|
+
toFile<AppGeneratorContext>(({ lib }) => lib, 'schemas', 'validators')
|
|
89
|
+
)
|
|
90
|
+
)
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
|
-
const template = ({}) => `import type { Application } from '../declarations'
|
|
6
|
+
const template = ({}) => /* ts */ `import type { Application } from '../declarations'
|
|
7
7
|
|
|
8
8
|
export const services = (app: Application) => {
|
|
9
9
|
// All services will be registered here
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/services.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAuB,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"services.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/services.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAuB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;CAKtD,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,CACnE,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
|
|
@@ -2,8 +2,7 @@ import { generator, toFile } from '@feathershq/pinion'
|
|
|
2
2
|
import { renderSource } from '../../commons'
|
|
3
3
|
import { AppGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
|
-
const template = ({}: AppGeneratorContext) =>
|
|
6
|
-
`import type { Application } from '../declarations'
|
|
5
|
+
const template = ({}: AppGeneratorContext) => /* ts */ `import type { Application } from '../declarations'
|
|
7
6
|
|
|
8
7
|
export const services = (app: Application) => {
|
|
9
8
|
// All services will be registered here
|
|
@@ -6,7 +6,7 @@ export interface AuthenticationGeneratorContext extends ServiceGeneratorContext
|
|
|
6
6
|
authStrategies: string[];
|
|
7
7
|
dependencies: string[];
|
|
8
8
|
}
|
|
9
|
-
export declare type AuthenticationGeneratorArguments = FeathersBaseContext & Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity'>>;
|
|
9
|
+
export declare type AuthenticationGeneratorArguments = FeathersBaseContext & Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity' | 'path'>>;
|
|
10
10
|
export declare const prompts: (ctx: AuthenticationGeneratorArguments) => ({
|
|
11
11
|
type: string;
|
|
12
12
|
name: string;
|
|
@@ -51,14 +51,15 @@ export declare const generate: (ctx: AuthenticationGeneratorArguments) => Promis
|
|
|
51
51
|
kebabName: string;
|
|
52
52
|
fileName: string;
|
|
53
53
|
relative: string;
|
|
54
|
-
type: "
|
|
54
|
+
type: "mongodb" | "knex" | "custom";
|
|
55
|
+
schema: false | "typebox" | "json";
|
|
55
56
|
authentication: boolean;
|
|
56
57
|
isEntityService?: boolean;
|
|
57
58
|
feathers: import("../commons").FeathersAppInfo;
|
|
58
59
|
pkg: import("../commons").AppPackageJson;
|
|
59
60
|
lib: string;
|
|
60
61
|
test: string;
|
|
61
|
-
language: "
|
|
62
|
+
language: "ts" | "js";
|
|
62
63
|
dependencyVersions?: import("../commons").DependencyVersions;
|
|
63
64
|
cwd: string;
|
|
64
65
|
_?: (string | number)[];
|
|
@@ -48,6 +48,13 @@ const prompts = (ctx) => [
|
|
|
48
48
|
type: 'input',
|
|
49
49
|
when: !ctx.service,
|
|
50
50
|
message: 'What is your authentication service name?',
|
|
51
|
+
default: 'user'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'path',
|
|
55
|
+
type: 'input',
|
|
56
|
+
when: !ctx.path,
|
|
57
|
+
message: 'What path should the service be registered on?',
|
|
51
58
|
default: 'users'
|
|
52
59
|
},
|
|
53
60
|
{
|
|
@@ -61,14 +68,16 @@ const prompts = (ctx) => [
|
|
|
61
68
|
];
|
|
62
69
|
exports.prompts = prompts;
|
|
63
70
|
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
71
|
+
.then((0, commons_1.initializeBaseContext)())
|
|
72
|
+
.then((0, commons_1.checkPreconditions)())
|
|
64
73
|
.then((0, pinion_1.prompt)(exports.prompts))
|
|
65
74
|
.then(async (ctx) => {
|
|
75
|
+
var _a;
|
|
66
76
|
const serviceContext = await (0, index_1.generate)({
|
|
67
77
|
...ctx,
|
|
68
78
|
name: ctx.service,
|
|
69
|
-
path: ctx.service,
|
|
70
79
|
isEntityService: true,
|
|
71
|
-
type: (0, commons_1.getDatabaseAdapter)(ctx.feathers.database)
|
|
80
|
+
type: (0, commons_1.getDatabaseAdapter)((_a = ctx.feathers) === null || _a === void 0 ? void 0 : _a.database)
|
|
72
81
|
});
|
|
73
82
|
return {
|
|
74
83
|
...ctx,
|
|
@@ -88,7 +97,7 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
|
88
97
|
dependencies: [...ctx.dependencies, ...dependencies]
|
|
89
98
|
};
|
|
90
99
|
}
|
|
91
|
-
return (0, pinion_1.install)((0, commons_1.addVersions)(dependencies, ctx.dependencyVersions))(ctx);
|
|
100
|
+
return (0, pinion_1.install)((0, commons_1.addVersions)(dependencies, ctx.dependencyVersions), false, ctx.feathers.packager)(ctx);
|
|
92
101
|
});
|
|
93
102
|
exports.generate = generate;
|
|
94
103
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authentication/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,+CAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authentication/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,+CAA8E;AAC9E,wCAMmB;AACnB,4CAAwF;AAYjF,MAAM,OAAO,GAAG,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1,12 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
import { generator, runGenerators, prompt, install } from '@feathershq/pinion'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
addVersions,
|
|
5
|
+
checkPreconditions,
|
|
6
|
+
FeathersBaseContext,
|
|
7
|
+
getDatabaseAdapter,
|
|
8
|
+
initializeBaseContext
|
|
9
|
+
} from '../commons'
|
|
4
10
|
import { generate as serviceGenerator, ServiceGeneratorContext } from '../service/index'
|
|
5
11
|
|
|
6
12
|
export interface AuthenticationGeneratorContext extends ServiceGeneratorContext {
|
|
@@ -11,7 +17,7 @@ export interface AuthenticationGeneratorContext extends ServiceGeneratorContext
|
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
export type AuthenticationGeneratorArguments = FeathersBaseContext &
|
|
14
|
-
Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity'>>
|
|
20
|
+
Partial<Pick<AuthenticationGeneratorContext, 'service' | 'authStrategies' | 'entity' | 'path'>>
|
|
15
21
|
|
|
16
22
|
export const prompts = (ctx: AuthenticationGeneratorArguments) => [
|
|
17
23
|
{
|
|
@@ -53,6 +59,13 @@ export const prompts = (ctx: AuthenticationGeneratorArguments) => [
|
|
|
53
59
|
type: 'input',
|
|
54
60
|
when: !ctx.service,
|
|
55
61
|
message: 'What is your authentication service name?',
|
|
62
|
+
default: 'user'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'path',
|
|
66
|
+
type: 'input',
|
|
67
|
+
when: !ctx.path,
|
|
68
|
+
message: 'What path should the service be registered on?',
|
|
56
69
|
default: 'users'
|
|
57
70
|
},
|
|
58
71
|
{
|
|
@@ -67,14 +80,15 @@ export const prompts = (ctx: AuthenticationGeneratorArguments) => [
|
|
|
67
80
|
|
|
68
81
|
export const generate = (ctx: AuthenticationGeneratorArguments) =>
|
|
69
82
|
generator(ctx)
|
|
83
|
+
.then(initializeBaseContext())
|
|
84
|
+
.then(checkPreconditions())
|
|
70
85
|
.then(prompt<AuthenticationGeneratorArguments, AuthenticationGeneratorContext>(prompts))
|
|
71
86
|
.then(async (ctx) => {
|
|
72
87
|
const serviceContext = await serviceGenerator({
|
|
73
88
|
...ctx,
|
|
74
89
|
name: ctx.service,
|
|
75
|
-
path: ctx.service,
|
|
76
90
|
isEntityService: true,
|
|
77
|
-
type: getDatabaseAdapter(ctx.feathers
|
|
91
|
+
type: getDatabaseAdapter(ctx.feathers?.database)
|
|
78
92
|
})
|
|
79
93
|
|
|
80
94
|
return {
|
|
@@ -99,5 +113,9 @@ export const generate = (ctx: AuthenticationGeneratorArguments) =>
|
|
|
99
113
|
}
|
|
100
114
|
}
|
|
101
115
|
|
|
102
|
-
return install<AuthenticationGeneratorContext>(
|
|
116
|
+
return install<AuthenticationGeneratorContext>(
|
|
117
|
+
addVersions(dependencies, ctx.dependencyVersions),
|
|
118
|
+
false,
|
|
119
|
+
ctx.feathers.packager
|
|
120
|
+
)(ctx)
|
|
103
121
|
})
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generate = void 0;
|
|
4
4
|
const pinion_1 = require("@feathershq/pinion");
|
|
5
5
|
const commons_1 = require("../../commons");
|
|
6
|
-
const template = ({ authStrategies
|
|
6
|
+
const template = ({ authStrategies }) => /* ts */ `import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
|
|
7
7
|
import { LocalStrategy } from '@feathersjs/authentication-local'
|
|
8
8
|
import { OAuthStrategy } from '@feathersjs/authentication-oauth'
|
|
9
|
-
|
|
9
|
+
import { oauth } from '@feathersjs/authentication-oauth'
|
|
10
10
|
import type { Application } from './declarations'
|
|
11
11
|
|
|
12
12
|
declare module './declarations' {
|
|
@@ -23,10 +23,8 @@ export const authentication = (app: Application) => {
|
|
|
23
23
|
.map((strategy) => ` authentication.register('${strategy}', ${strategy === 'local' ? `new LocalStrategy()` : `new OAuthStrategy()`})`)
|
|
24
24
|
.join('\n')}
|
|
25
25
|
|
|
26
|
-
app.use('authentication', authentication)
|
|
27
|
-
|
|
28
|
-
app.configure(expressOauth())`
|
|
29
|
-
: ''}
|
|
26
|
+
app.use('authentication', authentication)
|
|
27
|
+
app.configure(oauth())
|
|
30
28
|
}
|
|
31
29
|
`;
|
|
32
30
|
const importTemplate = "import { authentication } from './authentication'";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/authentication.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAC9D,2CAA0D;AAG1D,MAAM,QAAQ,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"authentication.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/authentication.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA8D;AAC9D,2CAA0D;AAG1D,MAAM,QAAQ,GAAG,CAAC,EAChB,cAAc,EACiB,EAAE,EAAE,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;IAgB3C,cAAc;KACb,GAAG,CACF,CAAC,QAAQ,EAAE,EAAE,CACX,8BAA8B,QAAQ,MACpC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBACjD,GAAG,CACN;KACA,IAAI,CAAC,IAAI,CAAC;;;;;CAKd,CAAA;AAED,MAAM,cAAc,GAAG,mDAAmD,CAAA;AAC1E,MAAM,iBAAiB,GAAG,+BAA+B,CAAA;AACzD,MAAM,SAAS,GAAG,IAAA,eAAM,EAAiC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;AAE5E,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CACH,IAAA,sBAAY,EACV,QAAQ,EACR,IAAA,eAAM,EAAiC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAC3E,CACF;KACA,IAAI,CAAC,IAAA,sBAAY,EAAC,cAAc,EAAE,IAAA,eAAM,EAAC,0BAA0B,CAAC,EAAE,SAAS,CAAC,CAAC;KACjF,IAAI,CAAC,IAAA,sBAAY,EAAC,iBAAiB,EAAE,IAAA,eAAM,EAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA;AAT3E,QAAA,QAAQ,YASmE"}
|
|
@@ -2,11 +2,12 @@ import { generator, before, toFile } from '@feathershq/pinion'
|
|
|
2
2
|
import { injectSource, renderSource } from '../../commons'
|
|
3
3
|
import { AuthenticationGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
|
-
const template = ({
|
|
6
|
-
|
|
5
|
+
const template = ({
|
|
6
|
+
authStrategies
|
|
7
|
+
}: AuthenticationGeneratorContext) => /* ts */ `import { AuthenticationService, JWTStrategy } from '@feathersjs/authentication'
|
|
7
8
|
import { LocalStrategy } from '@feathersjs/authentication-local'
|
|
8
9
|
import { OAuthStrategy } from '@feathersjs/authentication-oauth'
|
|
9
|
-
|
|
10
|
+
import { oauth } from '@feathersjs/authentication-oauth'
|
|
10
11
|
import type { Application } from './declarations'
|
|
11
12
|
|
|
12
13
|
declare module './declarations' {
|
|
@@ -28,12 +29,8 @@ export const authentication = (app: Application) => {
|
|
|
28
29
|
)
|
|
29
30
|
.join('\n')}
|
|
30
31
|
|
|
31
|
-
app.use('authentication', authentication)
|
|
32
|
-
|
|
33
|
-
? `
|
|
34
|
-
app.configure(expressOauth())`
|
|
35
|
-
: ''
|
|
36
|
-
}
|
|
32
|
+
app.use('authentication', authentication)
|
|
33
|
+
app.configure(oauth())
|
|
37
34
|
}
|
|
38
35
|
`
|
|
39
36
|
|
|
@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.generate = void 0;
|
|
7
7
|
const crypto_1 = __importDefault(require("crypto"));
|
|
8
8
|
const pinion_1 = require("@feathershq/pinion");
|
|
9
|
-
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
9
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
10
|
+
.then((0, pinion_1.mergeJSON)(({ authStrategies }) => {
|
|
10
11
|
const authentication = {
|
|
11
12
|
entity: ctx.entity,
|
|
12
|
-
service: ctx.
|
|
13
|
+
service: ctx.path,
|
|
13
14
|
secret: crypto_1.default.randomBytes(24).toString('base64'),
|
|
14
15
|
authStrategies: ['jwt'],
|
|
15
16
|
jwtOptions: {
|
|
@@ -36,11 +37,14 @@ const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.mergeJS
|
|
|
36
37
|
secret: '<Client secret>'
|
|
37
38
|
};
|
|
38
39
|
return oauth;
|
|
39
|
-
}, {
|
|
40
|
-
redirect: '/'
|
|
41
|
-
});
|
|
40
|
+
}, {});
|
|
42
41
|
}
|
|
43
42
|
return { authentication };
|
|
44
|
-
}, (0, pinion_1.toFile)('config', 'default.json')))
|
|
43
|
+
}, (0, pinion_1.toFile)('config', 'default.json')))
|
|
44
|
+
.then((0, pinion_1.mergeJSON)({
|
|
45
|
+
authentication: {
|
|
46
|
+
secret: 'FEATHERS_SECRET'
|
|
47
|
+
}
|
|
48
|
+
}, (0, pinion_1.toFile)('config', 'custom-environment-variables.json')));
|
|
45
49
|
exports.generate = generate;
|
|
46
50
|
//# sourceMappingURL=config.tpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/config.tpl.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAC3B,+CAAiE;AAG1D,MAAM,QAAQ,GAAG,CAAC,GAAmC,EAAE,EAAE,CAC9D,IAAA,kBAAS,EAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"config.tpl.js","sourceRoot":"","sources":["../../../src/authentication/templates/config.tpl.ts"],"names":[],"mappings":";;;;;;AAAA,oD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IAAA,eAAM,EAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CACrC;KACA,IAAI,CACH,IAAA,kBAAS,EACP;IACE,cAAc,EAAE;QACd,MAAM,EAAE,iBAAiB;KAC1B;CACF,EACD,IAAA,eAAM,EAAC,QAAQ,EAAE,mCAAmC,CAAC,CACtD,CACF,CAAA;AApDQ,QAAA,QAAQ,YAoDhB"}
|
|
@@ -3,49 +3,55 @@ import { generator, toFile, mergeJSON } from '@feathershq/pinion'
|
|
|
3
3
|
import { AuthenticationGeneratorContext } from '../index'
|
|
4
4
|
|
|
5
5
|
export const generate = (ctx: AuthenticationGeneratorContext) =>
|
|
6
|
-
generator(ctx)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
generator(ctx)
|
|
7
|
+
.then(
|
|
8
|
+
mergeJSON<AuthenticationGeneratorContext>(({ authStrategies }) => {
|
|
9
|
+
const authentication: any = {
|
|
10
|
+
entity: ctx.entity,
|
|
11
|
+
service: ctx.path,
|
|
12
|
+
secret: crypto.randomBytes(24).toString('base64'),
|
|
13
|
+
authStrategies: ['jwt'],
|
|
14
|
+
jwtOptions: {
|
|
15
|
+
header: {
|
|
16
|
+
typ: 'access'
|
|
17
|
+
},
|
|
18
|
+
audience: 'https://yourdomain.com',
|
|
19
|
+
algorithm: 'HS256',
|
|
20
|
+
expiresIn: '1d'
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
|
-
}
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
if (authStrategies.includes('local')) {
|
|
25
|
+
authentication.authStrategies.push('local')
|
|
26
|
+
authentication.local = {
|
|
27
|
+
usernameField: 'email',
|
|
28
|
+
passwordField: 'password'
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
|
-
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
const oauthStrategies = authStrategies.filter((name) => name !== 'local')
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
(oauth, name) => {
|
|
34
|
+
if (oauthStrategies.length) {
|
|
35
|
+
authentication.oauth = oauthStrategies.reduce((oauth, name) => {
|
|
36
36
|
oauth[name] = {
|
|
37
37
|
key: '<Client ID>',
|
|
38
38
|
secret: '<Client secret>'
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
return oauth
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
redirect: '/'
|
|
45
|
-
} as any
|
|
46
|
-
)
|
|
47
|
-
}
|
|
42
|
+
}, {} as any)
|
|
43
|
+
}
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
return { authentication }
|
|
46
|
+
}, toFile('config', 'default.json'))
|
|
47
|
+
)
|
|
48
|
+
.then(
|
|
49
|
+
mergeJSON<AuthenticationGeneratorContext>(
|
|
50
|
+
{
|
|
51
|
+
authentication: {
|
|
52
|
+
secret: 'FEATHERS_SECRET'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
toFile('config', 'custom-environment-variables.json')
|
|
56
|
+
)
|
|
57
|
+
)
|