@rvoh/psychic 0.26.0 → 0.26.2
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/dist/cjs/src/bin/index.js +9 -11
- package/dist/cjs/src/generate/controller.js +3 -3
- package/dist/cjs/src/generate/helpers/generateResourceControllerSpecContent.js +18 -18
- package/dist/cjs/src/helpers/path.js +3 -3
- package/dist/cjs/src/server/helpers/startPsychicServer.js +2 -4
- package/dist/esm/src/bin/index.js +9 -11
- package/dist/esm/src/generate/controller.js +2 -2
- package/dist/esm/src/generate/helpers/generateResourceControllerSpecContent.js +18 -18
- package/dist/esm/src/helpers/path.js +1 -1
- package/dist/esm/src/server/helpers/startPsychicServer.js +2 -4
- package/package.json +4 -4
|
@@ -28,9 +28,7 @@ class PsychicBin {
|
|
|
28
28
|
await dream_1.DreamBin.sync(() => { });
|
|
29
29
|
await PsychicBin.syncTypes();
|
|
30
30
|
const psychicApp = index_js_1.default.getOrFail();
|
|
31
|
-
|
|
32
|
-
await PsychicBin.syncOpenapiJson();
|
|
33
|
-
}
|
|
31
|
+
await PsychicBin.syncOpenapiJson();
|
|
34
32
|
if (psychicApp.openapi?.syncEnumsToClient) {
|
|
35
33
|
await this.syncClientEnums();
|
|
36
34
|
}
|
|
@@ -50,30 +48,30 @@ class PsychicBin {
|
|
|
50
48
|
}
|
|
51
49
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
50
|
static async syncTypes(customTypes = undefined) {
|
|
53
|
-
|
|
51
|
+
dream_1.DreamCLI.logger.logStartProgress(`syncing types/psychic.ts...`);
|
|
54
52
|
await TypesBuilder_js_1.default.sync(customTypes);
|
|
55
|
-
|
|
53
|
+
dream_1.DreamCLI.logger.logEndProgress();
|
|
56
54
|
}
|
|
57
55
|
static async syncOpenapiJson() {
|
|
58
|
-
|
|
56
|
+
dream_1.DreamCLI.logger.logStartProgress(`syncing openapi...`);
|
|
59
57
|
await app_js_1.default.sync();
|
|
60
|
-
|
|
58
|
+
dream_1.DreamCLI.logger.logEndProgress();
|
|
61
59
|
}
|
|
62
60
|
static async syncRoutes() {
|
|
63
|
-
|
|
61
|
+
dream_1.DreamCLI.logger.logStartProgress(`syncing routes...`);
|
|
64
62
|
const server = new index_js_2.default();
|
|
65
63
|
await server.boot();
|
|
66
64
|
const routes = await server.routes();
|
|
67
65
|
await (0, generateRouteTypes_js_1.default)(routes);
|
|
68
|
-
|
|
66
|
+
dream_1.DreamCLI.logger.logEndProgress();
|
|
69
67
|
}
|
|
70
68
|
static async syncClientEnums() {
|
|
71
|
-
|
|
69
|
+
dream_1.DreamCLI.logger.logStartProgress(`syncing client enums...`);
|
|
72
70
|
const psychicApp = index_js_1.default.getOrFail();
|
|
73
71
|
const apiPath = path.join(psychicApp.clientRoot, psychicApp.client.apiPath);
|
|
74
72
|
const enumsStr = await (0, enumsFileStr_js_1.default)();
|
|
75
73
|
await fs.writeFile(`${apiPath}/enums.ts`, enumsStr);
|
|
76
|
-
|
|
74
|
+
dream_1.DreamCLI.logger.logEndProgress();
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
77
|
exports.default = PsychicBin;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = generateController;
|
|
4
4
|
const dream_1 = require("@rvoh/dream");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
5
|
const fs = require("fs/promises");
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
7
|
const EnvInternal_js_1 = require("../helpers/EnvInternal.js");
|
|
8
8
|
const psychicFileAndDirPaths_js_1 = require("../helpers/path/psychicFileAndDirPaths.js");
|
|
9
9
|
const psychicPath_js_1 = require("../helpers/path/psychicPath.js");
|
|
@@ -20,13 +20,13 @@ async function generateController({ fullyQualifiedControllerName, fullyQualified
|
|
|
20
20
|
const isAdmin = allControllerNameParts[0] === 'Admin';
|
|
21
21
|
const controllerNameParts = isAdmin ? [allControllerNameParts.shift()] : [];
|
|
22
22
|
for (let index = 0; index < allControllerNameParts.length; index++) {
|
|
23
|
-
if (controllerNameParts.length) {
|
|
23
|
+
if (controllerNameParts.length > (isAdmin ? 1 : 0)) {
|
|
24
24
|
// Write the ancestor controller
|
|
25
25
|
const [baseAncestorName, baseAncestorImportStatement] = baseAncestorNameAndImport(controllerNameParts, isAdmin, { forBaseController: true });
|
|
26
26
|
const baseControllerName = [...controllerNameParts, 'BaseController'].join('/');
|
|
27
27
|
const { absDirPath, absFilePath } = (0, psychicFileAndDirPaths_js_1.default)((0, psychicPath_js_1.default)('controllers'), baseControllerName + `.ts`);
|
|
28
28
|
await fs.mkdir(absDirPath, { recursive: true });
|
|
29
|
-
if (!(0,
|
|
29
|
+
if (!(0, node_fs_1.existsSync)(absFilePath)) {
|
|
30
30
|
await fs.writeFile(absFilePath, (0, generateControllerContent_js_1.default)({
|
|
31
31
|
ancestorImportStatement: baseAncestorImportStatement,
|
|
32
32
|
ancestorName: baseAncestorName,
|
|
@@ -40,7 +40,7 @@ function generateResourceControllerSpecContent({ fullyQualifiedControllerName, r
|
|
|
40
40
|
import { UpdateableProperties } from '@rvoh/dream'
|
|
41
41
|
import { PsychicServer } from '@rvoh/psychic'
|
|
42
42
|
import { specRequest as request } from '@rvoh/psychic-spec-helpers'${(0, dream_1.uniq)(importStatements).join('')}
|
|
43
|
-
import
|
|
43
|
+
import addEndUserAuthHeader from '${specUnitUpdirs}helpers/authentication.js'
|
|
44
44
|
|
|
45
45
|
describe('${fullyQualifiedControllerName}', () => {
|
|
46
46
|
let user: User
|
|
@@ -51,15 +51,15 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
51
51
|
})
|
|
52
52
|
|
|
53
53
|
describe('GET index', () => {
|
|
54
|
-
|
|
54
|
+
const subject = async (expectedStatus: number = 200) => {
|
|
55
55
|
return request.get('/${route}', expectedStatus, {
|
|
56
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
56
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
57
57
|
})
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
it('returns the index of ${fullyQualifiedModelName}s', async () => {
|
|
61
61
|
const ${modelVariableName} = await create${modelClassName}({
|
|
62
|
-
user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('
|
|
62
|
+
user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('\n ') : ''}
|
|
63
63
|
})
|
|
64
64
|
const results = (await subject()).body
|
|
65
65
|
|
|
@@ -81,15 +81,15 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
81
81
|
})
|
|
82
82
|
|
|
83
83
|
describe('GET show', () => {
|
|
84
|
-
|
|
84
|
+
const subject = async (${modelVariableName}: ${modelClassName}, expectedStatus: number = 200) => {
|
|
85
85
|
return request.get(\`/${route}/\${${modelVariableName}.id}\`, expectedStatus, {
|
|
86
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
86
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
87
87
|
})
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
it('returns the specified ${fullyQualifiedModelName}', async () => {
|
|
91
91
|
const ${modelVariableName} = await create${modelClassName}({
|
|
92
|
-
user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('
|
|
92
|
+
user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('\n ') : ''}
|
|
93
93
|
})
|
|
94
94
|
const results = (await subject(${modelVariableName})).body
|
|
95
95
|
|
|
@@ -109,16 +109,16 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
109
109
|
})
|
|
110
110
|
|
|
111
111
|
describe('POST create', () => {
|
|
112
|
-
|
|
112
|
+
const subject = async (data: UpdateableProperties<${modelClassName}>, expectedStatus: number = 201) => {
|
|
113
113
|
return request.post('/${route}', expectedStatus, {
|
|
114
114
|
data,
|
|
115
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
115
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
116
116
|
})
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
it('creates a ${fullyQualifiedModelName} for this User', async () => {
|
|
120
120
|
const results = (await subject({
|
|
121
|
-
${originalStringKeyValues.length ? originalStringKeyValues.join('
|
|
121
|
+
${originalStringKeyValues.length ? originalStringKeyValues.join('\n ') : ''}
|
|
122
122
|
})).body
|
|
123
123
|
const ${modelVariableName} = await ${modelClassName}.findOrFailBy({ userId: user.id })
|
|
124
124
|
|
|
@@ -131,19 +131,19 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
131
131
|
})
|
|
132
132
|
|
|
133
133
|
describe('PATCH update', () => {
|
|
134
|
-
|
|
134
|
+
const subject = async (${modelVariableName}: ${modelClassName}, data: UpdateableProperties<${modelClassName}>, expectedStatus: number = 204) => {
|
|
135
135
|
return request.patch(\`/${route}/\${${modelVariableName}.id}\`, expectedStatus, {
|
|
136
136
|
data,
|
|
137
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
137
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
138
138
|
})
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
it('updates the ${fullyQualifiedModelName}', async () => {
|
|
142
142
|
const ${modelVariableName} = await create${modelClassName}({
|
|
143
|
-
user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('
|
|
143
|
+
user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('\n ') : ''}
|
|
144
144
|
})
|
|
145
145
|
await subject(${modelVariableName}, {
|
|
146
|
-
${updatedStringKeyValues.length ? updatedStringKeyValues.join('
|
|
146
|
+
${updatedStringKeyValues.length ? updatedStringKeyValues.join('\n ') : ''}
|
|
147
147
|
})
|
|
148
148
|
|
|
149
149
|
await ${modelVariableName}.reload()
|
|
@@ -153,10 +153,10 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
153
153
|
context('a ${fullyQualifiedModelName} created by another User', () => {
|
|
154
154
|
it('is not updated', async () => {
|
|
155
155
|
const ${modelVariableName} = await create${modelClassName}({
|
|
156
|
-
${originalStringKeyValues.length ? originalStringKeyValues.join('
|
|
156
|
+
${originalStringKeyValues.length ? originalStringKeyValues.join('\n ') : ''}
|
|
157
157
|
})
|
|
158
158
|
await subject(${modelVariableName}, {
|
|
159
|
-
${updatedStringKeyValues.length ? updatedStringKeyValues.join('
|
|
159
|
+
${updatedStringKeyValues.length ? updatedStringKeyValues.join('\n ') : ''}
|
|
160
160
|
}, 404)
|
|
161
161
|
|
|
162
162
|
await ${modelVariableName}.reload()
|
|
@@ -166,9 +166,9 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
166
166
|
})
|
|
167
167
|
|
|
168
168
|
describe('DELETE destroy', () => {
|
|
169
|
-
|
|
169
|
+
const subject = async (${modelVariableName}: ${modelClassName}, expectedStatus: number = 204) => {
|
|
170
170
|
return request.delete(\`/${route}/\${${modelVariableName}.id}\`, expectedStatus, {
|
|
171
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
171
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
172
172
|
})
|
|
173
173
|
}
|
|
174
174
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadFile = loadFile;
|
|
4
4
|
exports.writeFile = writeFile;
|
|
5
|
-
const
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
6
|
async function loadFile(filepath) {
|
|
7
|
-
return await
|
|
7
|
+
return await node_fs_1.promises.readFile(filepath);
|
|
8
8
|
}
|
|
9
9
|
async function writeFile(filepath, contents) {
|
|
10
|
-
return await
|
|
10
|
+
return await node_fs_1.promises.writeFile(filepath, contents);
|
|
11
11
|
}
|
|
@@ -30,10 +30,8 @@ function createPsychicHttpInstance(app, sslCredentials) {
|
|
|
30
30
|
}
|
|
31
31
|
function welcomeMessage({ port }) {
|
|
32
32
|
if (!EnvInternal_js_1.default.isTest) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
dream_1.DreamCLI.logger.log(index_js_1.default.asciiLogo(), { permanent: true, logPrefix: '' });
|
|
36
|
-
spinner.stop();
|
|
33
|
+
dream_1.DreamCLI.logger.log('starting psychic server...');
|
|
34
|
+
dream_1.DreamCLI.logger.log(index_js_1.default.asciiLogo(), { logPrefix: '' });
|
|
37
35
|
dream_1.DreamCLI.logger.log(`psychic dev server started at port ${port}`);
|
|
38
36
|
}
|
|
39
37
|
}
|
|
@@ -26,9 +26,7 @@ export default class PsychicBin {
|
|
|
26
26
|
await DreamBin.sync(() => { });
|
|
27
27
|
await PsychicBin.syncTypes();
|
|
28
28
|
const psychicApp = PsychicApplication.getOrFail();
|
|
29
|
-
|
|
30
|
-
await PsychicBin.syncOpenapiJson();
|
|
31
|
-
}
|
|
29
|
+
await PsychicBin.syncOpenapiJson();
|
|
32
30
|
if (psychicApp.openapi?.syncEnumsToClient) {
|
|
33
31
|
await this.syncClientEnums();
|
|
34
32
|
}
|
|
@@ -48,29 +46,29 @@ export default class PsychicBin {
|
|
|
48
46
|
}
|
|
49
47
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
48
|
static async syncTypes(customTypes = undefined) {
|
|
51
|
-
|
|
49
|
+
DreamCLI.logger.logStartProgress(`syncing types/psychic.ts...`);
|
|
52
50
|
await TypesBuilder.sync(customTypes);
|
|
53
|
-
|
|
51
|
+
DreamCLI.logger.logEndProgress();
|
|
54
52
|
}
|
|
55
53
|
static async syncOpenapiJson() {
|
|
56
|
-
|
|
54
|
+
DreamCLI.logger.logStartProgress(`syncing openapi...`);
|
|
57
55
|
await OpenapiAppRenderer.sync();
|
|
58
|
-
|
|
56
|
+
DreamCLI.logger.logEndProgress();
|
|
59
57
|
}
|
|
60
58
|
static async syncRoutes() {
|
|
61
|
-
|
|
59
|
+
DreamCLI.logger.logStartProgress(`syncing routes...`);
|
|
62
60
|
const server = new PsychicServer();
|
|
63
61
|
await server.boot();
|
|
64
62
|
const routes = await server.routes();
|
|
65
63
|
await generateRouteTypes(routes);
|
|
66
|
-
|
|
64
|
+
DreamCLI.logger.logEndProgress();
|
|
67
65
|
}
|
|
68
66
|
static async syncClientEnums() {
|
|
69
|
-
|
|
67
|
+
DreamCLI.logger.logStartProgress(`syncing client enums...`);
|
|
70
68
|
const psychicApp = PsychicApplication.getOrFail();
|
|
71
69
|
const apiPath = path.join(psychicApp.clientRoot, psychicApp.client.apiPath);
|
|
72
70
|
const enumsStr = await enumsFileStr();
|
|
73
71
|
await fs.writeFile(`${apiPath}/enums.ts`, enumsStr);
|
|
74
|
-
|
|
72
|
+
DreamCLI.logger.logEndProgress();
|
|
75
73
|
}
|
|
76
74
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hyphenize, standardizeFullyQualifiedModelName } from '@rvoh/dream';
|
|
2
|
-
import { existsSync } from 'fs';
|
|
3
2
|
import * as fs from 'fs/promises';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
4
|
import EnvInternal from '../helpers/EnvInternal.js';
|
|
5
5
|
import psychicFileAndDirPaths from '../helpers/path/psychicFileAndDirPaths.js';
|
|
6
6
|
import psychicPath from '../helpers/path/psychicPath.js';
|
|
@@ -17,7 +17,7 @@ export default async function generateController({ fullyQualifiedControllerName,
|
|
|
17
17
|
const isAdmin = allControllerNameParts[0] === 'Admin';
|
|
18
18
|
const controllerNameParts = isAdmin ? [allControllerNameParts.shift()] : [];
|
|
19
19
|
for (let index = 0; index < allControllerNameParts.length; index++) {
|
|
20
|
-
if (controllerNameParts.length) {
|
|
20
|
+
if (controllerNameParts.length > (isAdmin ? 1 : 0)) {
|
|
21
21
|
// Write the ancestor controller
|
|
22
22
|
const [baseAncestorName, baseAncestorImportStatement] = baseAncestorNameAndImport(controllerNameParts, isAdmin, { forBaseController: true });
|
|
23
23
|
const baseControllerName = [...controllerNameParts, 'BaseController'].join('/');
|
|
@@ -37,7 +37,7 @@ export default function generateResourceControllerSpecContent({ fullyQualifiedCo
|
|
|
37
37
|
import { UpdateableProperties } from '@rvoh/dream'
|
|
38
38
|
import { PsychicServer } from '@rvoh/psychic'
|
|
39
39
|
import { specRequest as request } from '@rvoh/psychic-spec-helpers'${uniq(importStatements).join('')}
|
|
40
|
-
import
|
|
40
|
+
import addEndUserAuthHeader from '${specUnitUpdirs}helpers/authentication.js'
|
|
41
41
|
|
|
42
42
|
describe('${fullyQualifiedControllerName}', () => {
|
|
43
43
|
let user: User
|
|
@@ -48,15 +48,15 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
48
48
|
})
|
|
49
49
|
|
|
50
50
|
describe('GET index', () => {
|
|
51
|
-
|
|
51
|
+
const subject = async (expectedStatus: number = 200) => {
|
|
52
52
|
return request.get('/${route}', expectedStatus, {
|
|
53
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
53
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
54
54
|
})
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
it('returns the index of ${fullyQualifiedModelName}s', async () => {
|
|
58
58
|
const ${modelVariableName} = await create${modelClassName}({
|
|
59
|
-
user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('
|
|
59
|
+
user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('\n ') : ''}
|
|
60
60
|
})
|
|
61
61
|
const results = (await subject()).body
|
|
62
62
|
|
|
@@ -78,15 +78,15 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
78
78
|
})
|
|
79
79
|
|
|
80
80
|
describe('GET show', () => {
|
|
81
|
-
|
|
81
|
+
const subject = async (${modelVariableName}: ${modelClassName}, expectedStatus: number = 200) => {
|
|
82
82
|
return request.get(\`/${route}/\${${modelVariableName}.id}\`, expectedStatus, {
|
|
83
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
83
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
84
84
|
})
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
it('returns the specified ${fullyQualifiedModelName}', async () => {
|
|
88
88
|
const ${modelVariableName} = await create${modelClassName}({
|
|
89
|
-
user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('
|
|
89
|
+
user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('\n ') : ''}
|
|
90
90
|
})
|
|
91
91
|
const results = (await subject(${modelVariableName})).body
|
|
92
92
|
|
|
@@ -106,16 +106,16 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
106
106
|
})
|
|
107
107
|
|
|
108
108
|
describe('POST create', () => {
|
|
109
|
-
|
|
109
|
+
const subject = async (data: UpdateableProperties<${modelClassName}>, expectedStatus: number = 201) => {
|
|
110
110
|
return request.post('/${route}', expectedStatus, {
|
|
111
111
|
data,
|
|
112
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
112
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
113
113
|
})
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
it('creates a ${fullyQualifiedModelName} for this User', async () => {
|
|
117
117
|
const results = (await subject({
|
|
118
|
-
${originalStringKeyValues.length ? originalStringKeyValues.join('
|
|
118
|
+
${originalStringKeyValues.length ? originalStringKeyValues.join('\n ') : ''}
|
|
119
119
|
})).body
|
|
120
120
|
const ${modelVariableName} = await ${modelClassName}.findOrFailBy({ userId: user.id })
|
|
121
121
|
|
|
@@ -128,19 +128,19 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
128
128
|
})
|
|
129
129
|
|
|
130
130
|
describe('PATCH update', () => {
|
|
131
|
-
|
|
131
|
+
const subject = async (${modelVariableName}: ${modelClassName}, data: UpdateableProperties<${modelClassName}>, expectedStatus: number = 204) => {
|
|
132
132
|
return request.patch(\`/${route}/\${${modelVariableName}.id}\`, expectedStatus, {
|
|
133
133
|
data,
|
|
134
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
134
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
135
135
|
})
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
it('updates the ${fullyQualifiedModelName}', async () => {
|
|
139
139
|
const ${modelVariableName} = await create${modelClassName}({
|
|
140
|
-
user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('
|
|
140
|
+
user${originalStringKeyValues.length ? ',\n ' + originalStringKeyValues.join('\n ') : ''}
|
|
141
141
|
})
|
|
142
142
|
await subject(${modelVariableName}, {
|
|
143
|
-
${updatedStringKeyValues.length ? updatedStringKeyValues.join('
|
|
143
|
+
${updatedStringKeyValues.length ? updatedStringKeyValues.join('\n ') : ''}
|
|
144
144
|
})
|
|
145
145
|
|
|
146
146
|
await ${modelVariableName}.reload()
|
|
@@ -150,10 +150,10 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
150
150
|
context('a ${fullyQualifiedModelName} created by another User', () => {
|
|
151
151
|
it('is not updated', async () => {
|
|
152
152
|
const ${modelVariableName} = await create${modelClassName}({
|
|
153
|
-
${originalStringKeyValues.length ? originalStringKeyValues.join('
|
|
153
|
+
${originalStringKeyValues.length ? originalStringKeyValues.join('\n ') : ''}
|
|
154
154
|
})
|
|
155
155
|
await subject(${modelVariableName}, {
|
|
156
|
-
${updatedStringKeyValues.length ? updatedStringKeyValues.join('
|
|
156
|
+
${updatedStringKeyValues.length ? updatedStringKeyValues.join('\n ') : ''}
|
|
157
157
|
}, 404)
|
|
158
158
|
|
|
159
159
|
await ${modelVariableName}.reload()
|
|
@@ -163,9 +163,9 @@ describe('${fullyQualifiedControllerName}', () => {
|
|
|
163
163
|
})
|
|
164
164
|
|
|
165
165
|
describe('DELETE destroy', () => {
|
|
166
|
-
|
|
166
|
+
const subject = async (${modelVariableName}: ${modelClassName}, expectedStatus: number = 204) => {
|
|
167
167
|
return request.delete(\`/${route}/\${${modelVariableName}.id}\`, expectedStatus, {
|
|
168
|
-
headers: addEndUserAuthHeader(request, user, {}),
|
|
168
|
+
headers: await addEndUserAuthHeader(request, user, {}),
|
|
169
169
|
})
|
|
170
170
|
}
|
|
171
171
|
|
|
@@ -26,10 +26,8 @@ export function createPsychicHttpInstance(app, sslCredentials) {
|
|
|
26
26
|
}
|
|
27
27
|
function welcomeMessage({ port }) {
|
|
28
28
|
if (!EnvInternal.isTest) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
DreamCLI.logger.log(PsychicServer.asciiLogo(), { permanent: true, logPrefix: '' });
|
|
32
|
-
spinner.stop();
|
|
29
|
+
DreamCLI.logger.log('starting psychic server...');
|
|
30
|
+
DreamCLI.logger.log(PsychicServer.asciiLogo(), { logPrefix: '' });
|
|
33
31
|
DreamCLI.logger.log(`psychic dev server started at port ${port}`);
|
|
34
32
|
}
|
|
35
33
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@rvoh/psychic",
|
|
4
4
|
"description": "Typescript web framework",
|
|
5
|
-
"version": "0.26.
|
|
5
|
+
"version": "0.26.2",
|
|
6
6
|
"author": "RVOHealth",
|
|
7
7
|
"repository": "https://github.com/rvohealth/psychic.git",
|
|
8
8
|
"license": "MIT",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
23
|
"client": "yarn --cwd=./client start",
|
|
24
|
-
"psy": "yarn psyts",
|
|
24
|
+
"psy": "NODE_ENV=${NODE_ENV:-test} yarn psyts",
|
|
25
25
|
"psyjs": "node ./dist/test-app/src/cli/index.js",
|
|
26
26
|
"psyts": "NODE_ENV=${NODE_ENV:-test} tsx ./test-app/src/cli/index.ts",
|
|
27
27
|
"psycore": "PSYCHIC_CORE_DEVELOPMENT=1 yarn psyts",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@eslint/js": "^9.19.0",
|
|
62
62
|
"@jest-mock/express": "^3.0.0",
|
|
63
|
-
"@rvoh/dream": "^0.31.
|
|
63
|
+
"@rvoh/dream": "^0.31.3",
|
|
64
64
|
"@rvoh/dream-spec-helpers": "=0.1.0",
|
|
65
65
|
"@rvoh/psychic-spec-helpers": "=0.2.0",
|
|
66
66
|
"@types/express": "^4.17.21",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"vitest": "^3.0.8",
|
|
90
90
|
"winston": "^3.14.2"
|
|
91
91
|
},
|
|
92
|
-
"packageManager": "yarn@4.
|
|
92
|
+
"packageManager": "yarn@4.7.0"
|
|
93
93
|
}
|