Fix build issue with new interfaces

This commit is contained in:
Jan Oberhauser 2020-04-09 20:23:33 +02:00
parent 6f87895e00
commit be9474e84a
2 changed files with 20 additions and 21 deletions

View file

@ -24,7 +24,7 @@ export class Push {
this.channel.on('disconnect', (channel: string, res: express.Response) => {
if (res.req !== undefined) {
delete this.connections[res.req.query.sessionId];
delete this.connections[res.req.query.sessionId as string];
}
});
}

View file

@ -62,6 +62,7 @@ import {
IDataObject,
INodeCredentials,
INodeTypeDescription,
INodeParameters,
INodePropertyOptions,
IRunData,
Workflow,
@ -226,7 +227,7 @@ class App {
return;
}
this.push.add(req.query.sessionId, req, res);
this.push.add(req.query.sessionId as string, req, res);
return;
}
next();
@ -363,10 +364,10 @@ class App {
if (req.query.url === undefined) {
throw new ResponseHelper.ResponseError(`The parameter "url" is missing!`, undefined, 400);
}
if (!req.query.url.match(/^http[s]?:\/\/.*\.json$/i)) {
if (!(req.query.url as string).match(/^http[s]?:\/\/.*\.json$/i)) {
throw new ResponseHelper.ResponseError(`The parameter "url" is not valid! It does not seem to be a URL pointing to a n8n workflow JSON file.`, undefined, 400);
}
const data = await requestPromise.get(req.query.url);
const data = await requestPromise.get(req.query.url as string);
let workflowData: IWorkflowResponse | undefined;
try {
@ -390,7 +391,7 @@ class App {
this.app.get('/rest/workflows', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<IWorkflowShortResponse[]> => {
const findQuery = {} as FindManyOptions;
if (req.query.filter) {
findQuery.where = JSON.parse(req.query.filter);
findQuery.where = JSON.parse(req.query.filter as string);
}
// Return only the fields we need
@ -555,13 +556,13 @@ class App {
// Returns parameter values which normally get loaded from an external API or
// get generated dynamically
this.app.get('/rest/node-parameter-options', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<INodePropertyOptions[]> => {
const nodeType = req.query.nodeType;
const nodeType = req.query.nodeType as string;
let credentials: INodeCredentials | undefined = undefined;
const currentNodeParameters = req.query.currentNodeParameters;
const currentNodeParameters = req.query.currentNodeParameters as INodeParameters[];
if (req.query.credentials !== undefined) {
credentials = JSON.parse(req.query.credentials);
credentials = JSON.parse(req.query.credentials as string);
}
const methodName = req.query.methodName;
const methodName = req.query.methodName as string;
const nodeTypes = NodeTypes();
@ -780,13 +781,9 @@ class App {
const findQuery = {} as FindManyOptions;
// Make sure the variable has an expected value
if (req.query.includeData === 'true') {
req.query.includeData = true;
} else {
req.query.includeData = false;
}
const includeData = ['true', true].includes(req.query.includeData as string);
if (req.query.includeData !== true) {
if (includeData !== true) {
// Return only the fields we need
findQuery.select = ['id', 'name', 'type', 'nodesAccess', 'createdAt', 'updatedAt'];
}
@ -798,7 +795,7 @@ class App {
}
let encryptionKey = undefined;
if (req.query.includeData === true) {
if (includeData === true) {
encryptionKey = await UserSettings.getEncryptionKey();
if (encryptionKey === undefined) {
throw new Error('No encryption key got found to decrypt the credentials!');
@ -818,7 +815,7 @@ class App {
this.app.get('/rest/credentials', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<ICredentialsResponse[]> => {
const findQuery = {} as FindManyOptions;
if (req.query.filter) {
findQuery.where = JSON.parse(req.query.filter);
findQuery.where = JSON.parse(req.query.filter as string);
if ((findQuery.where! as IDataObject).id !== undefined) {
// No idea if multiple where parameters make db search
// slower but to be sure that that is not the case we
@ -832,7 +829,9 @@ class App {
const results = await Db.collections.Credentials!.find(findQuery) as unknown as ICredentialsResponse[];
let encryptionKey = undefined;
if (req.query.includeData === true) {
const includeData = ['true', true].includes(req.query.includeData as string);
if (includeData === true) {
encryptionKey = await UserSettings.getEncryptionKey();
if (encryptionKey === undefined) {
throw new Error('No encryption key got found to decrypt the credentials!');
@ -880,12 +879,12 @@ class App {
let filter: any = {}; // tslint:disable-line:no-any
if (req.query.filter) {
filter = JSON.parse(req.query.filter);
filter = JSON.parse(req.query.filter as string);
}
let limit = 20;
if (req.query.limit) {
limit = parseInt(req.query.limit, 10);
limit = parseInt(req.query.limit as string, 10);
}
const countFilter = JSON.parse(JSON.stringify(filter));
@ -1063,7 +1062,7 @@ class App {
let filter: any = {}; // tslint:disable-line:no-any
if (req.query.filter) {
filter = JSON.parse(req.query.filter);
filter = JSON.parse(req.query.filter as string);
}
for (const data of executingWorkflows) {