Пример #1
0
const createServer = () =>
	Promise.fromCallback(cb => {
		server = http.createServer((req, res) => {
			res.writeHead(200);
			res.end(`response${req.url}`);
		});
		server.listen(serverPort, cb);
	});
(async function createInterface(outputName: string) {
  const json = await getResponse();
  const camelCasedOutputName = camelCase(outputName);
  let interfaces = json2ts(JSON.stringify(json), {
    prefix: camelCasedOutputName.charAt(0).toUpperCase() + camelCasedOutputName.slice(1) + 'Response',
  });
  interfaces = interfaces.replace(/interface/g, 'export interface');
  await Bluebird.fromCallback(cb => writeFile(`./src/responses/${outputName}.response.ts`, interfaces, cb));
  console.log('Success');
})(
Пример #3
0
    importICS(event: EventMessage): Promise<Response> {
        this.assertBatchHasBeenStarted();

        return Promise.fromCallback(callback => {
            return this.auth(post(this.papiUrl('/batches/' + this.currentBatchId + '/events/' + event.PrimaryAddress + '/' + event.PrimaryAddress)))
                .type('text/plain')
                .send(event.MimeContent)
                .end(callback);
        });
    }
Пример #4
0
    commitBatch(): Promise<Response> {
        this.assertBatchHasBeenStarted();

        return Promise.fromCallback(callback => {
                return this.auth(put(this.papiUrl('/batches/' + this.currentBatchId +'/'))).end(callback);
            })
            .then(res => {
                this.currentBatchId = undefined;
                return res;
            });
    }
Пример #5
0
    startBatch(): Promise<Response> {
        if (this.currentBatchId) {
            throw new Error('The following batch is already started: ' + this.currentBatchId);
        }

        return Promise.fromCallback(callback => {
                return this.auth(post(this.papiUrl('/batches/'))).end(callback);
            })
            .then(res => {
                this.currentBatchId = res.body.id;
                return res;
            });
    }
export function getOptions(): Bluebird<any> {
  let rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
  });

  let credentials: any = {};

  return Bluebird.fromCallback((cb) => {
      rl.question("Email: ", (res) => cb(null, res));
    })
    .then((email: string) => {
      credentials.email = email;
      return Bluebird.fromCallback((cb) => {
        rl.question("Password: ", (res) => cb(null, res));
      })
    })
    .then((password: string) => {
      credentials.password = password;
      console.log(credentials);
      return {credentials: credentials};
    });
}
Пример #7
0
export function getOptions(): Bluebird<any> {
  let rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
  });


  let username: string = null;
  let password: string = null;

  return Bluebird.fromCallback((cb) => {
      rl.question("Username: "******"Password: ", (res) => cb(null, res));
      })
    })
    .then((password: string) => {
      password = password;
      return {credentials: {username: username, password: password}};
    });
}
Пример #8
0
 /**
  *
  * @returns {Bluebird<T>}
  */
 deleteBin() {
   return Promise.fromCallback((cb) => {
     return unlink(this.getPath(), cb);
   }).then(() => true).catch(() => false);
 }
 .then((email: string) => {
   credentials.email = email;
   return Bluebird.fromCallback((cb) => {
     rl.question("Password: ", (res) => cb(null, res));
   })
 })
Пример #10
0
const createTunnelProxy = () =>
	Promise.fromCallback(cb => {
		tunnelProxy = new nodeTunnel.Tunnel();
		tunnelProxy.listen(tunnelPort, cb);
	});