Skip to content

Commit 62fd96e

Browse files
remove CORS option from server options
1 parent 6ee74d2 commit 62fd96e

File tree

12 files changed

+137
-34
lines changed

12 files changed

+137
-34
lines changed

db.json

Lines changed: 106 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,113 @@
11
{
22
"users": [
3-
{ "id": 1, "name": "John Doe", "email": "john@example.com" },
4-
{ "id": 2, "name": "Jane Smith", "email": "jane@example.com" },
5-
{ "id": 3, "name": "Bob Johnson", "email": "bob@example.com" }
3+
{
4+
"id": 1,
5+
"name": "John Doe",
6+
"email": "john@example.com"
7+
},
8+
{
9+
"id": 2,
10+
"name": "Jane Smith",
11+
"email": "jane@example.com"
12+
},
13+
{
14+
"id": 3,
15+
"name": "Bob Johnson",
16+
"email": "bob@example.com"
17+
}
618
],
719
"posts": [
8-
{ "id": 1, "title": "First Post", "userId": 1 },
9-
{ "id": 2, "title": "Second Post", "userId": 1 },
10-
{ "id": 3, "title": "Third Post", "userId": 2 }
20+
{
21+
"id": 1,
22+
"title": "First Post",
23+
"userId": 1
24+
},
25+
{
26+
"id": 2,
27+
"title": "Second Post",
28+
"userId": 1
29+
},
30+
{
31+
"id": 3,
32+
"title": "Third Post",
33+
"userId": 2
34+
}
1135
],
1236
"items": [
13-
{ "id": 1, "name": "Item 1", "value": 100 },
14-
{ "id": 2, "name": "Item 2", "value": 200 },
15-
{ "id": 3, "name": "Item 3", "value": 300 },
16-
{ "id": 4, "name": "Item 4", "value": 400 },
17-
{ "id": 5, "name": "Item 5", "value": 500 },
18-
{ "id": 6, "name": "Item 6", "value": 600 },
19-
{ "id": 7, "name": "Item 7", "value": 700 },
20-
{ "id": 8, "name": "Item 8", "value": 800 },
21-
{ "id": 9, "name": "Item 9", "value": 900 },
22-
{ "id": 10, "name": "Item 10", "value": 1000 },
23-
{ "id": 11, "name": "Item 11", "value": 1100 },
24-
{ "id": 12, "name": "Item 12", "value": 1200 },
25-
{ "id": 13, "name": "Item 13", "value": 1300 },
26-
{ "id": 14, "name": "Item 14", "value": 1400 },
27-
{ "id": 15, "name": "Item 15", "value": 1500 }
37+
{
38+
"id": 1,
39+
"name": "Item 1",
40+
"value": 100
41+
},
42+
{
43+
"id": 2,
44+
"name": "Item 2",
45+
"value": 200
46+
},
47+
{
48+
"id": 3,
49+
"name": "Item 3",
50+
"value": 300
51+
},
52+
{
53+
"id": 4,
54+
"name": "Item 4",
55+
"value": 400
56+
},
57+
{
58+
"id": 5,
59+
"name": "Item 5",
60+
"value": 500
61+
},
62+
{
63+
"id": 6,
64+
"name": "Item 6",
65+
"value": 600
66+
},
67+
{
68+
"id": 7,
69+
"name": "Item 7",
70+
"value": 700
71+
},
72+
{
73+
"id": 8,
74+
"name": "Item 8",
75+
"value": 800
76+
},
77+
{
78+
"id": 9,
79+
"name": "Item 9",
80+
"value": 900
81+
},
82+
{
83+
"id": 10,
84+
"name": "Item 10",
85+
"value": 1000
86+
},
87+
{
88+
"id": 11,
89+
"name": "Item 11",
90+
"value": 1100
91+
},
92+
{
93+
"id": 12,
94+
"name": "Item 12",
95+
"value": 1200
96+
},
97+
{
98+
"id": 13,
99+
"name": "Item 13",
100+
"value": 1300
101+
},
102+
{
103+
"id": 14,
104+
"name": "Item 14",
105+
"value": 1400
106+
},
107+
{
108+
"id": 15,
109+
"name": "Item 15",
110+
"value": 1500
111+
}
28112
]
29-
}
113+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@webmasterdevlin/json-server",
3-
"version": "1.3.4",
3+
"version": "1.3.5",
44
"description": "A TypeScript implementation of json-server with additional features",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/bin/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ async function main(): Promise<void> {
214214
const options: ServerOptions = {
215215
port: cliArgs.port || DEFAULT_PORT,
216216
host: cliArgs.host || DEFAULT_HOST,
217-
cors: !(cliArgs['no-cors'] || false),
218217
static: cliArgs.static || [],
219218
middlewares: [],
220219
bodyParser: true,

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export function create(options: Partial<ServerOptions> = {}): JsonServer {
6262
const serverOptions: ServerOptions = {
6363
port: options.port || 3000,
6464
host: options.host || '0.0.0.0', // Changed from 'localhost' to '0.0.0.0' to allow external connections
65-
cors: options.cors !== undefined ? options.cors : true,
6665
static: options.static || [],
6766
middlewares: options.middlewares || [],
6867
bodyParser: options.bodyParser !== undefined ? options.bodyParser : true,

src/types/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ export interface ServerOptions {
1111
/** Host address to bind the server to */
1212
host: string;
1313

14-
/** Whether to enable CORS */
15-
cors: boolean;
16-
1714
/** Path(s) to static files to serve */
1815
static: string | string[];
1916

test-db.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,36 @@
135135
"userId": "1",
136136
"content": "This is a test post",
137137
"id": "1768976793834"
138+
},
139+
{
140+
"title": "Test Post",
141+
"userId": "1",
142+
"content": "This is a test post",
143+
"id": "1768978735818"
144+
},
145+
{
146+
"title": "Test Post",
147+
"userId": "1",
148+
"content": "This is a test post",
149+
"id": "1768978748578"
150+
},
151+
{
152+
"title": "Test Post",
153+
"userId": "1",
154+
"content": "This is a test post",
155+
"id": "1768978857498"
156+
},
157+
{
158+
"title": "Test Post",
159+
"userId": "1",
160+
"content": "This is a test post",
161+
"id": "1768978892285"
162+
},
163+
{
164+
"title": "Test Post",
165+
"userId": "1",
166+
"content": "This is a test post",
167+
"id": "1768978979576"
138168
}
139169
],
140170
"comments": [

test/custom-routes.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ describe('Custom Routes Tests', () => {
3636
const options: ServerOptions = {
3737
port: 3458,
3838
host: 'localhost',
39-
cors: true,
4039
static: [],
4140
middlewares: [],
4241
bodyParser: true,

test/pagination.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ describe('Pagination Tests', () => {
2929
const options: ServerOptions = {
3030
port: 3000,
3131
host: 'localhost',
32-
cors: true,
3332
static: [],
3433
middlewares: [],
3534
bodyParser: true,

test/readonly-mode.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ describe('Read-Only Mode Tests', () => {
2222
const options: ServerOptions = {
2323
port: 3457,
2424
host: 'localhost',
25-
cors: true,
2625
static: [],
2726
middlewares: [],
2827
bodyParser: true,

test/rest-api.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ describe('REST API Integration Tests', () => {
3333
const options: ServerOptions = {
3434
port: 3456,
3535
host: 'localhost',
36-
cors: true,
3736
static: [],
3837
middlewares: [],
3938
bodyParser: true,

0 commit comments

Comments
 (0)