typescript-mock-server 1.11.2 → 1.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -99,6 +99,9 @@ Following dependencies are being used:
|
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
## Release notes (will be moved to GitHub in the future)
|
|
102
|
+
- v1.11.4 - Fixed "models not found" error when running as a dependency by removing incorrect path mapping for compiled models and relying on ts-node for raw TypeScript files.
|
|
103
|
+
- v1.11.3 - Fixed module resolution when used as a dependency by explicitly adding ts-node as a dependency and improving its configuration at runtime.
|
|
104
|
+
- v1.11.1 - Added binary support to the package, allowing it to be executed as a command-line tool when installed as a dependency.
|
|
102
105
|
- v1.11.0 - Support dynamic responses via request/response context, added comprehensive tests, and switched to a faster build-and-serve workflow
|
|
103
106
|
- v1.10.0 - Improved path resolution and library usage support
|
|
104
107
|
- v1.0.8 - Minor bugfixes
|
|
@@ -78,7 +78,15 @@ class TypescriptMockServerImpl {
|
|
|
78
78
|
static loadModule(moduleName) {
|
|
79
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
80
|
if (moduleName.endsWith('.ts')) {
|
|
81
|
-
require('ts-node').register({
|
|
81
|
+
require('ts-node').register({
|
|
82
|
+
transpileOnly: true,
|
|
83
|
+
compilerOptions: {
|
|
84
|
+
module: 'commonjs',
|
|
85
|
+
allowJs: true,
|
|
86
|
+
esModuleInterop: true,
|
|
87
|
+
resolveJsonModule: true
|
|
88
|
+
}
|
|
89
|
+
});
|
|
82
90
|
}
|
|
83
91
|
return yield Promise.resolve(`${moduleName}`).then(s => __importStar(require(s)));
|
|
84
92
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-mock-server",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.4",
|
|
4
4
|
"description": "Simple mock server that can be used in front end development. Instead of creating json files you can just publish TypeScript objects as json",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@types/node": "^24.10.1",
|
|
44
44
|
"cors": "^2.8.5",
|
|
45
45
|
"express": "^5.1.0",
|
|
46
|
+
"ts-node": "^10.9.2",
|
|
46
47
|
"tslog": "^3.3.3",
|
|
47
48
|
"typescript": "^5.9.3",
|
|
48
49
|
"ts-node-dev": "2.0.0"
|
|
@@ -33,7 +33,15 @@ export class TypescriptMockServerImpl implements TypescriptMockServer{
|
|
|
33
33
|
|
|
34
34
|
private static async loadModule(moduleName: string) {
|
|
35
35
|
if (moduleName.endsWith('.ts')) {
|
|
36
|
-
require('ts-node').register({
|
|
36
|
+
require('ts-node').register({
|
|
37
|
+
transpileOnly: true,
|
|
38
|
+
compilerOptions: {
|
|
39
|
+
module: 'commonjs',
|
|
40
|
+
allowJs: true,
|
|
41
|
+
esModuleInterop: true,
|
|
42
|
+
resolveJsonModule: true
|
|
43
|
+
}
|
|
44
|
+
});
|
|
37
45
|
}
|
|
38
46
|
return await import(moduleName);
|
|
39
47
|
}
|
|
@@ -113,18 +121,6 @@ export class TypescriptMockServerImpl implements TypescriptMockServer{
|
|
|
113
121
|
let modulePath = `${dirPath}/${dirent.name}`;
|
|
114
122
|
this.registeredEndpoints.push({ httpVerb, endpoint });
|
|
115
123
|
|
|
116
|
-
if (__filename.endsWith('.js') && modulePath.endsWith('.ts')) {
|
|
117
|
-
const distPath = path.join(process.cwd(), 'dist');
|
|
118
|
-
const potentialJsPath = modulePath
|
|
119
|
-
.replace(process.cwd(), distPath)
|
|
120
|
-
.replace(/\.ts$/, '.js');
|
|
121
|
-
|
|
122
|
-
const fs = require('fs');
|
|
123
|
-
if (fs.existsSync(potentialJsPath)) {
|
|
124
|
-
modulePath = potentialJsPath;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
124
|
await TypescriptMockServerImpl.loadModule(modulePath)
|
|
129
125
|
.then(model => this.addEndpoint(endpoint, httpVerb, model))
|
|
130
126
|
.catch(error => this.log.error(error));
|