rest_api_faker 0.0.4 → 0.0.6-alpha
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 +30 -2
- package/bin/rest_api_faker.js +1 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +354 -1825
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +20 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +133 -0
- package/dist/config.js.map +1 -0
- package/dist/database.d.ts +29 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +216 -0
- package/dist/database.js.map +1 -0
- package/dist/index.d.ts +6 -7
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -46
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +4 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +42 -0
- package/dist/loader.js.map +1 -0
- package/dist/logger.d.ts +14 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +61 -0
- package/dist/logger.js.map +1 -0
- package/dist/query.d.ts +19 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +289 -0
- package/dist/query.js.map +1 -0
- package/dist/relationships.d.ts +10 -0
- package/dist/relationships.d.ts.map +1 -0
- package/dist/relationships.js +95 -0
- package/dist/relationships.js.map +1 -0
- package/dist/rewriter.d.ts +5 -0
- package/dist/rewriter.d.ts.map +1 -0
- package/dist/rewriter.js +135 -0
- package/dist/rewriter.js.map +1 -0
- package/dist/router.d.ts +9 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +275 -0
- package/dist/router.js.map +1 -0
- package/dist/server.d.ts +17 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +90 -0
- package/dist/server.js.map +1 -0
- package/dist/static.d.ts +8 -0
- package/dist/static.d.ts.map +1 -0
- package/dist/static.js +148 -0
- package/dist/static.js.map +1 -0
- package/package.json +13 -14
package/dist/router.js
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import { logger } from './logger.js';
|
|
3
|
+
import { parseQuery, applyQuery, generateLinkHeader } from './query.js';
|
|
4
|
+
import { parseRelationships, applyRelationships, getForeignKey } from './relationships.js';
|
|
5
|
+
function getParam(req, name) {
|
|
6
|
+
const value = req.params[name];
|
|
7
|
+
if (value === undefined) {
|
|
8
|
+
throw new Error(`Route parameter '${name}' is missing`);
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
export function createRouter(db, options = {}) {
|
|
13
|
+
const router = Router();
|
|
14
|
+
const readOnly = options.readOnly || false;
|
|
15
|
+
const idField = options.idField || 'id';
|
|
16
|
+
const foreignKeySuffix = options.foreignKeySuffix || 'Id';
|
|
17
|
+
const validateContentType = (req, _res, next) => {
|
|
18
|
+
const contentType = req.get('Content-Type');
|
|
19
|
+
if (!contentType || !contentType.includes('application/json')) {
|
|
20
|
+
logger.warn('Content-Type should be application/json');
|
|
21
|
+
}
|
|
22
|
+
next();
|
|
23
|
+
};
|
|
24
|
+
router.get('/db', (_req, res) => {
|
|
25
|
+
res.json(db.getData());
|
|
26
|
+
});
|
|
27
|
+
router.get('/:resource', (req, res) => {
|
|
28
|
+
const resource = getParam(req, 'resource');
|
|
29
|
+
const data = db.getCollection(resource);
|
|
30
|
+
if (data === undefined) {
|
|
31
|
+
res.status(404).json({ error: `Resource '${resource}' not found` });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(data)) {
|
|
35
|
+
const queryOptions = parseQuery(req);
|
|
36
|
+
const { data: filtered, total } = applyQuery(data, queryOptions);
|
|
37
|
+
const { embed, expand } = parseRelationships(req.query);
|
|
38
|
+
const withRelationships = applyRelationships(filtered, resource, embed, expand, db, idField, foreignKeySuffix);
|
|
39
|
+
res.set('X-Total-Count', String(total));
|
|
40
|
+
if (queryOptions.page !== undefined && queryOptions.limit !== undefined) {
|
|
41
|
+
const linkHeader = generateLinkHeader(req, queryOptions.page, queryOptions.limit, total);
|
|
42
|
+
res.set('Link', linkHeader);
|
|
43
|
+
}
|
|
44
|
+
res.json(withRelationships);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
res.json(data);
|
|
48
|
+
});
|
|
49
|
+
router.get('/:resource/:id', (req, res) => {
|
|
50
|
+
const resource = getParam(req, 'resource');
|
|
51
|
+
const id = getParam(req, 'id');
|
|
52
|
+
if (!db.isCollection(resource)) {
|
|
53
|
+
res.status(404).json({ error: `Collection '${resource}' not found` });
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const item = db.getById(resource, id);
|
|
57
|
+
if (!item) {
|
|
58
|
+
res.status(404).json({ error: `Item with id '${id}' not found in '${resource}'` });
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const { embed, expand } = parseRelationships(req.query);
|
|
62
|
+
if (embed.length > 0 || expand.length > 0) {
|
|
63
|
+
const withRelationships = applyRelationships([item], resource, embed, expand, db, idField, foreignKeySuffix);
|
|
64
|
+
res.json(withRelationships[0]);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
res.json(item);
|
|
68
|
+
});
|
|
69
|
+
router.get('/:parent/:parentId/:children', (req, res) => {
|
|
70
|
+
const parent = getParam(req, 'parent');
|
|
71
|
+
const parentId = getParam(req, 'parentId');
|
|
72
|
+
const children = getParam(req, 'children');
|
|
73
|
+
if (!db.isCollection(parent)) {
|
|
74
|
+
res.status(404).json({ error: `Collection '${parent}' not found` });
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const parentItem = db.getById(parent, parentId);
|
|
78
|
+
if (!parentItem) {
|
|
79
|
+
res.status(404).json({ error: `Parent item with id '${parentId}' not found in '${parent}'` });
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const childrenData = db.getCollection(children);
|
|
83
|
+
if (!Array.isArray(childrenData)) {
|
|
84
|
+
res.status(404).json({ error: `Collection '${children}' not found` });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const foreignKey = getForeignKey(parent, foreignKeySuffix);
|
|
88
|
+
const filtered = childrenData.filter((child) => {
|
|
89
|
+
if (typeof child !== 'object' || child === null)
|
|
90
|
+
return false;
|
|
91
|
+
const childFk = child[foreignKey];
|
|
92
|
+
return (childFk === parentId ||
|
|
93
|
+
(typeof childFk === 'number' || typeof childFk === 'string'
|
|
94
|
+
? String(childFk) === parentId
|
|
95
|
+
: false));
|
|
96
|
+
});
|
|
97
|
+
const queryOptions = parseQuery(req);
|
|
98
|
+
const { data: result, total } = applyQuery(filtered, queryOptions);
|
|
99
|
+
res.set('X-Total-Count', String(total));
|
|
100
|
+
res.json(result);
|
|
101
|
+
});
|
|
102
|
+
router.post('/:parent/:parentId/:children', validateContentType, async (req, res) => {
|
|
103
|
+
if (readOnly) {
|
|
104
|
+
return res.status(403).json({ error: 'Read-only mode enabled' });
|
|
105
|
+
}
|
|
106
|
+
const parent = getParam(req, 'parent');
|
|
107
|
+
const parentId = getParam(req, 'parentId');
|
|
108
|
+
const children = getParam(req, 'children');
|
|
109
|
+
const data = req.body;
|
|
110
|
+
if (typeof data !== 'object') {
|
|
111
|
+
return res.status(400).json({ error: 'Request body must be a JSON object' });
|
|
112
|
+
}
|
|
113
|
+
if (!db.isCollection(parent)) {
|
|
114
|
+
return res.status(404).json({ error: `Collection '${parent}' not found` });
|
|
115
|
+
}
|
|
116
|
+
const parentItem = db.getById(parent, parentId);
|
|
117
|
+
if (!parentItem) {
|
|
118
|
+
return res
|
|
119
|
+
.status(404)
|
|
120
|
+
.json({ error: `Parent item with id '${parentId}' not found in '${parent}'` });
|
|
121
|
+
}
|
|
122
|
+
const foreignKey = getForeignKey(parent, foreignKeySuffix);
|
|
123
|
+
data[foreignKey] = parentId;
|
|
124
|
+
try {
|
|
125
|
+
const created = await db.create(children, data);
|
|
126
|
+
return res.status(201).json(created);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
130
|
+
return res.status(400).json({ error: message });
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
router.post('/:resource', validateContentType, async (req, res) => {
|
|
134
|
+
if (readOnly) {
|
|
135
|
+
return res.status(403).json({ error: 'Read-only mode enabled' });
|
|
136
|
+
}
|
|
137
|
+
const resource = getParam(req, 'resource');
|
|
138
|
+
const data = req.body;
|
|
139
|
+
if (typeof data !== 'object') {
|
|
140
|
+
return res.status(400).json({ error: 'Request body must be a JSON object' });
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
if (!db.isCollection(resource) && db.getCollection(resource) !== undefined) {
|
|
144
|
+
const updated = await db.updateSingular(resource, data);
|
|
145
|
+
return res.status(200).json(updated);
|
|
146
|
+
}
|
|
147
|
+
const created = await db.create(resource, data);
|
|
148
|
+
return res.status(201).json(created);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
152
|
+
return res.status(400).json({ error: message });
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
router.put('/:resource/:id', validateContentType, async (req, res) => {
|
|
156
|
+
if (readOnly) {
|
|
157
|
+
return res.status(403).json({ error: 'Read-only mode enabled' });
|
|
158
|
+
}
|
|
159
|
+
const resource = getParam(req, 'resource');
|
|
160
|
+
const id = getParam(req, 'id');
|
|
161
|
+
const data = req.body;
|
|
162
|
+
if (typeof data !== 'object') {
|
|
163
|
+
return res.status(400).json({ error: 'Request body must be a JSON object' });
|
|
164
|
+
}
|
|
165
|
+
if (!db.isCollection(resource)) {
|
|
166
|
+
return res.status(404).json({ error: `Collection '${resource}' not found` });
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
const updated = await db.update(resource, id, data);
|
|
170
|
+
if (!updated) {
|
|
171
|
+
return res.status(404).json({ error: `Item with id '${id}' not found in '${resource}'` });
|
|
172
|
+
}
|
|
173
|
+
return res.json(updated);
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
177
|
+
return res.status(400).json({ error: message });
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
router.patch('/:resource/:id', validateContentType, async (req, res) => {
|
|
181
|
+
if (readOnly) {
|
|
182
|
+
return res.status(403).json({ error: 'Read-only mode enabled' });
|
|
183
|
+
}
|
|
184
|
+
const resource = getParam(req, 'resource');
|
|
185
|
+
const id = getParam(req, 'id');
|
|
186
|
+
const data = req.body;
|
|
187
|
+
if (typeof data !== 'object') {
|
|
188
|
+
return res.status(400).json({ error: 'Request body must be a JSON object' });
|
|
189
|
+
}
|
|
190
|
+
if (!db.isCollection(resource)) {
|
|
191
|
+
return res.status(404).json({ error: `Collection '${resource}' not found` });
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
const patched = await db.patch(resource, id, data);
|
|
195
|
+
if (!patched) {
|
|
196
|
+
return res.status(404).json({ error: `Item with id '${id}' not found in '${resource}'` });
|
|
197
|
+
}
|
|
198
|
+
return res.json(patched);
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
202
|
+
return res.status(400).json({ error: message });
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
router.put('/:resource', validateContentType, async (req, res) => {
|
|
206
|
+
if (readOnly) {
|
|
207
|
+
return res.status(403).json({ error: 'Read-only mode enabled' });
|
|
208
|
+
}
|
|
209
|
+
const resource = getParam(req, 'resource');
|
|
210
|
+
const data = req.body;
|
|
211
|
+
if (typeof data !== 'object') {
|
|
212
|
+
return res.status(400).json({ error: 'Request body must be a JSON object' });
|
|
213
|
+
}
|
|
214
|
+
if (db.isCollection(resource)) {
|
|
215
|
+
return res
|
|
216
|
+
.status(400)
|
|
217
|
+
.json({
|
|
218
|
+
error: `Cannot PUT to collection '${resource}'. Use POST or PUT /${resource}/:id`,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
const updated = await db.updateSingular(resource, data);
|
|
223
|
+
return res.json(updated);
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
227
|
+
return res.status(400).json({ error: message });
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
router.patch('/:resource', validateContentType, async (req, res) => {
|
|
231
|
+
if (readOnly) {
|
|
232
|
+
return res.status(403).json({ error: 'Read-only mode enabled' });
|
|
233
|
+
}
|
|
234
|
+
const resource = getParam(req, 'resource');
|
|
235
|
+
const data = req.body;
|
|
236
|
+
if (typeof data !== 'object') {
|
|
237
|
+
return res.status(400).json({ error: 'Request body must be a JSON object' });
|
|
238
|
+
}
|
|
239
|
+
if (db.isCollection(resource)) {
|
|
240
|
+
return res
|
|
241
|
+
.status(400)
|
|
242
|
+
.json({ error: `Cannot PATCH collection '${resource}'. Use PATCH /${resource}/:id` });
|
|
243
|
+
}
|
|
244
|
+
const current = db.getCollection(resource);
|
|
245
|
+
if (!current || typeof current !== 'object') {
|
|
246
|
+
return res.status(404).json({ error: `Resource '${resource}' not found` });
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
const merged = { ...current, ...data };
|
|
250
|
+
const updated = await db.updateSingular(resource, merged);
|
|
251
|
+
return res.json(updated);
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
255
|
+
return res.status(400).json({ error: message });
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
router.delete('/:resource/:id', async (req, res) => {
|
|
259
|
+
if (readOnly) {
|
|
260
|
+
return res.status(403).json({ error: 'Read-only mode enabled' });
|
|
261
|
+
}
|
|
262
|
+
const resource = getParam(req, 'resource');
|
|
263
|
+
const id = getParam(req, 'id');
|
|
264
|
+
if (!db.isCollection(resource)) {
|
|
265
|
+
return res.status(404).json({ error: `Collection '${resource}' not found` });
|
|
266
|
+
}
|
|
267
|
+
const deleted = await db.delete(resource, id);
|
|
268
|
+
if (!deleted) {
|
|
269
|
+
return res.status(404).json({ error: `Item with id '${id}' not found in '${resource}'` });
|
|
270
|
+
}
|
|
271
|
+
return res.status(204).send();
|
|
272
|
+
});
|
|
273
|
+
return router;
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmC,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAK3F,SAAS,QAAQ,CAAC,GAAY,EAAE,IAAY;IAC1C,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,cAAc,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AA0BD,MAAM,UAAU,YAAY,CAAC,EAAY,EAAE,UAAkC,EAAE;IAC7E,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC;IAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC;IACxC,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,IAAI,CAAC;IAK1D,MAAM,mBAAmB,GAAG,CAAC,GAAY,EAAE,IAAc,EAAE,IAAkB,EAAQ,E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AAO,EAAE,CAAC,CAAC;QAClD,CAAC;IACH,CAAC,CAAC,CAAC;IAKH,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,EAAE;QACpE,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,wBAAwB,EAAE,CAAC,CAAC;QACnE,CAAC;QAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC3C,MAAM,EAAE,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAE/B,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,eAAe,QAAQ,aAAa,EAAE,CAAC,CAAC;QAC/E,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAE9C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,QAAQ,GAAG,EAAE,CAAC,CAAC;QAC5F,CAAC;QAGD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Express } from 'express';
|
|
2
|
+
import { Database } from './database.js';
|
|
3
|
+
import { RouterOptions } from './router.js';
|
|
4
|
+
import { StaticOptions } from './static.js';
|
|
5
|
+
export interface ServerOptions extends RouterOptions, StaticOptions {
|
|
6
|
+
port?: number;
|
|
7
|
+
host?: string;
|
|
8
|
+
noCors?: boolean;
|
|
9
|
+
noGzip?: boolean;
|
|
10
|
+
delay?: number;
|
|
11
|
+
quiet?: boolean;
|
|
12
|
+
routes?: string;
|
|
13
|
+
middlewares?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function createServer(db: Database, options?: Partial<ServerOptions>): Promise<Express>;
|
|
16
|
+
export declare function startServer(app: Express, options?: Pick<ServerOptions, 'port' | 'host' | 'quiet'>): ReturnType<Express['listen']>;
|
|
17
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAG3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAgB,aAAa,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAoD,aAAa,EAAE,MAAM,aAAa,CAAC;AAQ9F,MAAM,WAAW,aAAc,SAAQ,aAAa,EAAE,aAAa;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAgBD,wBAAsB,YAAY,CAChC,EAAE,EAAE,QAAQ,EACZ,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,GACnC,OAAO,CAAC,OAAO,CAAC,CA0FlB;AASD,wBAAgB,WAAW,CACzB,GAAG,EAAE,OAAO,EACZ,OAAO,GAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAM,GAC3D,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAiB/B"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import cors from 'cors';
|
|
3
|
+
import compression from 'compression';
|
|
4
|
+
import { createRouter } from './router.js';
|
|
5
|
+
import { createStaticMiddleware, createHomepageMiddleware } from './static.js';
|
|
6
|
+
import { loadMiddlewares } from './loader.js';
|
|
7
|
+
import { loadRewriteRules, createRewriterMiddleware } from './rewriter.js';
|
|
8
|
+
import { logger } from './logger.js';
|
|
9
|
+
export async function createServer(db, options = {}) {
|
|
10
|
+
const app = express();
|
|
11
|
+
if (!options.noCors) {
|
|
12
|
+
app.use(cors());
|
|
13
|
+
}
|
|
14
|
+
if (!options.noGzip) {
|
|
15
|
+
app.use(compression());
|
|
16
|
+
}
|
|
17
|
+
app.use(express.json());
|
|
18
|
+
if (options.delay && options.delay > 0) {
|
|
19
|
+
const delay = options.delay;
|
|
20
|
+
app.use((_req, _res, next) => {
|
|
21
|
+
setTimeout(() => {
|
|
22
|
+
next();
|
|
23
|
+
}, delay);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (!options.quiet) {
|
|
27
|
+
app.use((req, _res, next) => {
|
|
28
|
+
logger.request(req.method, req.url);
|
|
29
|
+
next();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (options.middlewares) {
|
|
33
|
+
try {
|
|
34
|
+
const middlewares = await loadMiddlewares(options.middlewares);
|
|
35
|
+
for (const middleware of middlewares) {
|
|
36
|
+
app.use(middleware);
|
|
37
|
+
}
|
|
38
|
+
if (!options.quiet) {
|
|
39
|
+
logger.success(`Loaded custom middlewares from ${options.middlewares}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
logger.error(`Failed to load middlewares: ${error instanceof Error ? error.message : String(error)}`);
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
app.use(createHomepageMiddleware(options));
|
|
48
|
+
app.use(createStaticMiddleware(options));
|
|
49
|
+
if (options.routes) {
|
|
50
|
+
try {
|
|
51
|
+
const rules = await loadRewriteRules(options.routes);
|
|
52
|
+
const rewriter = createRewriterMiddleware(rules);
|
|
53
|
+
app.use(rewriter);
|
|
54
|
+
if (!options.quiet) {
|
|
55
|
+
logger.success(`Loaded route rewrite rules from ${options.routes}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
logger.error(`Failed to load routes: ${error instanceof Error ? error.message : String(error)}`);
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
app.get('/db', (_req, res) => {
|
|
64
|
+
res.json(db.getData());
|
|
65
|
+
});
|
|
66
|
+
const router = createRouter(db, options);
|
|
67
|
+
app.use(router);
|
|
68
|
+
app.use((_req, res) => {
|
|
69
|
+
res.status(404).json({ error: 'Not Found' });
|
|
70
|
+
});
|
|
71
|
+
return app;
|
|
72
|
+
}
|
|
73
|
+
export function startServer(app, options = {}) {
|
|
74
|
+
const port = options.port || 3000;
|
|
75
|
+
const host = options.host || 'localhost';
|
|
76
|
+
return app.listen(port, host, () => {
|
|
77
|
+
if (!options.quiet) {
|
|
78
|
+
logger.banner([
|
|
79
|
+
'🚀 API Faker is running!',
|
|
80
|
+
'',
|
|
81
|
+
' Resources:',
|
|
82
|
+
` http://${host}:${String(port)}/`,
|
|
83
|
+
'',
|
|
84
|
+
' Home:',
|
|
85
|
+
` http://${host}:${String(port)}`,
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,OAAoB,MAAM,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BACF,SAAS;gBACT,YAAY,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE;aACnC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/static.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RequestHandler } from 'express';
|
|
2
|
+
export interface StaticOptions {
|
|
3
|
+
directory?: string;
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function createStaticMiddleware(options?: StaticOptions): RequestHandler;
|
|
7
|
+
export declare function createHomepageMiddleware(options?: StaticOptions): RequestHandler;
|
|
8
|
+
//# sourceMappingURL=static.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../src/static.ts"],"names":[],"mappings":"AAIA,OAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAOlD,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAcD,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,aAAkB,GAAG,cAAc,CAkBlF;AAQD,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,aAAkB,GAAG,cAAc,CAuIpF"}
|
package/dist/static.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import { resolve } from 'path';
|
|
4
|
+
export function createStaticMiddleware(options = {}) {
|
|
5
|
+
const directory = options.directory || './public';
|
|
6
|
+
const enabled = options.enabled !== false;
|
|
7
|
+
const staticPath = resolve(process.cwd(), directory);
|
|
8
|
+
if (!enabled || !existsSync(staticPath)) {
|
|
9
|
+
return (_req, _res, next) => {
|
|
10
|
+
next();
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return express.static(staticPath, {
|
|
14
|
+
index: 'index.html',
|
|
15
|
+
dotfiles: 'ignore',
|
|
16
|
+
redirect: true,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export function createHomepageMiddleware(options = {}) {
|
|
20
|
+
const directory = options.directory || './public';
|
|
21
|
+
const enabled = options.enabled !== false;
|
|
22
|
+
const staticPath = resolve(process.cwd(), directory);
|
|
23
|
+
const indexPath = resolve(staticPath, 'index.html');
|
|
24
|
+
return (req, res, next) => {
|
|
25
|
+
if (req.path !== '/') {
|
|
26
|
+
next();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (enabled && existsSync(indexPath)) {
|
|
30
|
+
next();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const host = req.get('host') || 'localhost:3000';
|
|
34
|
+
const protocol = req.protocol;
|
|
35
|
+
const baseUrl = `${protocol}://${host}`;
|
|
36
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
37
|
+
res.send(`<!DOCTYPE html>
|
|
38
|
+
<html lang="en">
|
|
39
|
+
<head>
|
|
40
|
+
<meta charset="UTF-8">
|
|
41
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
42
|
+
<title>API Faker</title>
|
|
43
|
+
<style>
|
|
44
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
45
|
+
body {
|
|
46
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
47
|
+
line-height: 1.6;
|
|
48
|
+
color: #333;
|
|
49
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
50
|
+
min-height: 100vh;
|
|
51
|
+
padding: 2rem;
|
|
52
|
+
}
|
|
53
|
+
.container {
|
|
54
|
+
max-width: 800px;
|
|
55
|
+
margin: 0 auto;
|
|
56
|
+
background: white;
|
|
57
|
+
border-radius: 12px;
|
|
58
|
+
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
|
59
|
+
padding: 3rem;
|
|
60
|
+
}
|
|
61
|
+
h1 {
|
|
62
|
+
color: #667eea;
|
|
63
|
+
font-size: 2.5rem;
|
|
64
|
+
margin-bottom: 1rem;
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
gap: 0.5rem;
|
|
68
|
+
}
|
|
69
|
+
h2 {
|
|
70
|
+
color: #555;
|
|
71
|
+
font-size: 1.5rem;
|
|
72
|
+
margin-top: 2rem;
|
|
73
|
+
margin-bottom: 1rem;
|
|
74
|
+
border-bottom: 2px solid #667eea;
|
|
75
|
+
padding-bottom: 0.5rem;
|
|
76
|
+
}
|
|
77
|
+
.intro {
|
|
78
|
+
color: #666;
|
|
79
|
+
font-size: 1.1rem;
|
|
80
|
+
margin-bottom: 2rem;
|
|
81
|
+
}
|
|
82
|
+
.endpoint {
|
|
83
|
+
background: #f8f9fa;
|
|
84
|
+
border-left: 4px solid #667eea;
|
|
85
|
+
padding: 1rem;
|
|
86
|
+
margin-bottom: 1rem;
|
|
87
|
+
border-radius: 4px;
|
|
88
|
+
}
|
|
89
|
+
.endpoint a {
|
|
90
|
+
color: #667eea;
|
|
91
|
+
text-decoration: none;
|
|
92
|
+
font-family: 'Monaco', 'Courier New', monospace;
|
|
93
|
+
font-weight: bold;
|
|
94
|
+
}
|
|
95
|
+
.endpoint a:hover {
|
|
96
|
+
text-decoration: underline;
|
|
97
|
+
}
|
|
98
|
+
.endpoint p {
|
|
99
|
+
color: #666;
|
|
100
|
+
margin-top: 0.5rem;
|
|
101
|
+
font-size: 0.95rem;
|
|
102
|
+
}
|
|
103
|
+
.info-box {
|
|
104
|
+
background: #e3f2fd;
|
|
105
|
+
border-left: 4px solid #2196f3;
|
|
106
|
+
padding: 1rem;
|
|
107
|
+
margin-top: 2rem;
|
|
108
|
+
border-radius: 4px;
|
|
109
|
+
}
|
|
110
|
+
.info-box p {
|
|
111
|
+
color: #1565c0;
|
|
112
|
+
margin: 0;
|
|
113
|
+
}
|
|
114
|
+
code {
|
|
115
|
+
background: #f5f5f5;
|
|
116
|
+
padding: 0.2rem 0.4rem;
|
|
117
|
+
border-radius: 3px;
|
|
118
|
+
font-family: 'Monaco', 'Courier New', monospace;
|
|
119
|
+
font-size: 0.9em;
|
|
120
|
+
}
|
|
121
|
+
</style>
|
|
122
|
+
</head>
|
|
123
|
+
<body>
|
|
124
|
+
<div class="container">
|
|
125
|
+
<h1>🚀 API Faker</h1>
|
|
126
|
+
<p class="intro">
|
|
127
|
+
Your JSON REST API is up and running! Use the endpoints below to interact with your data.
|
|
128
|
+
</p>
|
|
129
|
+
|
|
130
|
+
<h2>📡 Endpoints</h2>
|
|
131
|
+
<div class="endpoint">
|
|
132
|
+
<a href="${baseUrl}/db" target="_blank">${baseUrl}/db</a>
|
|
133
|
+
<p>View the full database</p>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<h2>💡 Tips</h2>
|
|
137
|
+
<div class="info-box">
|
|
138
|
+
<p>
|
|
139
|
+
Use query parameters to filter, sort, and paginate your data.
|
|
140
|
+
Examples: <code>?_sort=name&_order=asc</code>, <code>?_page=1&_limit=10</code>
|
|
141
|
+
</p>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
</body>
|
|
145
|
+
</html>`);
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=static.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static.js","sourceRoot":"","sources":["../src/static.ts"],"names":[],"mappings":"AAIA,OAAO,OAA2B,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAsB/B,MAAM,UAAU,sBAAsB,CAAC,UAAyB,EAAE;IAChE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,UAAU,CAAC;IAClD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,KAAK,KAAK,CAAC;IAC1C,MAAM,UA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AA0B,CAAC,CAAC;QAC1D,GAAG,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+FI,OAAO,wBAAwB,OAAO;;;;;;;;;;;;;QAa/C,CAAC,CAAC;IACR,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rest_api_faker",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6-alpha",
|
|
4
4
|
"description": "Get a full fake REST API with zero coding in less than 30 seconds",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "./dist/index.js",
|
|
6
7
|
"types": "./dist/index.d.ts",
|
|
7
8
|
"bin": {
|
|
@@ -37,30 +38,28 @@
|
|
|
37
38
|
"yargs": "^18.0.0"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@eslint/js": "^
|
|
41
|
-
"@types/chokidar": "^2.1.7",
|
|
41
|
+
"@eslint/js": "^10.0.1",
|
|
42
42
|
"@types/compression": "^1.7.5",
|
|
43
43
|
"@types/cors": "^2.8.17",
|
|
44
44
|
"@types/express": "^5.0.6",
|
|
45
|
-
"@types/node": "^25.
|
|
46
|
-
"@types/supertest": "^
|
|
45
|
+
"@types/node": "^25.3.3",
|
|
46
|
+
"@types/supertest": "^7.2.0",
|
|
47
47
|
"@types/yargs": "^17.0.32",
|
|
48
|
-
"@typescript-eslint/eslint-plugin": "
|
|
49
|
-
"@typescript-eslint/parser": "
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "8.58.0",
|
|
49
|
+
"@typescript-eslint/parser": "8.58.0",
|
|
50
50
|
"@vitest/coverage-v8": "^4.0.16",
|
|
51
|
-
"eslint": "^
|
|
51
|
+
"eslint": "^10.0.2",
|
|
52
52
|
"eslint-config-prettier": "^10.1.8",
|
|
53
|
-
"nodemon": "^3.1.
|
|
53
|
+
"nodemon": "^3.1.14",
|
|
54
54
|
"prettier": "^3.2.4",
|
|
55
55
|
"supertest": "^7.1.4",
|
|
56
|
-
"
|
|
57
|
-
"typescript": "
|
|
58
|
-
"typescript-eslint": "^8.51.0",
|
|
56
|
+
"typescript": "^6.0.2",
|
|
57
|
+
"typescript-eslint": "8.58.0",
|
|
59
58
|
"vitest": "^4.0.16"
|
|
60
59
|
},
|
|
61
60
|
"scripts": {
|
|
62
|
-
"build": "
|
|
63
|
-
"dev": "
|
|
61
|
+
"build": "tsc -p tsconfig.build.json",
|
|
62
|
+
"dev": "tsc && nodemon --watch dist --exec \"node dist/cli.js db.json\"",
|
|
64
63
|
"test": "vitest",
|
|
65
64
|
"test:run": "vitest run",
|
|
66
65
|
"test:coverage": "vitest --coverage",
|