@base44-preview/cli 0.0.44-pr.395.f527fa6 → 0.0.44-pr.406.b97f4ba
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/dist/cli/index.js +102 -228
- package/dist/cli/index.js.map +10 -8
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -238081,7 +238081,7 @@ var FieldRLSSchema = exports_external.looseObject({
|
|
|
238081
238081
|
delete: RLSRuleSchema.optional()
|
|
238082
238082
|
});
|
|
238083
238083
|
var PropertyDefinitionSchema = exports_external.looseObject({
|
|
238084
|
-
type: exports_external.string(),
|
|
238084
|
+
type: exports_external.string().optional(),
|
|
238085
238085
|
title: exports_external.string().optional(),
|
|
238086
238086
|
description: exports_external.string().optional(),
|
|
238087
238087
|
minLength: exports_external.number().int().min(0).optional(),
|
|
@@ -248424,7 +248424,7 @@ function getTypesCommand(context) {
|
|
|
248424
248424
|
// src/cli/dev/dev-server/main.ts
|
|
248425
248425
|
import { dirname as dirname13, join as join18 } from "node:path";
|
|
248426
248426
|
var import_cors = __toESM(require_lib4(), 1);
|
|
248427
|
-
var
|
|
248427
|
+
var import_express6 = __toESM(require_express(), 1);
|
|
248428
248428
|
|
|
248429
248429
|
// ../../node_modules/get-port/index.js
|
|
248430
248430
|
import net from "node:net";
|
|
@@ -248779,162 +248779,19 @@ function createFunctionRouter(manager, logger) {
|
|
|
248779
248779
|
return router;
|
|
248780
248780
|
}
|
|
248781
248781
|
|
|
248782
|
-
// src/cli/dev/dev-server/
|
|
248782
|
+
// src/cli/dev/dev-server/database.ts
|
|
248783
248783
|
var import_nedb = __toESM(require_nedb(), 1);
|
|
248784
248784
|
|
|
248785
|
-
// src/cli/dev/dev-server/db/validator.ts
|
|
248786
|
-
var fieldTypes = [
|
|
248787
|
-
"string",
|
|
248788
|
-
"integer",
|
|
248789
|
-
"number",
|
|
248790
|
-
"boolean",
|
|
248791
|
-
"array",
|
|
248792
|
-
"object"
|
|
248793
|
-
];
|
|
248794
|
-
|
|
248795
|
-
class Validator {
|
|
248796
|
-
filterFields(record2, entitySchema) {
|
|
248797
|
-
const filteredRecord = {};
|
|
248798
|
-
for (const [key2, value] of Object.entries(record2)) {
|
|
248799
|
-
if (entitySchema.properties[key2]) {
|
|
248800
|
-
filteredRecord[key2] = value;
|
|
248801
|
-
}
|
|
248802
|
-
}
|
|
248803
|
-
return filteredRecord;
|
|
248804
|
-
}
|
|
248805
|
-
applyDefaults(record2, entitySchema) {
|
|
248806
|
-
const result = {};
|
|
248807
|
-
for (const [key2, property] of Object.entries(entitySchema.properties)) {
|
|
248808
|
-
if (property.default !== undefined) {
|
|
248809
|
-
result[key2] = property.default;
|
|
248810
|
-
}
|
|
248811
|
-
}
|
|
248812
|
-
return {
|
|
248813
|
-
...result,
|
|
248814
|
-
...record2
|
|
248815
|
-
};
|
|
248816
|
-
}
|
|
248817
|
-
validate(record2, entitySchema, partial2 = false) {
|
|
248818
|
-
if (!partial2) {
|
|
248819
|
-
const requiredFieldsResponse = this.validateRequiredFields(record2, entitySchema);
|
|
248820
|
-
if (requiredFieldsResponse.hasError) {
|
|
248821
|
-
return requiredFieldsResponse;
|
|
248822
|
-
}
|
|
248823
|
-
}
|
|
248824
|
-
const fieldTypesResponse = this.validateFieldTypes(record2, entitySchema);
|
|
248825
|
-
if (fieldTypesResponse.hasError) {
|
|
248826
|
-
return fieldTypesResponse;
|
|
248827
|
-
}
|
|
248828
|
-
return {
|
|
248829
|
-
hasError: false
|
|
248830
|
-
};
|
|
248831
|
-
}
|
|
248832
|
-
createValidationError(message) {
|
|
248833
|
-
return {
|
|
248834
|
-
error_type: "ValidationError",
|
|
248835
|
-
message,
|
|
248836
|
-
request_id: null,
|
|
248837
|
-
traceback: ""
|
|
248838
|
-
};
|
|
248839
|
-
}
|
|
248840
|
-
validateFieldTypes(record2, entitySchema) {
|
|
248841
|
-
for (const [key2, value] of Object.entries(record2)) {
|
|
248842
|
-
const property = entitySchema.properties[key2];
|
|
248843
|
-
const result = this.validateValue(value, property, key2);
|
|
248844
|
-
if (result.hasError)
|
|
248845
|
-
return result;
|
|
248846
|
-
}
|
|
248847
|
-
return {
|
|
248848
|
-
hasError: false
|
|
248849
|
-
};
|
|
248850
|
-
}
|
|
248851
|
-
validateValue(value, property, fieldPath) {
|
|
248852
|
-
const propertyType = property?.type;
|
|
248853
|
-
if (!fieldTypes.includes(propertyType)) {
|
|
248854
|
-
return {
|
|
248855
|
-
hasError: true,
|
|
248856
|
-
error: this.createValidationError(`Error in field ${fieldPath}: Input should be a valid ${propertyType}`)
|
|
248857
|
-
};
|
|
248858
|
-
}
|
|
248859
|
-
switch (propertyType) {
|
|
248860
|
-
case "array":
|
|
248861
|
-
if (!Array.isArray(value)) {
|
|
248862
|
-
return {
|
|
248863
|
-
hasError: true,
|
|
248864
|
-
error: this.createValidationError(`Error in field ${fieldPath}: Input should be a valid array`)
|
|
248865
|
-
};
|
|
248866
|
-
}
|
|
248867
|
-
if (property.items) {
|
|
248868
|
-
for (let i5 = 0;i5 < value.length; i5++) {
|
|
248869
|
-
const itemResult = this.validateValue(value[i5], property.items, `${fieldPath}[${i5}]`);
|
|
248870
|
-
if (itemResult.hasError)
|
|
248871
|
-
return itemResult;
|
|
248872
|
-
}
|
|
248873
|
-
}
|
|
248874
|
-
break;
|
|
248875
|
-
case "object":
|
|
248876
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
248877
|
-
return {
|
|
248878
|
-
hasError: true,
|
|
248879
|
-
error: this.createValidationError(`Error in field ${fieldPath}: Input should be a valid object`)
|
|
248880
|
-
};
|
|
248881
|
-
}
|
|
248882
|
-
if (property.properties) {
|
|
248883
|
-
for (const [subKey, subValue] of Object.entries(value)) {
|
|
248884
|
-
if (property.properties[subKey]) {
|
|
248885
|
-
const subResult = this.validateValue(subValue, property.properties[subKey], `${fieldPath}.${subKey}`);
|
|
248886
|
-
if (subResult.hasError)
|
|
248887
|
-
return subResult;
|
|
248888
|
-
}
|
|
248889
|
-
}
|
|
248890
|
-
}
|
|
248891
|
-
break;
|
|
248892
|
-
case "integer":
|
|
248893
|
-
if (!Number.isInteger(value)) {
|
|
248894
|
-
return {
|
|
248895
|
-
hasError: true,
|
|
248896
|
-
error: this.createValidationError(`Error in field ${fieldPath}: Input should be a valid integer`)
|
|
248897
|
-
};
|
|
248898
|
-
}
|
|
248899
|
-
break;
|
|
248900
|
-
default:
|
|
248901
|
-
if (typeof value !== propertyType) {
|
|
248902
|
-
return {
|
|
248903
|
-
hasError: true,
|
|
248904
|
-
error: this.createValidationError(`Error in field ${fieldPath}: Input should be a valid ${propertyType}`)
|
|
248905
|
-
};
|
|
248906
|
-
}
|
|
248907
|
-
}
|
|
248908
|
-
return { hasError: false };
|
|
248909
|
-
}
|
|
248910
|
-
validateRequiredFields(record2, entitySchema) {
|
|
248911
|
-
if (entitySchema.required && entitySchema.required.length > 0) {
|
|
248912
|
-
for (const required2 of entitySchema.required) {
|
|
248913
|
-
if (record2[required2] == null) {
|
|
248914
|
-
return {
|
|
248915
|
-
hasError: true,
|
|
248916
|
-
error: this.createValidationError(`Error in field ${required2}: Field required`)
|
|
248917
|
-
};
|
|
248918
|
-
}
|
|
248919
|
-
}
|
|
248920
|
-
}
|
|
248921
|
-
return {
|
|
248922
|
-
hasError: false
|
|
248923
|
-
};
|
|
248924
|
-
}
|
|
248925
|
-
}
|
|
248926
|
-
|
|
248927
|
-
// src/cli/dev/dev-server/db/database.ts
|
|
248928
248785
|
class Database {
|
|
248929
248786
|
collections = new Map;
|
|
248930
|
-
|
|
248931
|
-
|
|
248932
|
-
|
|
248933
|
-
for (const entity2 of entities) {
|
|
248934
|
-
this.collections.set(entity2.name, new import_nedb.default);
|
|
248935
|
-
this.schemas.set(entity2.name, entity2);
|
|
248787
|
+
initCollections(names) {
|
|
248788
|
+
for (const name2 of names) {
|
|
248789
|
+
this.collections.set(name2, new import_nedb.default);
|
|
248936
248790
|
}
|
|
248937
248791
|
}
|
|
248792
|
+
hasCollection(name2) {
|
|
248793
|
+
return this.collections.has(name2);
|
|
248794
|
+
}
|
|
248938
248795
|
getCollection(name2) {
|
|
248939
248796
|
return this.collections.get(name2);
|
|
248940
248797
|
}
|
|
@@ -248946,25 +248803,6 @@ class Database {
|
|
|
248946
248803
|
collection.remove({}, { multi: true });
|
|
248947
248804
|
}
|
|
248948
248805
|
this.collections.clear();
|
|
248949
|
-
this.schemas.clear();
|
|
248950
|
-
}
|
|
248951
|
-
validate(entityName, record2, partial2 = false) {
|
|
248952
|
-
const schema9 = this.schemas.get(entityName);
|
|
248953
|
-
if (!schema9) {
|
|
248954
|
-
throw new Error(`Entity "${entityName}" not found`);
|
|
248955
|
-
}
|
|
248956
|
-
return this.validator.validate(record2, schema9, partial2);
|
|
248957
|
-
}
|
|
248958
|
-
prepareRecord(entityName, record2, partial2 = false) {
|
|
248959
|
-
const schema9 = this.schemas.get(entityName);
|
|
248960
|
-
if (!schema9) {
|
|
248961
|
-
throw new Error(`Entity "${entityName}" not found`);
|
|
248962
|
-
}
|
|
248963
|
-
const filteredRecord = this.validator.filterFields(record2, schema9);
|
|
248964
|
-
if (partial2) {
|
|
248965
|
-
return filteredRecord;
|
|
248966
|
-
}
|
|
248967
|
-
return this.validator.applyDefaults(filteredRecord, schema9);
|
|
248968
248806
|
}
|
|
248969
248807
|
}
|
|
248970
248808
|
|
|
@@ -249000,8 +248838,8 @@ function broadcastEntityEvent(io6, appId, entityName, event) {
|
|
|
249000
248838
|
});
|
|
249001
248839
|
}
|
|
249002
248840
|
|
|
249003
|
-
// src/cli/dev/dev-server/routes/entities.ts
|
|
249004
|
-
var
|
|
248841
|
+
// src/cli/dev/dev-server/routes/entities/entities-router.ts
|
|
248842
|
+
var import_express3 = __toESM(require_express(), 1);
|
|
249005
248843
|
|
|
249006
248844
|
// ../../node_modules/nanoid/index.js
|
|
249007
248845
|
import { webcrypto as crypto } from "node:crypto";
|
|
@@ -249033,7 +248871,52 @@ function nanoid3(size = 21) {
|
|
|
249033
248871
|
return id2;
|
|
249034
248872
|
}
|
|
249035
248873
|
|
|
249036
|
-
// src/cli/dev/dev-server/routes/entities.ts
|
|
248874
|
+
// src/cli/dev/dev-server/routes/entities/entities-user-router.ts
|
|
248875
|
+
var import_express2 = __toESM(require_express(), 1);
|
|
248876
|
+
|
|
248877
|
+
// src/cli/dev/dev-server/routes/entities/utils.ts
|
|
248878
|
+
function stripInternalFields(doc2) {
|
|
248879
|
+
if (Array.isArray(doc2)) {
|
|
248880
|
+
return doc2.map((d5) => stripInternalFields(d5));
|
|
248881
|
+
}
|
|
248882
|
+
const { _id, ...rest } = doc2;
|
|
248883
|
+
return rest;
|
|
248884
|
+
}
|
|
248885
|
+
|
|
248886
|
+
// src/cli/dev/dev-server/routes/entities/entities-user-router.ts
|
|
248887
|
+
async function createUserRouter(db2) {
|
|
248888
|
+
if (!db2.hasCollection("User")) {
|
|
248889
|
+
db2.initCollections(["User"]);
|
|
248890
|
+
}
|
|
248891
|
+
const userInfo = await readAuth();
|
|
248892
|
+
const now = new Date().toISOString().replace("Z", "000");
|
|
248893
|
+
const idMe = nanoid3();
|
|
248894
|
+
await db2.getCollection("User")?.insertAsync({
|
|
248895
|
+
id: idMe,
|
|
248896
|
+
email: userInfo.email,
|
|
248897
|
+
full_name: userInfo.name,
|
|
248898
|
+
is_service: false,
|
|
248899
|
+
is_verified: true,
|
|
248900
|
+
disabled: null,
|
|
248901
|
+
role: "admin",
|
|
248902
|
+
collaborator_role: "editor",
|
|
248903
|
+
created_date: now,
|
|
248904
|
+
updated_date: now
|
|
248905
|
+
});
|
|
248906
|
+
const router = import_express2.Router({ mergeParams: true });
|
|
248907
|
+
router.get("/:id", async (req, res) => {
|
|
248908
|
+
const id2 = req.params.id === "me" ? idMe : req.params.id;
|
|
248909
|
+
const result = await db2.getCollection("User")?.findOneAsync({ id: id2 });
|
|
248910
|
+
if (!result) {
|
|
248911
|
+
res.status(404).json({ error: `User with id "${req.params.id}" not found` });
|
|
248912
|
+
return;
|
|
248913
|
+
}
|
|
248914
|
+
res.json(stripInternalFields(result));
|
|
248915
|
+
});
|
|
248916
|
+
return router;
|
|
248917
|
+
}
|
|
248918
|
+
|
|
248919
|
+
// src/cli/dev/dev-server/routes/entities/entities-router.ts
|
|
249037
248920
|
function parseSort(sort) {
|
|
249038
248921
|
if (!sort) {
|
|
249039
248922
|
return;
|
|
@@ -249056,16 +248939,9 @@ function parseFields(fields) {
|
|
|
249056
248939
|
}
|
|
249057
248940
|
return Object.keys(projection).length > 0 ? projection : undefined;
|
|
249058
248941
|
}
|
|
249059
|
-
function
|
|
249060
|
-
|
|
249061
|
-
|
|
249062
|
-
}
|
|
249063
|
-
const { _id, ...rest } = doc2;
|
|
249064
|
-
return rest;
|
|
249065
|
-
}
|
|
249066
|
-
function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
|
|
249067
|
-
const router = import_express2.Router({ mergeParams: true });
|
|
249068
|
-
const parseBody = import_express2.json();
|
|
248942
|
+
async function createEntityRoutes(db2, logger, broadcast) {
|
|
248943
|
+
const router = import_express3.Router({ mergeParams: true });
|
|
248944
|
+
const parseBody = import_express3.json();
|
|
249069
248945
|
function withCollection(handler) {
|
|
249070
248946
|
return async (req, res) => {
|
|
249071
248947
|
const collection = db2.getCollection(req.params.entityName);
|
|
@@ -249091,11 +248967,8 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
|
|
|
249091
248967
|
}
|
|
249092
248968
|
broadcast(appId, entityName, createData(data));
|
|
249093
248969
|
}
|
|
249094
|
-
|
|
249095
|
-
|
|
249096
|
-
req.url = req.originalUrl;
|
|
249097
|
-
remoteProxy(req, res, next);
|
|
249098
|
-
});
|
|
248970
|
+
const userRouter = await createUserRouter(db2);
|
|
248971
|
+
router.use("/User", userRouter);
|
|
249099
248972
|
router.get("/:entityName/:id", withCollection(async (req, res, collection) => {
|
|
249100
248973
|
const { entityName, id: id2 } = req.params;
|
|
249101
248974
|
try {
|
|
@@ -249156,14 +249029,8 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
|
|
|
249156
249029
|
try {
|
|
249157
249030
|
const now = new Date().toISOString();
|
|
249158
249031
|
const { _id, ...body } = req.body;
|
|
249159
|
-
const filteredBody = db2.prepareRecord(entityName, body);
|
|
249160
|
-
const validation = db2.validate(entityName, filteredBody);
|
|
249161
|
-
if (validation.hasError) {
|
|
249162
|
-
res.status(422).json(validation.error);
|
|
249163
|
-
return;
|
|
249164
|
-
}
|
|
249165
249032
|
const record2 = {
|
|
249166
|
-
...
|
|
249033
|
+
...body,
|
|
249167
249034
|
id: nanoid3(),
|
|
249168
249035
|
created_date: now,
|
|
249169
249036
|
updated_date: now
|
|
@@ -249184,21 +249051,12 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
|
|
|
249184
249051
|
}
|
|
249185
249052
|
try {
|
|
249186
249053
|
const now = new Date().toISOString();
|
|
249187
|
-
const records =
|
|
249188
|
-
|
|
249189
|
-
|
|
249190
|
-
|
|
249191
|
-
|
|
249192
|
-
|
|
249193
|
-
return;
|
|
249194
|
-
}
|
|
249195
|
-
records.push({
|
|
249196
|
-
...filteredRecord,
|
|
249197
|
-
id: nanoid3(),
|
|
249198
|
-
created_date: now,
|
|
249199
|
-
updated_date: now
|
|
249200
|
-
});
|
|
249201
|
-
}
|
|
249054
|
+
const records = req.body.map((item) => ({
|
|
249055
|
+
...item,
|
|
249056
|
+
id: nanoid3(),
|
|
249057
|
+
created_date: now,
|
|
249058
|
+
updated_date: now
|
|
249059
|
+
}));
|
|
249202
249060
|
const inserted = stripInternalFields(await collection.insertAsync(records));
|
|
249203
249061
|
emit(appId, entityName, "create", inserted);
|
|
249204
249062
|
res.status(201).json(inserted);
|
|
@@ -249211,14 +249069,8 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
|
|
|
249211
249069
|
const { appId, entityName, id: id2 } = req.params;
|
|
249212
249070
|
const { id: _id, created_date: _created_date, ...body } = req.body;
|
|
249213
249071
|
try {
|
|
249214
|
-
const filteredBody = db2.prepareRecord(entityName, body, true);
|
|
249215
|
-
const validation = db2.validate(entityName, filteredBody, true);
|
|
249216
|
-
if (validation.hasError) {
|
|
249217
|
-
res.status(422).json(validation.error);
|
|
249218
|
-
return;
|
|
249219
|
-
}
|
|
249220
249072
|
const updateData = {
|
|
249221
|
-
...
|
|
249073
|
+
...body,
|
|
249222
249074
|
updated_date: new Date().toISOString()
|
|
249223
249075
|
};
|
|
249224
249076
|
const result = await collection.updateAsync({ id: id2 }, { $set: updateData }, { returnUpdatedDocs: true });
|
|
@@ -249267,7 +249119,7 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
|
|
|
249267
249119
|
}
|
|
249268
249120
|
|
|
249269
249121
|
// src/cli/dev/dev-server/routes/integrations.ts
|
|
249270
|
-
var
|
|
249122
|
+
var import_express4 = __toESM(require_express(), 1);
|
|
249271
249123
|
var import_multer = __toESM(require_multer(), 1);
|
|
249272
249124
|
import { createHash, randomUUID as randomUUID4 } from "node:crypto";
|
|
249273
249125
|
import fs28 from "node:fs";
|
|
@@ -249276,8 +249128,8 @@ function createFileToken(fileUri) {
|
|
|
249276
249128
|
return createHash("sha256").update(fileUri).digest("hex");
|
|
249277
249129
|
}
|
|
249278
249130
|
function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
|
|
249279
|
-
const router =
|
|
249280
|
-
const parseBody =
|
|
249131
|
+
const router = import_express4.Router({ mergeParams: true });
|
|
249132
|
+
const parseBody = import_express4.json();
|
|
249281
249133
|
const privateFilesDir = path18.join(mediaFilesDir, "private");
|
|
249282
249134
|
fs28.mkdirSync(mediaFilesDir, { recursive: true });
|
|
249283
249135
|
fs28.mkdirSync(privateFilesDir, { recursive: true });
|
|
@@ -249347,7 +249199,7 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
|
|
|
249347
249199
|
return router;
|
|
249348
249200
|
}
|
|
249349
249201
|
function createCustomIntegrationRoutes(remoteProxy, logger) {
|
|
249350
|
-
const router =
|
|
249202
|
+
const router = import_express4.Router({ mergeParams: true });
|
|
249351
249203
|
router.post("/:slug/:operationId", (req, res, next) => {
|
|
249352
249204
|
logger.warn(`"${req.originalUrl}" is not supported in local development, passing call to production`);
|
|
249353
249205
|
req.url = req.originalUrl;
|
|
@@ -249356,6 +249208,18 @@ function createCustomIntegrationRoutes(remoteProxy, logger) {
|
|
|
249356
249208
|
return router;
|
|
249357
249209
|
}
|
|
249358
249210
|
|
|
249211
|
+
// src/cli/dev/dev-server/routes/users.ts
|
|
249212
|
+
var import_express5 = __toESM(require_express(), 1);
|
|
249213
|
+
function createUsersRoutes() {
|
|
249214
|
+
const router = import_express5.Router({ mergeParams: true });
|
|
249215
|
+
const parseBody = import_express5.json();
|
|
249216
|
+
router.post("/invite-user", parseBody, (req, _res, next) => {
|
|
249217
|
+
console.log("invite-user", req.body);
|
|
249218
|
+
next();
|
|
249219
|
+
});
|
|
249220
|
+
return router;
|
|
249221
|
+
}
|
|
249222
|
+
|
|
249359
249223
|
// src/cli/dev/dev-server/watcher.ts
|
|
249360
249224
|
import { EventEmitter as EventEmitter4 } from "node:events";
|
|
249361
249225
|
import { relative as relative6 } from "node:path";
|
|
@@ -251060,7 +250924,7 @@ async function createDevServer(options8) {
|
|
|
251060
250924
|
const port = userPort ?? await getPorts({ port: DEFAULT_PORT });
|
|
251061
250925
|
const baseUrl = `http://localhost:${port}`;
|
|
251062
250926
|
const { functions, entities, project: project2 } = await options8.loadResources();
|
|
251063
|
-
const app =
|
|
250927
|
+
const app = import_express6.default();
|
|
251064
250928
|
const remoteProxy = import_http_proxy_middleware2.createProxyMiddleware({
|
|
251065
250929
|
target: BASE44_APP_URL,
|
|
251066
250930
|
changeOrigin: true
|
|
@@ -251077,7 +250941,17 @@ async function createDevServer(options8) {
|
|
|
251077
250941
|
}
|
|
251078
250942
|
next();
|
|
251079
250943
|
});
|
|
250944
|
+
app.use((req, res, next) => {
|
|
250945
|
+
const auth2 = req.headers.authorization;
|
|
250946
|
+
if (!auth2 || !auth2.startsWith("Bearer ")) {
|
|
250947
|
+
res.status(401).json({ error: "Unauthorized" });
|
|
250948
|
+
return;
|
|
250949
|
+
}
|
|
250950
|
+
next();
|
|
250951
|
+
});
|
|
251080
250952
|
const devLogger = createDevLogger();
|
|
250953
|
+
const usersRoutes = createUsersRoutes();
|
|
250954
|
+
app.use("/api/apps/:appId/users", usersRoutes);
|
|
251081
250955
|
const functionManager = new FunctionManager(functions, devLogger, options8.denoWrapperPath);
|
|
251082
250956
|
const functionRoutes = createFunctionRouter(functionManager, devLogger);
|
|
251083
250957
|
app.use("/api/apps/:appId/functions", functionRoutes);
|
|
@@ -251085,12 +250959,12 @@ async function createDevServer(options8) {
|
|
|
251085
250959
|
R2.info(`Loaded functions: ${functionManager.getFunctionNames().join(", ")}`);
|
|
251086
250960
|
}
|
|
251087
250961
|
const db2 = new Database;
|
|
251088
|
-
db2.
|
|
250962
|
+
db2.initCollections(entities.map((entity2) => entity2.name));
|
|
251089
250963
|
if (db2.getCollectionNames().length > 0) {
|
|
251090
250964
|
R2.info(`Loaded entities: ${db2.getCollectionNames().join(", ")}`);
|
|
251091
250965
|
}
|
|
251092
250966
|
let emitEntityEvent = () => {};
|
|
251093
|
-
const entityRoutes = createEntityRoutes(db2, devLogger,
|
|
250967
|
+
const entityRoutes = await createEntityRoutes(db2, devLogger, (...args) => emitEntityEvent(...args));
|
|
251094
250968
|
app.use("/api/apps/:appId/entities", entityRoutes);
|
|
251095
250969
|
const { path: mediaFilesDir } = await $dir();
|
|
251096
250970
|
app.use("/media/private/:fileUri", (req, res, next) => {
|
|
@@ -251111,7 +250985,7 @@ async function createDevServer(options8) {
|
|
|
251111
250985
|
}
|
|
251112
250986
|
next();
|
|
251113
250987
|
});
|
|
251114
|
-
app.use("/media",
|
|
250988
|
+
app.use("/media", import_express6.default.static(mediaFilesDir));
|
|
251115
250989
|
const integrationRoutes = createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, devLogger);
|
|
251116
250990
|
app.use("/api/apps/:appId/integration-endpoints", integrationRoutes);
|
|
251117
250991
|
const customIntegrationRoutes = createCustomIntegrationRoutes(remoteProxy, devLogger);
|
|
@@ -251160,7 +251034,7 @@ async function createDevServer(options8) {
|
|
|
251160
251034
|
if (previousEntityCount > 0) {
|
|
251161
251035
|
devLogger.log("Entities directory changed, clearing data...");
|
|
251162
251036
|
}
|
|
251163
|
-
db2.
|
|
251037
|
+
db2.initCollections(entities2.map((entity2) => entity2.name));
|
|
251164
251038
|
if (db2.getCollectionNames().length > 0) {
|
|
251165
251039
|
devLogger.log(`Loaded entities: ${db2.getCollectionNames().join(", ")}`);
|
|
251166
251040
|
}
|
|
@@ -255561,4 +255435,4 @@ export {
|
|
|
255561
255435
|
CLIExitError
|
|
255562
255436
|
};
|
|
255563
255437
|
|
|
255564
|
-
//# debugId=
|
|
255438
|
+
//# debugId=6ACA581A680E964E64756E2164756E21
|