@forklaunch/express 0.1.0 → 0.1.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.
Files changed (56) hide show
  1. package/lib/eslint.config.d.mts +3 -0
  2. package/lib/eslint.config.d.mts.map +1 -0
  3. package/lib/eslint.config.mjs +10 -0
  4. package/lib/index.d.ts +22 -0
  5. package/lib/index.d.ts.map +1 -0
  6. package/lib/index.js +25 -0
  7. package/lib/jest.config.d.ts +4 -0
  8. package/lib/jest.config.d.ts.map +1 -0
  9. package/lib/jest.config.js +19 -0
  10. package/lib/src/expressApplication.d.ts +37 -0
  11. package/lib/src/expressApplication.d.ts.map +1 -0
  12. package/lib/src/expressApplication.js +60 -0
  13. package/lib/src/expressRouter.d.ts +46 -0
  14. package/lib/src/expressRouter.d.ts.map +1 -0
  15. package/lib/src/expressRouter.js +91 -0
  16. package/lib/src/middleware/async.middleware.d.ts +16 -0
  17. package/lib/src/middleware/async.middleware.d.ts.map +1 -0
  18. package/{dist → lib/src}/middleware/async.middleware.js +5 -11
  19. package/{dist → lib/src}/middleware/response.middleware.d.ts +5 -2
  20. package/lib/src/middleware/response.middleware.d.ts.map +1 -0
  21. package/{dist → lib/src}/middleware/response.middleware.js +20 -22
  22. package/lib/src/types/express.types.d.ts +28 -0
  23. package/lib/src/types/express.types.d.ts.map +1 -0
  24. package/lib/tests/typebox.forklaunch.express.test.d.ts +2 -0
  25. package/lib/tests/typebox.forklaunch.express.test.d.ts.map +1 -0
  26. package/{tests/typebox.forklaunch.express.test.ts → lib/tests/typebox.forklaunch.express.test.js} +11 -36
  27. package/lib/tests/zod.forklaunch.express.test.d.ts +2 -0
  28. package/lib/tests/zod.forklaunch.express.test.d.ts.map +1 -0
  29. package/{tests/zod.forklaunch.express.test.ts → lib/tests/zod.forklaunch.express.test.js} +16 -41
  30. package/lib/tsconfig.tsbuildinfo +1 -0
  31. package/lib/vitest.config.d.ts +3 -0
  32. package/lib/vitest.config.d.ts.map +1 -0
  33. package/lib/vitest.config.js +7 -0
  34. package/package.json +22 -9
  35. package/.prettierignore +0 -2
  36. package/.prettierrc +0 -7
  37. package/dist/forklaunch.express.d.ts +0 -198
  38. package/dist/forklaunch.express.js +0 -375
  39. package/dist/forklaunch.express.js.map +0 -1
  40. package/dist/jest.config.d.ts +0 -3
  41. package/dist/jest.config.js.map +0 -1
  42. package/dist/middleware/async.middleware.d.ts +0 -18
  43. package/dist/middleware/async.middleware.js.map +0 -1
  44. package/dist/middleware/response.middleware.js.map +0 -1
  45. package/dist/tests/typebox.forklaunch.express.test.js +0 -141
  46. package/dist/tests/typebox.forklaunch.express.test.js.map +0 -1
  47. package/dist/tests/zod.forklaunch.express.test.d.ts +0 -1
  48. package/dist/tests/zod.forklaunch.express.test.js +0 -141
  49. package/dist/tests/zod.forklaunch.express.test.js.map +0 -1
  50. package/dist/types/forklaunch.express.types.d.ts +0 -53
  51. package/dist/types/forklaunch.express.types.js +0 -3
  52. package/dist/types/forklaunch.express.types.js.map +0 -1
  53. package/eslint.config.mjs +0 -12
  54. package/forklaunch.express.ts +0 -617
  55. package/jest.config.ts +0 -10
  56. /package/{dist/tests/typebox.forklaunch.express.test.d.ts → lib/src/types/express.types.js} +0 -0
@@ -1,29 +1,22 @@
1
- import { TypeboxSchemaValidator, string } from "@forklaunch/validator/typebox";
2
- import { killPortProcess } from "kill-port-process";
3
- import forklaunchExpress, { Application, Router, forklaunchRouter } from "../forklaunch.express";
4
-
5
- const typeboxSchemaValidator = new TypeboxSchemaValidator();
6
-
1
+ import { SchemaValidator, string } from '@forklaunch/validator/typebox';
2
+ import { forklaunchExpress, forklaunchRouter } from '../index';
3
+ const typeboxSchemaValidator = SchemaValidator();
7
4
  describe('Forklaunch Express Tests', () => {
8
- let forklaunchApplication: Application<TypeboxSchemaValidator>;
9
- let forklaunchRouterInstance: Router<TypeboxSchemaValidator>;
10
-
5
+ let forklaunchApplication;
6
+ let forklaunchRouterInstance;
7
+ let server;
11
8
  beforeAll(async () => {
12
- await killPortProcess(6934);
13
-
14
9
  forklaunchApplication = forklaunchExpress(typeboxSchemaValidator);
15
10
  forklaunchRouterInstance = forklaunchRouter('/testpath', typeboxSchemaValidator);
16
-
17
11
  forklaunchRouterInstance.get('/test', {
18
12
  name: 'Test',
19
13
  summary: 'Test Summary',
20
14
  responses: {
21
15
  200: string
22
16
  }
23
- }, (req, res) => {
17
+ }, (_req, res) => {
24
18
  res.status(200).send('Hello World');
25
19
  });
26
-
27
20
  forklaunchRouterInstance.post('/test', {
28
21
  name: 'Test',
29
22
  summary: 'Test Summary',
@@ -36,7 +29,6 @@ describe('Forklaunch Express Tests', () => {
36
29
  }, (req, res) => {
37
30
  res.status(200).send(req.body.test);
38
31
  });
39
-
40
32
  forklaunchRouterInstance.put('/test', {
41
33
  name: 'Test',
42
34
  summary: 'Test Summary',
@@ -49,7 +41,6 @@ describe('Forklaunch Express Tests', () => {
49
41
  }, (req, res) => {
50
42
  res.status(200).send(req.body.test);
51
43
  });
52
-
53
44
  forklaunchRouterInstance.patch('/test', {
54
45
  name: 'Test',
55
46
  summary: 'Test Summary',
@@ -62,76 +53,60 @@ describe('Forklaunch Express Tests', () => {
62
53
  }, (req, res) => {
63
54
  res.status(200).send(req.body.test);
64
55
  });
65
-
66
56
  forklaunchRouterInstance.delete('/test', {
67
57
  name: 'Test',
68
58
  summary: 'Test Summary',
69
59
  responses: {
70
60
  200: string
71
61
  }
72
- }, (req, res) => {
62
+ }, (_req, res) => {
73
63
  res.status(200).send('Hello World');
74
64
  });
75
-
76
65
  forklaunchApplication.use(forklaunchRouterInstance);
77
-
78
- await forklaunchApplication.listen(6934, () => {
79
- console.log('Server started');
80
- });
66
+ server = await forklaunchApplication.listen(6934, () => { });
81
67
  });
82
-
83
68
  test('Get', async () => {
84
69
  const testGet = await fetch('http://localhost:6934/testpath/test', {
85
70
  method: 'GET'
86
71
  });
87
-
88
72
  expect(testGet.status).toBe(200);
89
73
  expect(await testGet.text()).toBe('Hello World');
90
74
  });
91
-
92
75
  test('Post', async () => {
93
76
  const testPost = await fetch('http://localhost:6934/testpath/test', {
94
77
  method: 'POST',
95
78
  body: JSON.stringify({ test: 'Hello World' }),
96
79
  headers: { 'Content-Type': 'application/json' }
97
80
  });
98
-
99
81
  expect(testPost.status).toBe(200);
100
82
  expect(await testPost.text()).toBe('Hello World');
101
83
  });
102
-
103
84
  test('Put', async () => {
104
85
  const testPut = await fetch('http://localhost:6934/testpath/test', {
105
86
  method: 'PUT',
106
87
  body: JSON.stringify({ test: 'Hello World' }),
107
88
  headers: { 'Content-Type': 'application/json' }
108
89
  });
109
-
110
90
  expect(testPut.status).toBe(200);
111
91
  expect(await testPut.text()).toBe('Hello World');
112
92
  });
113
-
114
93
  test('Patch', async () => {
115
94
  const testPatch = await fetch('http://localhost:6934/testpath/test', {
116
95
  method: 'PATCH',
117
96
  body: JSON.stringify({ test: 'Hello World' }),
118
97
  headers: { 'Content-Type': 'application/json' }
119
98
  });
120
-
121
99
  expect(testPatch.status).toBe(200);
122
100
  expect(await testPatch.text()).toBe('Hello World');
123
101
  });
124
-
125
102
  test('Delete', async () => {
126
103
  const testDelete = await fetch('http://localhost:6934/testpath/test', {
127
104
  method: 'DELETE'
128
105
  });
129
-
130
106
  expect(testDelete.status).toBe(200);
131
107
  expect(await testDelete.text()).toBe('Hello World');
132
108
  });
133
-
134
109
  afterAll(async () => {
135
- setTimeout(async () => await killPortProcess(6934), 500);
110
+ server.close();
136
111
  });
137
- });
112
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=zod.forklaunch.express.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod.forklaunch.express.test.d.ts","sourceRoot":"","sources":["../../tests/zod.forklaunch.express.test.ts"],"names":[],"mappings":""}
@@ -1,29 +1,22 @@
1
- import { ZodSchemaValidator, string } from "@forklaunch/validator/zod";
2
- import { killPortProcess } from "kill-port-process";
3
- import forklaunchExpress, { Application, Router, forklaunchRouter } from "../forklaunch.express";
4
-
5
- const zodSchemaValidator = new ZodSchemaValidator();
6
-
1
+ import { SchemaValidator, string } from '@forklaunch/validator/zod';
2
+ import { forklaunchExpress, forklaunchRouter } from '../index';
3
+ const zodSchemaValidator = SchemaValidator();
7
4
  describe('Forklaunch Express Tests', () => {
8
- let forklaunchApplication: Application<ZodSchemaValidator>;
9
- let forklaunchRouterInstance: Router<ZodSchemaValidator>;
10
-
5
+ let forklaunchApplication;
6
+ let forklaunchRouterInstance;
7
+ let server;
11
8
  beforeAll(async () => {
12
- await killPortProcess(6935);
13
-
14
9
  forklaunchApplication = forklaunchExpress(zodSchemaValidator);
15
10
  forklaunchRouterInstance = forklaunchRouter('/testpath', zodSchemaValidator);
16
-
17
11
  forklaunchRouterInstance.get('/test', {
18
12
  name: 'Test',
19
13
  summary: 'Test Summary',
20
14
  responses: {
21
15
  200: string
22
16
  }
23
- }, (req, res) => {
17
+ }, (_req, res) => {
24
18
  res.status(200).send('Hello World');
25
19
  });
26
-
27
20
  forklaunchRouterInstance.post('/test', {
28
21
  name: 'Test',
29
22
  summary: 'Test Summary',
@@ -36,7 +29,6 @@ describe('Forklaunch Express Tests', () => {
36
29
  }, (req, res) => {
37
30
  res.status(200).send(req.body.test);
38
31
  });
39
-
40
32
  forklaunchRouterInstance.put('/test', {
41
33
  name: 'Test',
42
34
  summary: 'Test Summary',
@@ -49,7 +41,6 @@ describe('Forklaunch Express Tests', () => {
49
41
  }, (req, res) => {
50
42
  res.status(200).send(req.body.test);
51
43
  });
52
-
53
44
  forklaunchRouterInstance.patch('/test', {
54
45
  name: 'Test',
55
46
  summary: 'Test Summary',
@@ -62,76 +53,60 @@ describe('Forklaunch Express Tests', () => {
62
53
  }, (req, res) => {
63
54
  res.status(200).send(req.body.test);
64
55
  });
65
-
66
56
  forklaunchRouterInstance.delete('/test', {
67
57
  name: 'Test',
68
58
  summary: 'Test Summary',
69
59
  responses: {
70
60
  200: string
71
61
  }
72
- }, (req, res) => {
62
+ }, (_req, res) => {
73
63
  res.status(200).send('Hello World');
74
64
  });
75
-
76
65
  forklaunchApplication.use(forklaunchRouterInstance);
77
-
78
- await forklaunchApplication.listen(6935, () => {
79
- console.log('Server started');
80
- });
66
+ server = await forklaunchApplication.listen(6935, () => { });
81
67
  });
82
-
83
68
  test('Get', async () => {
84
- const testGet = await fetch('http://localhost:6934/testpath/test', {
69
+ const testGet = await fetch('http://localhost:6935/testpath/test', {
85
70
  method: 'GET'
86
71
  });
87
-
88
72
  expect(testGet.status).toBe(200);
89
73
  expect(await testGet.text()).toBe('Hello World');
90
74
  });
91
-
92
75
  test('Post', async () => {
93
- const testPost = await fetch('http://localhost:6934/testpath/test', {
76
+ const testPost = await fetch('http://localhost:6935/testpath/test', {
94
77
  method: 'POST',
95
78
  body: JSON.stringify({ test: 'Hello World' }),
96
79
  headers: { 'Content-Type': 'application/json' }
97
80
  });
98
-
99
81
  expect(testPost.status).toBe(200);
100
82
  expect(await testPost.text()).toBe('Hello World');
101
83
  });
102
-
103
84
  test('Put', async () => {
104
- const testPut = await fetch('http://localhost:6934/testpath/test', {
85
+ const testPut = await fetch('http://localhost:6935/testpath/test', {
105
86
  method: 'PUT',
106
87
  body: JSON.stringify({ test: 'Hello World' }),
107
88
  headers: { 'Content-Type': 'application/json' }
108
89
  });
109
-
110
90
  expect(testPut.status).toBe(200);
111
91
  expect(await testPut.text()).toBe('Hello World');
112
92
  });
113
-
114
93
  test('Patch', async () => {
115
- const testPatch = await fetch('http://localhost:6934/testpath/test', {
94
+ const testPatch = await fetch('http://localhost:6935/testpath/test', {
116
95
  method: 'PATCH',
117
96
  body: JSON.stringify({ test: 'Hello World' }),
118
97
  headers: { 'Content-Type': 'application/json' }
119
98
  });
120
-
121
99
  expect(testPatch.status).toBe(200);
122
100
  expect(await testPatch.text()).toBe('Hello World');
123
101
  });
124
-
125
102
  test('Delete', async () => {
126
- const testDelete = await fetch('http://localhost:6934/testpath/test', {
103
+ const testDelete = await fetch('http://localhost:6935/testpath/test', {
127
104
  method: 'DELETE'
128
105
  });
129
-
130
106
  expect(testDelete.status).toBe(200);
131
107
  expect(await testDelete.text()).toBe('Hello World');
132
108
  });
133
-
134
109
  afterAll(async () => {
135
- setTimeout(async () => await killPortProcess(6935), 500);
110
+ server.close();
136
111
  });
137
- });
112
+ });