@feathersjs/cli 4.6.2 → 5.0.0-pre.24
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 +10 -917
- package/LICENSE +1 -1
- package/README.md +9 -34
- package/bin/feathers +9 -0
- package/lib/app/index.d.ts +29 -0
- package/lib/app/index.js +123 -0
- package/lib/app/index.js.map +1 -0
- package/lib/app/index.ts +198 -0
- package/lib/app/static/.gitignore +121 -0
- package/lib/app/templates/app.test.tpl.d.ts +2 -0
- package/lib/app/templates/app.test.tpl.js +48 -0
- package/lib/app/templates/app.test.tpl.js.map +1 -0
- package/lib/app/templates/app.test.tpl.ts +48 -0
- package/lib/app/templates/app.tpl.d.ts +2 -0
- package/lib/app/templates/app.tpl.js +110 -0
- package/lib/app/templates/app.tpl.js.map +1 -0
- package/lib/app/templates/app.tpl.ts +119 -0
- package/lib/app/templates/channels.tpl.d.ts +2 -0
- package/lib/app/templates/channels.tpl.js +76 -0
- package/lib/app/templates/channels.tpl.js.map +1 -0
- package/lib/app/templates/channels.tpl.ts +81 -0
- package/lib/app/templates/client.tpl.d.ts +2 -0
- package/lib/app/templates/client.tpl.js +22 -0
- package/lib/app/templates/client.tpl.js.map +1 -0
- package/lib/app/templates/client.tpl.ts +27 -0
- package/lib/app/templates/config.tpl.d.ts +2 -0
- package/lib/app/templates/config.tpl.js +21 -0
- package/lib/app/templates/config.tpl.js.map +1 -0
- package/lib/app/templates/config.tpl.ts +21 -0
- package/lib/app/templates/configuration.tpl.d.ts +2 -0
- package/lib/app/templates/configuration.tpl.js +36 -0
- package/lib/app/templates/configuration.tpl.js.map +1 -0
- package/lib/app/templates/configuration.tpl.ts +41 -0
- package/lib/app/templates/declarations.tpl.d.ts +2 -0
- package/lib/app/templates/declarations.tpl.js +23 -0
- package/lib/app/templates/declarations.tpl.js.map +1 -0
- package/lib/app/templates/declarations.tpl.ts +31 -0
- package/lib/app/templates/index.html.tpl.d.ts +2 -0
- package/lib/app/templates/index.html.tpl.js +85 -0
- package/lib/app/templates/index.html.tpl.js.map +1 -0
- package/lib/app/templates/index.html.tpl.ts +85 -0
- package/lib/app/templates/index.tpl.d.ts +2 -0
- package/lib/app/templates/index.tpl.js +18 -0
- package/lib/app/templates/index.tpl.js.map +1 -0
- package/lib/app/templates/index.tpl.ts +23 -0
- package/lib/app/templates/logger.tpl.d.ts +2 -0
- package/lib/app/templates/logger.tpl.js +33 -0
- package/lib/app/templates/logger.tpl.js.map +1 -0
- package/lib/app/templates/logger.tpl.ts +38 -0
- package/lib/app/templates/package.json.tpl.d.ts +2 -0
- package/lib/app/templates/package.json.tpl.js +53 -0
- package/lib/app/templates/package.json.tpl.js.map +1 -0
- package/lib/app/templates/package.json.tpl.ts +65 -0
- package/lib/app/templates/readme.md.tpl.d.ts +2 -0
- package/lib/app/templates/readme.md.tpl.js +50 -0
- package/lib/app/templates/readme.md.tpl.js.map +1 -0
- package/lib/app/templates/readme.md.tpl.ts +50 -0
- package/lib/app/templates/services.tpl.d.ts +2 -0
- package/lib/app/templates/services.tpl.js +14 -0
- package/lib/app/templates/services.tpl.js.map +1 -0
- package/lib/app/templates/services.tpl.ts +19 -0
- package/lib/app/templates/tsconfig.json.tpl.d.ts +2 -0
- package/lib/app/templates/tsconfig.json.tpl.js +20 -0
- package/lib/app/templates/tsconfig.json.tpl.js.map +1 -0
- package/lib/app/templates/tsconfig.json.tpl.ts +26 -0
- package/lib/authentication/index.d.ts +71 -0
- package/lib/authentication/index.js +94 -0
- package/lib/authentication/index.js.map +1 -0
- package/lib/authentication/index.ts +103 -0
- package/lib/authentication/templates/authentication.tpl.d.ts +2 -0
- package/lib/authentication/templates/authentication.tpl.js +40 -0
- package/lib/authentication/templates/authentication.tpl.js.map +1 -0
- package/lib/authentication/templates/authentication.tpl.ts +53 -0
- package/lib/authentication/templates/config.tpl.d.ts +2 -0
- package/lib/authentication/templates/config.tpl.js +46 -0
- package/lib/authentication/templates/config.tpl.js.map +1 -0
- package/lib/authentication/templates/config.tpl.ts +51 -0
- package/lib/authentication/templates/declarations.tpl.d.ts +2 -0
- package/lib/authentication/templates/declarations.tpl.js +19 -0
- package/lib/authentication/templates/declarations.tpl.js.map +1 -0
- package/lib/authentication/templates/declarations.tpl.ts +29 -0
- package/lib/authentication/templates/knex.tpl.d.ts +2 -0
- package/lib/authentication/templates/knex.tpl.js +41 -0
- package/lib/authentication/templates/knex.tpl.js.map +1 -0
- package/lib/authentication/templates/knex.tpl.ts +59 -0
- package/lib/authentication/templates/test.tpl.d.ts +2 -0
- package/lib/authentication/templates/test.tpl.js +43 -0
- package/lib/authentication/templates/test.tpl.js.map +1 -0
- package/lib/authentication/templates/test.tpl.ts +50 -0
- package/lib/authentication/templates/user.resolver.tpl.d.ts +2 -0
- package/lib/authentication/templates/user.resolver.tpl.js +96 -0
- package/lib/authentication/templates/user.resolver.tpl.js.map +1 -0
- package/lib/authentication/templates/user.resolver.tpl.ts +109 -0
- package/lib/authentication/templates/user.schema.tpl.d.ts +2 -0
- package/lib/authentication/templates/user.schema.tpl.js +85 -0
- package/lib/authentication/templates/user.schema.tpl.js.map +1 -0
- package/lib/authentication/templates/user.schema.tpl.ts +93 -0
- package/lib/commons.d.ts +120 -0
- package/lib/commons.js +137 -0
- package/lib/commons.js.map +1 -0
- package/lib/commons.ts +187 -0
- package/lib/connection/index.d.ts +53 -0
- package/lib/connection/index.js +86 -0
- package/lib/connection/index.js.map +1 -0
- package/lib/connection/index.ts +109 -0
- package/lib/connection/templates/knex.tpl.d.ts +2 -0
- package/lib/connection/templates/knex.tpl.js +59 -0
- package/lib/connection/templates/knex.tpl.js.map +1 -0
- package/lib/connection/templates/knex.tpl.ts +79 -0
- package/lib/connection/templates/mongodb.tpl.d.ts +2 -0
- package/lib/connection/templates/mongodb.tpl.js +39 -0
- package/lib/connection/templates/mongodb.tpl.js.map +1 -0
- package/lib/connection/templates/mongodb.tpl.ts +51 -0
- package/lib/hook/index.d.ts +22 -0
- package/lib/hook/index.js +40 -0
- package/lib/hook/index.js.map +1 -0
- package/lib/hook/index.ts +45 -0
- package/lib/hook/templates/hook.tpl.d.ts +2 -0
- package/lib/hook/templates/hook.tpl.js +21 -0
- package/lib/hook/templates/hook.tpl.js.map +1 -0
- package/lib/hook/templates/hook.tpl.ts +28 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +24 -62
- package/lib/index.js.map +1 -0
- package/lib/index.ts +27 -0
- package/lib/service/index.d.ts +130 -0
- package/lib/service/index.js +84 -0
- package/lib/service/index.js.map +1 -0
- package/lib/service/index.ts +150 -0
- package/lib/service/templates/client.tpl.d.ts +2 -0
- package/lib/service/templates/client.tpl.js +16 -0
- package/lib/service/templates/client.tpl.js.map +1 -0
- package/lib/service/templates/client.tpl.ts +27 -0
- package/lib/service/templates/resolver.tpl.d.ts +2 -0
- package/lib/service/templates/resolver.tpl.js +73 -0
- package/lib/service/templates/resolver.tpl.js.map +1 -0
- package/lib/service/templates/resolver.tpl.ts +78 -0
- package/lib/service/templates/schema.tpl.d.ts +2 -0
- package/lib/service/templates/schema.tpl.js +75 -0
- package/lib/service/templates/schema.tpl.js.map +1 -0
- package/lib/service/templates/schema.tpl.ts +80 -0
- package/lib/service/templates/service.tpl.d.ts +2 -0
- package/lib/service/templates/service.tpl.js +92 -0
- package/lib/service/templates/service.tpl.js.map +1 -0
- package/lib/service/templates/service.tpl.ts +117 -0
- package/lib/service/templates/test.tpl.d.ts +2 -0
- package/lib/service/templates/test.tpl.js +24 -0
- package/lib/service/templates/test.tpl.js.map +1 -0
- package/lib/service/templates/test.tpl.ts +29 -0
- package/lib/service/type/custom.tpl.d.ts +4 -0
- package/lib/service/type/custom.tpl.js +79 -0
- package/lib/service/type/custom.tpl.js.map +1 -0
- package/lib/service/type/custom.tpl.ts +81 -0
- package/lib/service/type/knex.tpl.d.ts +5 -0
- package/lib/service/type/knex.tpl.js +50 -0
- package/lib/service/type/knex.tpl.js.map +1 -0
- package/lib/service/type/knex.tpl.ts +62 -0
- package/lib/service/type/mongodb.tpl.d.ts +4 -0
- package/lib/service/type/mongodb.tpl.js +29 -0
- package/lib/service/type/mongodb.tpl.js.map +1 -0
- package/lib/service/type/mongodb.tpl.ts +34 -0
- package/package.json +56 -36
- package/bin/feathers.js +0 -5
|
@@ -0,0 +1,110 @@
|
|
|
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 tsKoaApp = ({ transports }) => `import serveStatic from 'koa-static'
|
|
7
|
+
import { feathers } from '@feathersjs/feathers'
|
|
8
|
+
import configuration from '@feathersjs/configuration'
|
|
9
|
+
import { koa, rest, bodyParser, errorHandler, parseAuthentication } from '@feathersjs/koa'
|
|
10
|
+
${transports.includes('websockets') ? "import socketio from '@feathersjs/socketio'" : ''}
|
|
11
|
+
|
|
12
|
+
import type { Application } from './declarations'
|
|
13
|
+
import { configurationSchema } from './schemas/configuration.schema'
|
|
14
|
+
import { logErrorHook } from './logger'
|
|
15
|
+
import { services } from './services/index'
|
|
16
|
+
import { channels } from './channels'
|
|
17
|
+
|
|
18
|
+
const app: Application = koa(feathers())
|
|
19
|
+
|
|
20
|
+
// Load our app configuration (see config/ folder)
|
|
21
|
+
app.configure(configuration(configurationSchema))
|
|
22
|
+
|
|
23
|
+
// Set up Koa middleware
|
|
24
|
+
app.use(serveStatic(app.get('public')))
|
|
25
|
+
app.use(errorHandler())
|
|
26
|
+
app.use(parseAuthentication())
|
|
27
|
+
app.use(bodyParser())
|
|
28
|
+
|
|
29
|
+
// Configure services and transports
|
|
30
|
+
app.configure(rest())
|
|
31
|
+
${transports.includes('websockets') ? 'app.configure(socketio())' : ''}
|
|
32
|
+
app.configure(services)
|
|
33
|
+
app.configure(channels)
|
|
34
|
+
|
|
35
|
+
// Register hooks that run on all service methods
|
|
36
|
+
app.hooks({
|
|
37
|
+
around: {
|
|
38
|
+
all: [ logErrorHook ]
|
|
39
|
+
},
|
|
40
|
+
before: {},
|
|
41
|
+
after: {},
|
|
42
|
+
error: {}
|
|
43
|
+
})
|
|
44
|
+
// Register application setup and teardown hooks here
|
|
45
|
+
app.hooks({
|
|
46
|
+
setup: [],
|
|
47
|
+
teardown: []
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
export { app }
|
|
51
|
+
`;
|
|
52
|
+
const tsExpressApp = ({ transports }) => `import compress from 'compression'
|
|
53
|
+
import helmet from 'helmet'
|
|
54
|
+
|
|
55
|
+
import { feathers } from '@feathersjs/feathers'
|
|
56
|
+
import express, {
|
|
57
|
+
rest, json, urlencoded,
|
|
58
|
+
serveStatic, notFound, errorHandler
|
|
59
|
+
} from '@feathersjs/express'
|
|
60
|
+
import configuration from '@feathersjs/configuration'
|
|
61
|
+
${transports.includes('websockets') ? "import socketio from '@feathersjs/socketio'" : ''}
|
|
62
|
+
|
|
63
|
+
import type { Application } from './declarations'
|
|
64
|
+
import { configurationSchema } from './schemas/configuration.schema'
|
|
65
|
+
import { logger, logErrorHook } from './logger'
|
|
66
|
+
import { services } from './services/index'
|
|
67
|
+
import { channels } from './channels'
|
|
68
|
+
|
|
69
|
+
const app: Application = express(feathers())
|
|
70
|
+
|
|
71
|
+
// Load app configuration
|
|
72
|
+
app.configure(configuration(configurationSchema))
|
|
73
|
+
app.use(helmet())
|
|
74
|
+
app.use(compress())
|
|
75
|
+
app.use(json())
|
|
76
|
+
app.use(urlencoded({ extended: true }))
|
|
77
|
+
// Host the public folder
|
|
78
|
+
app.use('/', serveStatic(app.get('public')))
|
|
79
|
+
|
|
80
|
+
// Configure services and real-time functionality
|
|
81
|
+
app.configure(rest())
|
|
82
|
+
${transports.includes('websockets') ? 'app.configure(socketio())' : ''}
|
|
83
|
+
app.configure(services)
|
|
84
|
+
app.configure(channels)
|
|
85
|
+
|
|
86
|
+
// Configure a middleware for 404s and the error handler
|
|
87
|
+
app.use(notFound())
|
|
88
|
+
app.use(errorHandler({ logger }))
|
|
89
|
+
|
|
90
|
+
// Register hooks that run on all service methods
|
|
91
|
+
app.hooks({
|
|
92
|
+
around: {
|
|
93
|
+
all: [ logErrorHook ]
|
|
94
|
+
},
|
|
95
|
+
before: {},
|
|
96
|
+
after: {},
|
|
97
|
+
error: {}
|
|
98
|
+
})
|
|
99
|
+
// Register application setup and teardown hooks here
|
|
100
|
+
app.hooks({
|
|
101
|
+
setup: [],
|
|
102
|
+
teardown: []
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
export { app }
|
|
106
|
+
`;
|
|
107
|
+
const template = (ctx) => ctx.framework === 'express' ? tsExpressApp(ctx) : tsKoaApp(ctx);
|
|
108
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib }) => lib, 'app')));
|
|
109
|
+
exports.generate = generate;
|
|
110
|
+
//# sourceMappingURL=app.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/app.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,UAAU,EAAuB,EAAE,EAAE,CACvD;;;;EAIA,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,6CAA6C,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;;EAqBtF,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;CAoBrE,CAAA;AAED,MAAM,YAAY,GAAG,CAAC,EAAE,UAAU,EAAuB,EAAE,EAAE,CAC3D;;;;;;;;;EASA,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,6CAA6C,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;;EAqBtF,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;CAwBrE,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CAC5C,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AAE1D,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,KAAK,CAAC,CACrD,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { AppGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const tsKoaApp = ({ transports }: AppGeneratorContext) =>
|
|
6
|
+
`import serveStatic from 'koa-static'
|
|
7
|
+
import { feathers } from '@feathersjs/feathers'
|
|
8
|
+
import configuration from '@feathersjs/configuration'
|
|
9
|
+
import { koa, rest, bodyParser, errorHandler, parseAuthentication } from '@feathersjs/koa'
|
|
10
|
+
${transports.includes('websockets') ? "import socketio from '@feathersjs/socketio'" : ''}
|
|
11
|
+
|
|
12
|
+
import type { Application } from './declarations'
|
|
13
|
+
import { configurationSchema } from './schemas/configuration.schema'
|
|
14
|
+
import { logErrorHook } from './logger'
|
|
15
|
+
import { services } from './services/index'
|
|
16
|
+
import { channels } from './channels'
|
|
17
|
+
|
|
18
|
+
const app: Application = koa(feathers())
|
|
19
|
+
|
|
20
|
+
// Load our app configuration (see config/ folder)
|
|
21
|
+
app.configure(configuration(configurationSchema))
|
|
22
|
+
|
|
23
|
+
// Set up Koa middleware
|
|
24
|
+
app.use(serveStatic(app.get('public')))
|
|
25
|
+
app.use(errorHandler())
|
|
26
|
+
app.use(parseAuthentication())
|
|
27
|
+
app.use(bodyParser())
|
|
28
|
+
|
|
29
|
+
// Configure services and transports
|
|
30
|
+
app.configure(rest())
|
|
31
|
+
${transports.includes('websockets') ? 'app.configure(socketio())' : ''}
|
|
32
|
+
app.configure(services)
|
|
33
|
+
app.configure(channels)
|
|
34
|
+
|
|
35
|
+
// Register hooks that run on all service methods
|
|
36
|
+
app.hooks({
|
|
37
|
+
around: {
|
|
38
|
+
all: [ logErrorHook ]
|
|
39
|
+
},
|
|
40
|
+
before: {},
|
|
41
|
+
after: {},
|
|
42
|
+
error: {}
|
|
43
|
+
})
|
|
44
|
+
// Register application setup and teardown hooks here
|
|
45
|
+
app.hooks({
|
|
46
|
+
setup: [],
|
|
47
|
+
teardown: []
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
export { app }
|
|
51
|
+
`
|
|
52
|
+
|
|
53
|
+
const tsExpressApp = ({ transports }: AppGeneratorContext) =>
|
|
54
|
+
`import compress from 'compression'
|
|
55
|
+
import helmet from 'helmet'
|
|
56
|
+
|
|
57
|
+
import { feathers } from '@feathersjs/feathers'
|
|
58
|
+
import express, {
|
|
59
|
+
rest, json, urlencoded,
|
|
60
|
+
serveStatic, notFound, errorHandler
|
|
61
|
+
} from '@feathersjs/express'
|
|
62
|
+
import configuration from '@feathersjs/configuration'
|
|
63
|
+
${transports.includes('websockets') ? "import socketio from '@feathersjs/socketio'" : ''}
|
|
64
|
+
|
|
65
|
+
import type { Application } from './declarations'
|
|
66
|
+
import { configurationSchema } from './schemas/configuration.schema'
|
|
67
|
+
import { logger, logErrorHook } from './logger'
|
|
68
|
+
import { services } from './services/index'
|
|
69
|
+
import { channels } from './channels'
|
|
70
|
+
|
|
71
|
+
const app: Application = express(feathers())
|
|
72
|
+
|
|
73
|
+
// Load app configuration
|
|
74
|
+
app.configure(configuration(configurationSchema))
|
|
75
|
+
app.use(helmet())
|
|
76
|
+
app.use(compress())
|
|
77
|
+
app.use(json())
|
|
78
|
+
app.use(urlencoded({ extended: true }))
|
|
79
|
+
// Host the public folder
|
|
80
|
+
app.use('/', serveStatic(app.get('public')))
|
|
81
|
+
|
|
82
|
+
// Configure services and real-time functionality
|
|
83
|
+
app.configure(rest())
|
|
84
|
+
${transports.includes('websockets') ? 'app.configure(socketio())' : ''}
|
|
85
|
+
app.configure(services)
|
|
86
|
+
app.configure(channels)
|
|
87
|
+
|
|
88
|
+
// Configure a middleware for 404s and the error handler
|
|
89
|
+
app.use(notFound())
|
|
90
|
+
app.use(errorHandler({ logger }))
|
|
91
|
+
|
|
92
|
+
// Register hooks that run on all service methods
|
|
93
|
+
app.hooks({
|
|
94
|
+
around: {
|
|
95
|
+
all: [ logErrorHook ]
|
|
96
|
+
},
|
|
97
|
+
before: {},
|
|
98
|
+
after: {},
|
|
99
|
+
error: {}
|
|
100
|
+
})
|
|
101
|
+
// Register application setup and teardown hooks here
|
|
102
|
+
app.hooks({
|
|
103
|
+
setup: [],
|
|
104
|
+
teardown: []
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
export { app }
|
|
108
|
+
`
|
|
109
|
+
|
|
110
|
+
const template = (ctx: AppGeneratorContext) =>
|
|
111
|
+
ctx.framework === 'express' ? tsExpressApp(ctx) : tsKoaApp(ctx)
|
|
112
|
+
|
|
113
|
+
export const generate = (ctx: AppGeneratorContext) =>
|
|
114
|
+
generator(ctx).then(
|
|
115
|
+
renderSource(
|
|
116
|
+
template,
|
|
117
|
+
toFile<AppGeneratorContext>(({ lib }) => lib, 'app')
|
|
118
|
+
)
|
|
119
|
+
)
|
|
@@ -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 template = ({ language }) => `import '@feathersjs/transport-commons'
|
|
7
|
+
import type { Application, HookContext } from './declarations'
|
|
8
|
+
import { logger } from './logger'
|
|
9
|
+
|
|
10
|
+
export const channels = (app: Application) => {
|
|
11
|
+
if(typeof app.channel !== 'function') {
|
|
12
|
+
// If no real-time functionality has been configured just return
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
logger.warn('Publishing all events to all authenticated users. See \`channels.${language}\` and https://docs.feathersjs.com/api/channels.html for more information.')
|
|
17
|
+
|
|
18
|
+
app.on('connection', (connection: any) => {
|
|
19
|
+
// On a new real-time connection, add it to the anonymous channel
|
|
20
|
+
app.channel('anonymous').join(connection)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
app.on('login', (authResult: any, { connection }: any) => {
|
|
24
|
+
// connection can be undefined if there is no
|
|
25
|
+
// real-time connection, e.g. when logging in via REST
|
|
26
|
+
if(connection) {
|
|
27
|
+
// Obtain the logged in user from the connection
|
|
28
|
+
// const user = connection.user
|
|
29
|
+
|
|
30
|
+
// The connection is no longer anonymous, remove it
|
|
31
|
+
app.channel('anonymous').leave(connection)
|
|
32
|
+
|
|
33
|
+
// Add it to the authenticated user channel
|
|
34
|
+
app.channel('authenticated').join(connection)
|
|
35
|
+
|
|
36
|
+
// Channels can be named anything and joined on any condition
|
|
37
|
+
|
|
38
|
+
// E.g. to send real-time events only to admins use
|
|
39
|
+
// if(user.isAdmin) { app.channel('admins').join(connection) }
|
|
40
|
+
|
|
41
|
+
// If the user has joined e.g. chat rooms
|
|
42
|
+
// if(Array.isArray(user.rooms)) user.rooms.forEach(room => app.channel(\`rooms/\${room.id}\`).join(connection))
|
|
43
|
+
|
|
44
|
+
// Easily organize users by email and userid for things like messaging
|
|
45
|
+
// app.channel(\`emails/\${user.email}\`).join(connection)
|
|
46
|
+
// app.channel(\`userIds/\${user.id}\`).join(connection)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// eslint-disable-next-line no-unused-vars
|
|
51
|
+
app.publish((data: any, hook: HookContext) => {
|
|
52
|
+
// Here you can add event publishers to channels set up in \`channels.js\`
|
|
53
|
+
// To publish only for a specific event use \`app.publish(eventname, () => {})\`
|
|
54
|
+
|
|
55
|
+
console.log('Publishing all events to all authenticated users. See \`channels.js\` and https://docs.feathersjs.com/api/channels.html for more information.') // eslint-disable-line
|
|
56
|
+
|
|
57
|
+
// e.g. to publish all service events to all authenticated users use
|
|
58
|
+
return app.channel('authenticated')
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
// Here you can also add service specific event publishers
|
|
62
|
+
// e.g. the publish the \`users\` service \`created\` event to the \`admins\` channel
|
|
63
|
+
// app.service('users').publish('created', () => app.channel('admins'))
|
|
64
|
+
|
|
65
|
+
// With the userid and email organization from above you can easily select involved users
|
|
66
|
+
// app.service('messages').publish(() => {
|
|
67
|
+
// return [
|
|
68
|
+
// app.channel(\`userIds/\${data.createdBy}\`),
|
|
69
|
+
// app.channel(\`emails/\${data.recipientEmail}\`)
|
|
70
|
+
// ]
|
|
71
|
+
// })
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib }) => lib, 'channels')));
|
|
75
|
+
exports.generate = generate;
|
|
76
|
+
//# sourceMappingURL=channels.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channels.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/channels.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ,EAAuB,EAAE,EAAE,CACrD;;;;;;;;;;kFAUgF,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDzF,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,CAAC,CAC1D,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { AppGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const template = ({ language }: AppGeneratorContext) =>
|
|
6
|
+
`import '@feathersjs/transport-commons'
|
|
7
|
+
import type { Application, HookContext } from './declarations'
|
|
8
|
+
import { logger } from './logger'
|
|
9
|
+
|
|
10
|
+
export const channels = (app: Application) => {
|
|
11
|
+
if(typeof app.channel !== 'function') {
|
|
12
|
+
// If no real-time functionality has been configured just return
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
logger.warn('Publishing all events to all authenticated users. See \`channels.${language}\` and https://docs.feathersjs.com/api/channels.html for more information.')
|
|
17
|
+
|
|
18
|
+
app.on('connection', (connection: any) => {
|
|
19
|
+
// On a new real-time connection, add it to the anonymous channel
|
|
20
|
+
app.channel('anonymous').join(connection)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
app.on('login', (authResult: any, { connection }: any) => {
|
|
24
|
+
// connection can be undefined if there is no
|
|
25
|
+
// real-time connection, e.g. when logging in via REST
|
|
26
|
+
if(connection) {
|
|
27
|
+
// Obtain the logged in user from the connection
|
|
28
|
+
// const user = connection.user
|
|
29
|
+
|
|
30
|
+
// The connection is no longer anonymous, remove it
|
|
31
|
+
app.channel('anonymous').leave(connection)
|
|
32
|
+
|
|
33
|
+
// Add it to the authenticated user channel
|
|
34
|
+
app.channel('authenticated').join(connection)
|
|
35
|
+
|
|
36
|
+
// Channels can be named anything and joined on any condition
|
|
37
|
+
|
|
38
|
+
// E.g. to send real-time events only to admins use
|
|
39
|
+
// if(user.isAdmin) { app.channel('admins').join(connection) }
|
|
40
|
+
|
|
41
|
+
// If the user has joined e.g. chat rooms
|
|
42
|
+
// if(Array.isArray(user.rooms)) user.rooms.forEach(room => app.channel(\`rooms/\${room.id}\`).join(connection))
|
|
43
|
+
|
|
44
|
+
// Easily organize users by email and userid for things like messaging
|
|
45
|
+
// app.channel(\`emails/\${user.email}\`).join(connection)
|
|
46
|
+
// app.channel(\`userIds/\${user.id}\`).join(connection)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// eslint-disable-next-line no-unused-vars
|
|
51
|
+
app.publish((data: any, hook: HookContext) => {
|
|
52
|
+
// Here you can add event publishers to channels set up in \`channels.js\`
|
|
53
|
+
// To publish only for a specific event use \`app.publish(eventname, () => {})\`
|
|
54
|
+
|
|
55
|
+
console.log('Publishing all events to all authenticated users. See \`channels.js\` and https://docs.feathersjs.com/api/channels.html for more information.') // eslint-disable-line
|
|
56
|
+
|
|
57
|
+
// e.g. to publish all service events to all authenticated users use
|
|
58
|
+
return app.channel('authenticated')
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
// Here you can also add service specific event publishers
|
|
62
|
+
// e.g. the publish the \`users\` service \`created\` event to the \`admins\` channel
|
|
63
|
+
// app.service('users').publish('created', () => app.channel('admins'))
|
|
64
|
+
|
|
65
|
+
// With the userid and email organization from above you can easily select involved users
|
|
66
|
+
// app.service('messages').publish(() => {
|
|
67
|
+
// return [
|
|
68
|
+
// app.channel(\`userIds/\${data.createdBy}\`),
|
|
69
|
+
// app.channel(\`emails/\${data.recipientEmail}\`)
|
|
70
|
+
// ]
|
|
71
|
+
// })
|
|
72
|
+
}
|
|
73
|
+
`
|
|
74
|
+
|
|
75
|
+
export const generate = (ctx: AppGeneratorContext) =>
|
|
76
|
+
generator(ctx).then(
|
|
77
|
+
renderSource(
|
|
78
|
+
template,
|
|
79
|
+
toFile<AppGeneratorContext>(({ lib }) => lib, 'channels')
|
|
80
|
+
)
|
|
81
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
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 template = ({}) => `import { feathers, type Service, type TransportConnection } from '@feathersjs/feathers'
|
|
7
|
+
|
|
8
|
+
// A mapping of client side services
|
|
9
|
+
export interface ServiceTypes {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const createClient = <Configuration = any> (connection: TransportConnection<ServiceTypes>) => {
|
|
13
|
+
const client = feathers<ServiceTypes, Configuration>()
|
|
14
|
+
|
|
15
|
+
client.configure(connection)
|
|
16
|
+
|
|
17
|
+
return client
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
const generate = async (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib }) => lib, 'client')));
|
|
21
|
+
exports.generate = generate;
|
|
22
|
+
//# sourceMappingURL=client.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/client.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAuB,EAAE,EAAE,CAC3C;;;;;;;;;;;;;CAaD,CAAA;AAEM,MAAM,QAAQ,GAAG,KAAK,EAAE,GAAwB,EAAE,EAAE,CACzD,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,QAAQ,CAAC,CACxD,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { AppGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const template = ({}: AppGeneratorContext) =>
|
|
6
|
+
`import { feathers, type Service, type TransportConnection } from '@feathersjs/feathers'
|
|
7
|
+
|
|
8
|
+
// A mapping of client side services
|
|
9
|
+
export interface ServiceTypes {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const createClient = <Configuration = any> (connection: TransportConnection<ServiceTypes>) => {
|
|
13
|
+
const client = feathers<ServiceTypes, Configuration>()
|
|
14
|
+
|
|
15
|
+
client.configure(connection)
|
|
16
|
+
|
|
17
|
+
return client
|
|
18
|
+
}
|
|
19
|
+
`
|
|
20
|
+
|
|
21
|
+
export const generate = async (ctx: AppGeneratorContext) =>
|
|
22
|
+
generator(ctx).then(
|
|
23
|
+
renderSource(
|
|
24
|
+
template,
|
|
25
|
+
toFile<AppGeneratorContext>(({ lib }) => lib, 'client')
|
|
26
|
+
)
|
|
27
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generate = void 0;
|
|
4
|
+
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
+
const defaultConfig = ({}) => ({
|
|
6
|
+
host: 'localhost',
|
|
7
|
+
port: 3030,
|
|
8
|
+
public: './public/',
|
|
9
|
+
paginate: {
|
|
10
|
+
default: 10,
|
|
11
|
+
max: 50
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
const testConfig = {
|
|
15
|
+
port: 8998
|
|
16
|
+
};
|
|
17
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx)
|
|
18
|
+
.then((0, pinion_1.writeJSON)(defaultConfig, (0, pinion_1.toFile)('config', 'default.json')))
|
|
19
|
+
.then((0, pinion_1.writeJSON)(testConfig, (0, pinion_1.toFile)('config', 'test.json')));
|
|
20
|
+
exports.generate = generate;
|
|
21
|
+
//# sourceMappingURL=config.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/config.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAiE;AAGjE,MAAM,aAAa,GAAG,CAAC,EAAuB,EAAE,EAAE,CAAC,CAAC;IAClD,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,WAAW;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE,EAAE;QACX,GAAG,EAAE,EAAE;KACR;CACF,CAAC,CAAA;AAEF,MAAM,UAAU,GAAG;IACjB,IAAI,EAAE,IAAI;CACX,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC;KACX,IAAI,CAAC,IAAA,kBAAS,EAAC,aAAa,EAAE,IAAA,eAAM,EAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;KAChE,IAAI,CAAC,IAAA,kBAAS,EAAC,UAAU,EAAE,IAAA,eAAM,EAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;AAHlD,QAAA,QAAQ,YAG0C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { generator, toFile, writeJSON } from '@feathershq/pinion'
|
|
2
|
+
import { AppGeneratorContext } from '../index'
|
|
3
|
+
|
|
4
|
+
const defaultConfig = ({}: AppGeneratorContext) => ({
|
|
5
|
+
host: 'localhost',
|
|
6
|
+
port: 3030,
|
|
7
|
+
public: './public/',
|
|
8
|
+
paginate: {
|
|
9
|
+
default: 10,
|
|
10
|
+
max: 50
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const testConfig = {
|
|
15
|
+
port: 8998
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const generate = (ctx: AppGeneratorContext) =>
|
|
19
|
+
generator(ctx)
|
|
20
|
+
.then(writeJSON(defaultConfig, toFile('config', 'default.json')))
|
|
21
|
+
.then(writeJSON(testConfig, toFile('config', 'test.json')))
|
|
@@ -0,0 +1,36 @@
|
|
|
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 template = ({}) => `import { schema, Ajv } from '@feathersjs/schema'
|
|
7
|
+
import type { Infer } from '@feathersjs/schema'
|
|
8
|
+
import { authenticationSettingsSchema } from '@feathersjs/authentication'
|
|
9
|
+
|
|
10
|
+
export const configurationSchema = schema({
|
|
11
|
+
$id: 'ApplicationConfiguration',
|
|
12
|
+
type: 'object',
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
required: [ 'host', 'port', 'public', 'paginate' ],
|
|
15
|
+
properties: {
|
|
16
|
+
host: { type: 'string' },
|
|
17
|
+
port: { type: 'number' },
|
|
18
|
+
public: { type: 'string' },
|
|
19
|
+
authentication: authenticationSettingsSchema,
|
|
20
|
+
paginate: {
|
|
21
|
+
type: 'object',
|
|
22
|
+
additionalProperties: false,
|
|
23
|
+
required: [ 'default', 'max' ],
|
|
24
|
+
properties: {
|
|
25
|
+
default: { type: 'number' },
|
|
26
|
+
max: { type: 'number' }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
} as const, new Ajv())
|
|
31
|
+
|
|
32
|
+
export type ConfigurationSchema = Infer<typeof configurationSchema>
|
|
33
|
+
`;
|
|
34
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, commons_1.renderSource)(template, (0, pinion_1.toFile)(({ lib }) => lib, 'schemas', 'configuration.schema')));
|
|
35
|
+
exports.generate = generate;
|
|
36
|
+
//# sourceMappingURL=configuration.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/configuration.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAAsD;AACtD,2CAA4C;AAG5C,MAAM,QAAQ,GAAG,CAAC,EAAuB,EAAE,EAAE,CAC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BD,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,SAAS,EAAE,sBAAsB,CAAC,CACjF,CACF,CAAA;AANU,QAAA,QAAQ,YAMlB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { generator, toFile } from '@feathershq/pinion'
|
|
2
|
+
import { renderSource } from '../../commons'
|
|
3
|
+
import { AppGeneratorContext } from '../index'
|
|
4
|
+
|
|
5
|
+
const template = ({}: AppGeneratorContext) =>
|
|
6
|
+
`import { schema, Ajv } from '@feathersjs/schema'
|
|
7
|
+
import type { Infer } from '@feathersjs/schema'
|
|
8
|
+
import { authenticationSettingsSchema } from '@feathersjs/authentication'
|
|
9
|
+
|
|
10
|
+
export const configurationSchema = schema({
|
|
11
|
+
$id: 'ApplicationConfiguration',
|
|
12
|
+
type: 'object',
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
required: [ 'host', 'port', 'public', 'paginate' ],
|
|
15
|
+
properties: {
|
|
16
|
+
host: { type: 'string' },
|
|
17
|
+
port: { type: 'number' },
|
|
18
|
+
public: { type: 'string' },
|
|
19
|
+
authentication: authenticationSettingsSchema,
|
|
20
|
+
paginate: {
|
|
21
|
+
type: 'object',
|
|
22
|
+
additionalProperties: false,
|
|
23
|
+
required: [ 'default', 'max' ],
|
|
24
|
+
properties: {
|
|
25
|
+
default: { type: 'number' },
|
|
26
|
+
max: { type: 'number' }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
} as const, new Ajv())
|
|
31
|
+
|
|
32
|
+
export type ConfigurationSchema = Infer<typeof configurationSchema>
|
|
33
|
+
`
|
|
34
|
+
|
|
35
|
+
export const generate = (ctx: AppGeneratorContext) =>
|
|
36
|
+
generator(ctx).then(
|
|
37
|
+
renderSource(
|
|
38
|
+
template,
|
|
39
|
+
toFile<AppGeneratorContext>(({ lib }) => lib, 'schemas', 'configuration.schema')
|
|
40
|
+
)
|
|
41
|
+
)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generate = void 0;
|
|
4
|
+
const pinion_1 = require("@feathershq/pinion");
|
|
5
|
+
const template = ({ framework }) => `import { HookContext as FeathersHookContext, NextFunction } from '@feathersjs/feathers'
|
|
6
|
+
import { Application as FeathersApplication } from '@feathersjs/${framework}'
|
|
7
|
+
import { ConfigurationSchema } from './schemas/configuration.schema'
|
|
8
|
+
|
|
9
|
+
export { NextFunction }
|
|
10
|
+
|
|
11
|
+
export interface Configuration extends ConfigurationSchema {}
|
|
12
|
+
|
|
13
|
+
// A mapping of service names to types. Will be extended in service files.
|
|
14
|
+
export interface ServiceTypes {}
|
|
15
|
+
|
|
16
|
+
// The application instance type that will be used everywhere else
|
|
17
|
+
export type Application = FeathersApplication<ServiceTypes, Configuration>
|
|
18
|
+
|
|
19
|
+
export type HookContext = FeathersHookContext<Application>
|
|
20
|
+
`;
|
|
21
|
+
const generate = (ctx) => (0, pinion_1.generator)(ctx).then((0, pinion_1.when)(({ language }) => language === 'ts', (0, pinion_1.renderTemplate)(template, (0, pinion_1.toFile)(({ lib }) => lib, 'declarations.ts'))));
|
|
22
|
+
exports.generate = generate;
|
|
23
|
+
//# sourceMappingURL=declarations.tpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations.tpl.js","sourceRoot":"","sources":["../../../src/app/templates/declarations.tpl.ts"],"names":[],"mappings":";;;AAAA,+CAA4E;AAG5E,MAAM,QAAQ,GAAG,CAAC,EAAE,SAAS,EAAuB,EAAE,EAAE,CACtD;kEACgE,SAAS;;;;;;;;;;;;;;CAc1E,CAAA;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAwB,EAAE,EAAE,CACnD,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC,IAAI,CACjB,IAAA,aAAI,EACF,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI,EACnC,IAAA,uBAAc,EACZ,QAAQ,EACR,IAAA,eAAM,EAAsB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC,CACjE,CACF,CACF,CAAA;AATU,QAAA,QAAQ,YASlB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { generator, toFile, when, renderTemplate } from '@feathershq/pinion'
|
|
2
|
+
import { AppGeneratorContext } from '../index'
|
|
3
|
+
|
|
4
|
+
const template = ({ framework }: AppGeneratorContext) =>
|
|
5
|
+
`import { HookContext as FeathersHookContext, NextFunction } from '@feathersjs/feathers'
|
|
6
|
+
import { Application as FeathersApplication } from '@feathersjs/${framework}'
|
|
7
|
+
import { ConfigurationSchema } from './schemas/configuration.schema'
|
|
8
|
+
|
|
9
|
+
export { NextFunction }
|
|
10
|
+
|
|
11
|
+
export interface Configuration extends ConfigurationSchema {}
|
|
12
|
+
|
|
13
|
+
// A mapping of service names to types. Will be extended in service files.
|
|
14
|
+
export interface ServiceTypes {}
|
|
15
|
+
|
|
16
|
+
// The application instance type that will be used everywhere else
|
|
17
|
+
export type Application = FeathersApplication<ServiceTypes, Configuration>
|
|
18
|
+
|
|
19
|
+
export type HookContext = FeathersHookContext<Application>
|
|
20
|
+
`
|
|
21
|
+
|
|
22
|
+
export const generate = (ctx: AppGeneratorContext) =>
|
|
23
|
+
generator(ctx).then(
|
|
24
|
+
when<AppGeneratorContext>(
|
|
25
|
+
({ language }) => language === 'ts',
|
|
26
|
+
renderTemplate(
|
|
27
|
+
template,
|
|
28
|
+
toFile<AppGeneratorContext>(({ lib }) => lib, 'declarations.ts')
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
)
|