UNPKG

vpn.email

Version:
48 lines (37 loc) 1.19 kB
import * as util from './util' import * as fs from 'fs' import * as express from 'express' import * as http from 'http' import * as https from 'https' import * as testImapAccount from './testImapAccount' import * as smtp from './smtpClass' import * as async from 'async' const jsonCallBack = ( res: express.Response, err: Error, data: any ) => { const ret: IJsonRespon = { err: err ? err.message : null, data: data } res.json ( JSON.stringify ( ret )); } module.exports = function ( obj: any ) { let app: express.Router = obj.app; let chartIo: SocketIO.Server = obj.io; app.post( "/api/testUrl", ( req, res ) => { var url:string = req.body.url; if( url.match ( 'https' )){ https.get ( url, ()=>{ res.json ( '0' ); }).on("error", () => { res.json ('-1') }); } else { http.get(url, ()=>{ res.json('0'); }).on("error", ()=>{ res.json('-1') }); } }); }