typescript-mock-server 1.0.6 → 1.0.8

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
@@ -91,6 +91,8 @@ Following dependencies are being used:
91
91
 
92
92
 
93
93
  ## Release notes (will be moved to GitHub in the future)
94
+ - v1.0.8 - Minor bugfixes
95
+ - v1.0.7 - Minor bugfixes
94
96
  - v1.0.6 - Bugfix: accidentally included "npm" and "install" dependency, removed again
95
97
  - v1.0.5 - Set $INIT_CWD to support all platforms and add CORS option
96
98
  - v1.0.3 - Updated README to include delay interval example
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "typescript-mock-server",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
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=5000 --cors=http://localhost:5000",
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.12",
34
- "prettier": "^2.6.2"
33
+ "@types/cors": "^2.8.17",
34
+ "prettier": "^3.3.3"
35
35
  },
36
36
  "dependencies": {
37
- "@types/express": "^4.17.13",
38
- "@types/node": "^18.0.5",
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": "^4.7.4"
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,9 @@ 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
- .replace('-', '');
97
+ .replace(`${httpVerb}-`, '')
98
+ .replace(httpVerb, '');
99
+
98
100
  if (endpoint.endsWith('/')) {
99
101
  return endpoint.substring(0, endpoint.length - 1);
100
102
  }
@@ -0,0 +1,3 @@
1
+ export const data = {
2
+ id: 'test1'
3
+ }
@@ -0,0 +1,3 @@
1
+ export const data = {
2
+ id: 'test1'
3
+ }
@@ -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
+ }