typescript-mock-server 1.0.6 → 1.0.7
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/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-mock-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
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
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
7
|
-
"example": "ts-node-dev src/index.ts --path=$INIT_CWD/tms-models --port=
|
|
7
|
+
"example": "ts-node-dev src/index.ts --path=$INIT_CWD/tms-models --port=5200 --cors=http://localhost:5200",
|
|
8
8
|
"start": "ts-node-dev src/index.ts",
|
|
9
9
|
"update-deps": "npm update",
|
|
10
10
|
"get-version": "echo $npm_package_version",
|
|
@@ -30,17 +30,17 @@
|
|
|
30
30
|
"url": "https://genydev.nl"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/cors": "^2.8.
|
|
34
|
-
"prettier": "^
|
|
33
|
+
"@types/cors": "^2.8.17",
|
|
34
|
+
"prettier": "^3.3.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@types/express": "^4.17.
|
|
38
|
-
"@types/node": "^
|
|
37
|
+
"@types/express": "^4.17.21",
|
|
38
|
+
"@types/node": "^22.5.4",
|
|
39
39
|
"cors": "^2.8.5",
|
|
40
40
|
"express": "^4.18.1",
|
|
41
41
|
"ts-node-dev": "2.0.0",
|
|
42
42
|
"tslog": "^3.3.3",
|
|
43
|
-
"typescript": "^
|
|
43
|
+
"typescript": "^5.5.4"
|
|
44
44
|
},
|
|
45
45
|
"prettier": {
|
|
46
46
|
"arrowParens": "avoid",
|
|
@@ -52,6 +52,7 @@ export class TypescriptMockServerImpl implements TypescriptMockServer{
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
this.registeredEndpoints.forEach(endpoint => this.log.info(`${endpoint.httpVerb.toUpperCase()} http://localhost:${this.commandLine.getCommand(Command.PORT)}${endpoint.endpoint}`));
|
|
55
|
+
this.registeredEndpoints = [];
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
private handleFile(path: string, dirent: Dirent) {
|
|
@@ -93,8 +94,12 @@ export class TypescriptMockServerImpl implements TypescriptMockServer{
|
|
|
93
94
|
private convertFileNameToEndpoint(path: string, dirent: Dirent, httpVerb: HttpVerb): string {
|
|
94
95
|
const endpoint = `${path.replace(this.basePath, '')}/${dirent.name}`
|
|
95
96
|
.replace('.ts', '')
|
|
96
|
-
.replace(httpVerb, '')
|
|
97
|
-
|
|
97
|
+
.replace(httpVerb, '');
|
|
98
|
+
|
|
99
|
+
if (!endpoint.endsWith('/')) {
|
|
100
|
+
return endpoint.replace('-', '');
|
|
101
|
+
}
|
|
102
|
+
|
|
98
103
|
if (endpoint.endsWith('/')) {
|
|
99
104
|
return endpoint.substring(0, endpoint.length - 1);
|
|
100
105
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RequestConfig } from '../../src/models/config';
|
|
2
|
+
|
|
3
|
+
export interface User {
|
|
4
|
+
id: number;
|
|
5
|
+
firstName: string;
|
|
6
|
+
lastName: string;
|
|
7
|
+
creationDate: Date;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const newDate = () => new Date();
|
|
11
|
+
|
|
12
|
+
export const data: User[] = [{
|
|
13
|
+
id: 1,
|
|
14
|
+
firstName: 'Guy',
|
|
15
|
+
lastName: 'Theuws',
|
|
16
|
+
creationDate: newDate()
|
|
17
|
+
}, {
|
|
18
|
+
id: 2,
|
|
19
|
+
firstName: 'Generation Y',
|
|
20
|
+
lastName: 'Development',
|
|
21
|
+
creationDate: newDate()
|
|
22
|
+
}];
|
|
23
|
+
|
|
24
|
+
export const config: RequestConfig = {
|
|
25
|
+
delay: 2000,
|
|
26
|
+
statusCode: 418
|
|
27
|
+
}
|