Best JavaScript code snippet using best
web.js
Source:web.js
1/* jshint -W097 */2/* jshint strict: false */3/* jslint node: true */4/* jshint -W061 */5'use strict';6const Stream = require('stream');7const utils = require('@iobroker/adapter-core'); // Get common adapter utils8const LE = require(utils.controllerDir + '/lib/letsencrypt.js');9const express = require('express');10const fs = require('fs');11let path = require('path');1213let session;14let bodyParser;15let AdapterStore;16let password;17let passport;18let LocalStrategy;19let flash;20let cookieParser;21let fileUpload;22let socketIoFile;2324function Web(settings, adapter, onReady) {25 if (!(this instanceof Web)) return new Web(settings, adapter, onReady);26 const server = {27 app: null,28 server: null29 };30 const bruteForce = {};31 let store = null;32 let loginPage;33 this.server = server;3435 this.close = () => server.server && server.server.close();3637 function decorateLogFile(filename) {38 const prefix = '<html><head>' +39 '<style>\n' +40 ' table {' +41 ' font-family: monospace;\n' +42 ' font-size: 14px;\n' +43 ' }\n' +44 ' .info {\n' +45 ' background: white;' +46 ' }\n' +47 ' .type {\n' +48 ' font-weight: bold;' +49 ' }\n' +50 ' .silly {\n' +51 ' background: #b3b3b3;' +52 ' }\n' +53 ' .debug {\n' +54 ' background: lightgray;' +55 ' }\n' +56 ' .warn {\n' +57 ' background: #ffdb75;' +58 ' color: white;' +59 ' }\n' +60 ' .error {\n' +61 ' background: #ff6a5b;' +62 ' }\n' +63 '</style>\n' +64 '<script>\n' +65 'function decorate (line) {\n' +66 ' var className = "info";\n' +67 ' line = line.replace(/\\x1B\\[39m/g, "</span>");\n' +68 ' if (line.indexOf("[32m") !== -1) {\n' +69 ' className = "info";\n'+70 ' line = line.replace(/\\x1B\\[32m/g, "<span class=\\"type\\">");\n' +71 ' } else \n' +72 ' if (line.indexOf("[34m") !== -1) {\n' +73 ' className = "debug";\n'+74 ' line = line.replace(/\\x1B\\[34m/g, "<span class=\\"type\\">");\n' +75 ' } else \n' +76 ' if (line.indexOf("[33m") !== -1) {\n' +77 ' className = "warn";\n'+78 ' line = line.replace(/\\x1B\\[33m/g, "<span class=\\"type\\">");\n' +79 ' } else \n' +80 ' if (line.indexOf("[31m") !== -1) {\n' +81 ' className = "error";\n'+82 ' line = line.replace(/\\x1B\\[31m/g, "<span class=\\"type\\">");\n' +83 ' } else \n' +84 ' if (line.indexOf("[35m") !== -1) {\n' +85 ' className = "silly";\n'+86 ' line = line.replace(/\\x1B\\[35m/g, "<span class=\\"type\\">");\n' +87 ' } else {\n' +88 ' }\n' +89 ' return "<tr class=\\"" + className + "\\"><td>" + line + "</td></tr>";\n'+90 '}\n' +91 'document.addEventListener("DOMContentLoaded", function () { \n' +92 ' var text = document.body.innerHTML;\n' +93 ' var lines = text.split("\\n");\n' +94 ' text = "<table>";\n' +95 ' for (var i = 0; i < lines.length; i++) {\n' +96 ' if (lines[i]) text += decorate(lines[i]);\n' +97 ' }\n' +98 ' text += "</table>";\n' +99 ' document.body.innerHTML = text;\n' +100 ' window.scrollTo(0,document.body.scrollHeight);\n' +101 '});\n' +102 '</script>\n</head>\n<body>\n';103 const suffix = '</body></html>';104 const log = fs.readFileSync(filename).toString();105 return prefix + log + suffix;106 }107108 function prepareLoginTemplate() {109 let def = 'background: #64b5f6;\n';110 let template = fs.readFileSync(__dirname + '/../www/login/index.html').toString('utf8');111 if (adapter.config.loginBackgroundColor) {112 def = 'background-color: ' + adapter.config.loginBackgroundColor + ';\n'113 }114 if (adapter.config.loginBackgroundImage) {115 def += ' background-image: url(../' + adapter.namespace + '/login-bg.png);\n';116 }117 if (adapter.config.loginHideLogo) {118 template = template.replace('.logo { display: block }', '.logo { display: none }');119 }120 if (adapter.config.loginMotto) {121 template = template.replace('Discover awesome. <a href="http://iobroker.net/" target="_blank">ioBroker</a>', adapter.config.loginMotto);122 }123 return template.replace('background: #64b5f6;', def);124 }125126 //settings: {127 // "port": 8080,128 // "auth": false,129 // "secure": false,130 // "bind": "0.0.0.0", // "::"131 // "cache": false132 //}133 (function __construct () {134 if (settings.port) {135 server.app = express();136137 server.app.disable('x-powered-by');138139 // enable use of i-frames together with HTTPS140 server.app.get('/*', (req, res, next) => {141 res.header('X-Frame-Options', 'SAMEORIGIN');142 next(); // http://expressjs.com/guide.html#passing-route control143 });144145 if (settings.auth) {146 session = require('express-session');147 cookieParser = require('cookie-parser');148 bodyParser = require('body-parser');149 AdapterStore = require(utils.controllerDir + '/lib/session.js')(session, settings.ttl);150 password = require(utils.controllerDir + '/lib/password.js');151 passport = require('passport');152 LocalStrategy = require('passport-local').Strategy;153 flash = require('connect-flash'); // TODO report error to user154155 store = new AdapterStore({adapter: adapter});156157 passport.use(new LocalStrategy(158 (username, password, done) => {159 if (bruteForce[username] && bruteForce[username].errors > 4) {160 let minutes = (new Date().getTime() - bruteForce[username].time);161 if (bruteForce[username].errors < 7) {162 if ((new Date().getTime() - bruteForce[username].time) < 60000) {163 minutes = 1;164 } else {165 minutes = 0;166 }167 } else168 if (bruteForce[username].errors < 10) {169 if ((new Date().getTime() - bruteForce[username].time) < 180000) {170 minutes = Math.ceil((180000 - minutes) / 60000);171 } else {172 minutes = 0;173 }174 } else175 if (bruteForce[username].errors < 15) {176 if ((new Date().getTime() - bruteForce[username].time) < 600000) {177 minutes = Math.ceil((600000 - minutes) / 60000);178 } else {179 minutes = 0;180 }181 } else182 if ((new Date().getTime() - bruteForce[username].time) < 3600000) {183 minutes = Math.ceil((3600000 - minutes) / 60000);184 } else {185 minutes = 0;186 }187188 if (minutes) {189 return done('Too many errors. Try again in ' + minutes + ' ' + (minutes === 1 ? 'minute' : 'minutes') + '.', false);190 }191 }192 adapter.checkPassword(username, password, res => {193 if (!res) {194 bruteForce[username] = bruteForce[username] || {errors: 0};195 bruteForce[username].time = new Date().getTime();196 bruteForce[username].errors++;197 } else if (bruteForce[username]) {198 delete bruteForce[username];199 }200201 if (res) {202 return done(null, username);203 } else {204 return done(null, false);205 }206 });207208 }209 ));210 passport.serializeUser((user, done) => done(null, user));211212 passport.deserializeUser((user, done) => done(null, user));213214 server.app.use(cookieParser());215 server.app.use(bodyParser.urlencoded({216 extended: true217 }));218 server.app.use(bodyParser.json());219 server.app.use(session({220 secret: settings.secret,221 saveUninitialized: true,222 resave: true,223 cookie: {224 maxAge: adapter.config.ttl * 1000225 },226 store: store227 }));228 server.app.use(passport.initialize());229 server.app.use(passport.session());230 server.app.use(flash());231232 server.app.post('/login', (req, res, next) => {233 let redirect = '/';234 if (req.body.origin) {235 const parts = req.body.origin.match(/href=(.+)$/);236 if (parts && parts[1]) {237 redirect = decodeURIComponent(parts[1]);238 }239 }240 passport.authenticate('local', {241 successRedirect: redirect,242 failureRedirect: '/login/index.html' + req.body.origin + (req.body.origin ? '&error' : '?error'),243 failureFlash: 'Invalid username or password.'244 })(req, res, next);245 });246247 server.app.get('/logout', (req, res) => {248 req.logout();249 res.redirect('/login/index.html');250 });251252 server.app.get('/login/index.html', (req, res) => {253 loginPage = loginPage || prepareLoginTemplate();254 res.contentType('text/html');255 res.status(200).send(loginPage);256 });257258 // route middleware to make sure a user is logged in259 server.app.use((req, res, next) => {260 if (!req.isAuthenticated()) {261 if (/admin\.\d+\/login-bg\.png(\?.*)?$/.test(req.originalUrl)) {262 // Read names of files for gong263 adapter.objects.readFile(adapter.namespace, 'login-bg.png', null, (err, file) => {264 if (!err && file) {265 res.set('Content-Type', 'image/png');266 res.status(200).send(file);267 } else {268 res.status(404).send();269 }270 });271 } else if (/^\/login\//.test(req.originalUrl) ||272 /\.ico(\?.*)?$/.test(req.originalUrl)) {273 return next();274 } else {275 res.redirect('/login/index.html?href=' + encodeURIComponent(req.originalUrl));276 }277 } else {278 // special solution for socket.io279 if (socketIoFile !== false && (req.url.startsWith('socket.io.js') || req.url.match(/\/socket\.io\.js(\?.*)?$/))) {280 if (socketIoFile) {281 res.contentType('text/javascript');282 res.status(200).send(socketIoFile);283 return284 } else {285 try {286 const dir = require.resolve('socket.io-client');287 const fileDir = path.join(path.dirname(dir), '../dist/');288 if (fs.existsSync(fileDir + 'socket.io.min.js')) {289 socketIoFile = fs.readFileSync(fileDir + 'socket.io.min.js');290 } else {291 socketIoFile = fs.readFileSync(fileDir + 'socket.io.js');292 }293 } catch (e) {294 try {295 socketIoFile = fs.readFileSync(path.join(__dirname, '../www/lib/js/socket.io.js'));296 } catch (e) {297 adapter.log.error('Cannot read socket.io.js: ' + e);298 socketIoFile = false;299 }300 }301 if (socketIoFile) {302 res.contentType('text/javascript');303 res.status(200).send(socketIoFile);304 return305 }306 }307 }308309 return next();310 }311 });312 } else {313 server.app.get('/login', (req, res) => {314 res.redirect('/');315 });316 server.app.get('/logout', (req, res) => {317 res.redirect('/');318 });319 }320321 server.app.get('/zip/*', (req, res) => {322 let parts = req.url.split('/');323 let filename = parts.pop();324325 adapter.getBinaryState('system.host.' + adapter.host + '.zip.' + filename, (err, buff) => {326 if (err) {327 res.status(500).send(err);328 } else {329 if (!buff) {330 res.status(404).send('File package.zip not found');331 } else {332 // remove file333 adapter.delBinaryState && adapter.delBinaryState('system.host.' + adapter.host + '.zip.' + filename);334 res.set('Content-Type', 'application/zip');335 res.send(buff);336 }337 }338 });339 });340341 // send log files342 server.app.get('/log/*', (req, res) => {343 let parts = req.url.split('/');344 parts = parts.splice(2);345 const transport = parts.shift();346 let filename = parts.join('/');347 const config = adapter.systemConfig;348 // detect file log349 if (config && config.log && config.log.transport) {350 if (config.log.transport.hasOwnProperty(transport) && config.log.transport[transport].type === 'file') {351 if (config.log.transport[transport].filename) {352 parts = config.log.transport[transport].filename.replace(/\\/g, '/').split('/');353 parts.pop();354 filename = path.join(parts.join('/'), filename);355 } else {356 filename = path.join('log/', filename) ;357 }358359 if (filename[0] !== '/' && !filename.match(/^\W:/)) {360 filename = path.normalize(__dirname + '/../../../') + filename;361 }362363 if (fs.existsSync(filename)) {364 const stat = fs.lstatSync(filename);365 if (stat.size > 2 * 1024 * 1024) {366 res.sendFile(filename);367 } else {368 res.send(decorateLogFile(filename));369 }370371 return;372 }373 }374 }375 res.status(404).send('File ' + filename + ' not found');376 });377 const appOptions = {};378 if (settings.cache) {379 appOptions.maxAge = 30758400000;380 }381382 if (settings.tmpPathAllow && settings.tmpPath) {383 server.app.use('/tmp/', express.static(settings.tmpPath, {maxAge: 0}));384 fileUpload = fileUpload || require('express-fileupload');385 server.app.use(fileUpload({386 useTempFiles: true,387 tempFilePath: settings.tmpPath388 }));389 server.app.post('/upload', (req, res) => {390 if (!req.files) {391 return res.status(400).send('No files were uploaded.');392 }393394 // The name of the input field (i.e. "sampleFile") is used to retrieve the uploaded file395 let myFile;396 for (const name in req.files) {397 if (req.files.hasOwnProperty(name)) {398 myFile = req.files[name];399 break;400 }401 }402403 if (myFile) {404 if (myFile.data && myFile.data.length > 600 * 1024 * 1024) {405 return res.status(500).send('File is too big. (Max 600MB)');406 }407 // Use the mv() method to place the file somewhere on your server408 myFile.mv(settings.tmpPath + '/restore.iob', err => {409 if (err) {410 res.status(500).send(err);411 } else {412 res.send('File uploaded!');413 }414 });415 } else {416 return res.status(500).send('File not uploaded');417 }418 });419 }420421 if (!fs.existsSync(__dirname + '/../www')) {422 server.app.use('/', (req, res) => {423 res.send('This adapter cannot be installed directly from github.<br>You must install it from npm.<br>Write for that <i>"npm install iobroker.admin"</i> in according directory.');424 });425 } else {426 server.app.use('/', express.static(__dirname + '/../www', appOptions));427 }428429 // reverse proxy with url rewrite for couchdb attachments in <adapter-name>.admin430 server.app.use('/adapter/', (req, res) => {431432 // Example: /example/?0433 let url = req.url;434435 // add index.html436 url = url.replace(/\/($|\?|#)/, '/index.html$1');437438 // Read config files for admin from /adapters/admin/admin/...439 if (url.substring(0, '/' + adapter.name + '/'.length) === '/' + adapter.name + '/') {440 url = url.replace('/' + adapter.name + '/', __dirname + '/../admin/');441 url = url.replace(/\?[0-9]*/, '');442443 try {444 if (fs.existsSync(url)) {445 fs.createReadStream(url).pipe(res);446 } else {447 const ss = new Stream();448 ss.pipe = dest => dest.write('File not found');449450 ss.pipe(res);451 }452 } catch (e) {453 const s = new Stream();454 s.pipe = dest => dest.write('File not found: ' + e);455456 s.pipe(res);457 }458 return;459 }460 url = url.split('/');461 // Skip first /462 url.shift();463 // Get ID464 const id = url.shift() + '.admin';465 url = url.join('/');466 const pos = url.indexOf('?');467 if (pos !== -1) {468 url = url.substring(0, pos);469 }470 adapter.readFile(id, url, null, (err, buffer, mimeType) => {471 if (!buffer || err) {472 res.contentType('text/html');473 res.status(404).send('File ' + url + ' not found');474 } else {475 if (mimeType) {476 res.contentType(mimeType['content-type'] || mimeType);477 } else {478 res.contentType('text/javascript');479 }480 res.send(buffer);481 }482 });483 });484485 server.server = LE.createServer(server.app, settings, adapter.config.certificates, adapter.config.leConfig, adapter.log);486 server.server.__server = server;487 } else {488 adapter.log.error('port missing');489 adapter.terminate ? adapter.terminate('port missing', 1) : process.exit(1);490 }491492 if (server.server) {493 settings.port = parseInt(settings.port, 10);494495 adapter.getPort(settings.port, port => {496 if (port !== settings.port && !adapter.config.findNextPort) {497 adapter.log.error('port ' + settings.port + ' already in use');498 adapter.terminate ? adapter.terminate('port ' + settings.port + ' already in use', 1) : process.exit(1);499 }500 server.server.listen(port, (!settings.bind || settings.bind === '0.0.0.0') ? undefined : settings.bind || undefined);501502 adapter.log.info('http' + (settings.secure ? 's' : '') + ' server listening on port ' + port);503 adapter.log.info('Use link "http' + (settings.secure ? 's' : '') + '://localhost:' + port + '" to configure.');504505 if (typeof onReady === 'function') {506 onReady(server.server, store);507 }508 });509 }510511 if (server.server) {512 return server;513 } else {514 return null;515 }516 })();517518 return this;519}520
...
gatsby-node.js
Source:gatsby-node.js
1const fs = require('fs')2const path = require('path')3const cheerio = require('cheerio')4const crypto = require('crypto');5const WriteFilePlugin = require('write-file-webpack-plugin')6const SHA_ALGO = 'sha512'7const BASE_URL = 'http://localhost:8000'8const getContentSecurityPolicy = (text) => {9 const hash = crypto.createHash(SHA_ALGO);10 hash.update(text)11 const sha = hash.digest('base64')12 return `'${SHA_ALGO}-${sha}'`13}14const getFile = (file) => {15 const { INIT_CWD } = process.env16 return path.join(INIT_CWD, file)17}18const getFileInPublic = (file) => getFile(path.join('public', file))19const copyManifestFile = () => {20 const filePath = getFile('manifest.json')21 const manifest = JSON.parse(fs.readFileSync(filePath, 'utf8'))22 if (process.env.NODE_ENV === 'development') {23 manifest.content_security_policy = manifest.content_security_policy.replace(';', ` ${BASE_URL};`)24 } else {25 const $ = cheerio.load(fs.readFileSync(getFileInPublic('index.html')))26 const scripts = []27 $('script').each(function (_, element) {28 const content = $(this).html()29 scripts.push(content)30 })31 const contentSecurityPolicies = scripts.filter(x => x).map(getContentSecurityPolicy)32 manifest.content_security_policy = manifest.content_security_policy.replace(';', ` ${contentSecurityPolicies.join(' ')};`)33 }34 fs.writeFileSync(35 getFileInPublic('manifest.json'),36 JSON.stringify(manifest)37 )38}39exports.onPreInit = ({ reporter }) => {40 const activity = reporter.activityTimer(`Setup process.env.GATSBY_WEBPACK_PUBLICPATH`)41 activity.start()42 if (!process.env.GATSBY_WEBPACK_PUBLICPATH) {43 process.env.GATSBY_WEBPACK_PUBLICPATH = BASE_URL + '/'44 }45 activity.end()46}47exports.onCreateDevServer = ({ reporter }) => {48 const activity = reporter.activityTimer(`Rewrite index.html & copy manifest.json`)49 activity.start()50 const htmlFile = getFileInPublic('index.html')51 const $ = cheerio.load(fs.readFileSync(htmlFile))52 $('script').each(function (_, element) {53 const $$ = $(this)54 const src = `${BASE_URL}${$$.attr('src')}`55 $$.attr('src', src)56 })57 fs.writeFileSync(htmlFile, $.html())58 copyManifestFile()59 activity.end()60}61exports.onPostBootstrap = ({ reporter }) => {62 const activity = reporter.activityTimer(`Setup .cache/socketIo.js`)63 const socketIoFile = getFile('.cache/socketIo.js')64 const socketIoFileContent = fs.readFileSync(socketIoFile, 'utf8')65 fs.writeFileSync(socketIoFile, socketIoFileContent.replace('= io()', `= io('${BASE_URL}')`))66 activity.end()67}68exports.onPostBuild = async ({ reporter }, pluginOptions) => {69 const activity = reporter.activityTimer(`Build manifest.json`)70 activity.start()71 copyManifestFile()72 activity.end()73}74exports.onCreateWebpackConfig = ({ stage, getConfig, actions }) => {75 const config = getConfig()76 if (stage != 'develop') {77 return78 }79 const { plugins, output, entry } = config80 actions.replaceWebpackConfig({81 ...config,82 output: { ...output, path: getFile('public') },83 plugins: [...plugins, new WriteFilePlugin()]84 })...
index.d.ts
Source:index.d.ts
1// Type definitions for socket.io-file 2.02// Project: https://github.com/rico345100/socket.io-file3// Definitions by: Dief Bell <https://github.com/merrickking>4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped5// TypeScript Version: 2.36import { Socket } from 'socket.io';7export = SocketIOFile;8declare class SocketIOFile {9 constructor(socket: Socket, options: Options);10 on(event: string, cb: (fileInfo: FileInfo) => void): void;11}12interface Options {13 uploadDir: string | { [dirId: string]: string };14 maxFileSize?: number | undefined;15 accepts?: string[] | undefined;16 chunkSize?: number | undefined;17 transmissionDelay?: number | undefined;18 overwrite?: boolean | undefined;19 rename?: ((fileName: string, fileInfo: FileInfo) => string | string) | undefined;20 resume?: boolean | undefined;21}22interface FileInfo {23 name: string;24 size: number;25 path: string;26 wrote: number;27 uploadDir: string;28 data: any[];29 mime: string;30 estimated: number;31 uploadId: string;32 originalFileName: string;...
Using AI Code Generation
1var SocketIOFile = require('socket.io-file');2var io = require('socket.io').listen(3000);3io.sockets.on('connection', function (socket) {4 var uploader = new SocketIOFile(socket, {5 });6 uploader.on('start', function (fileInfo) {7 console.log('Start uploading');8 console.log(fileInfo);9 });10 uploader.on('stream', function (fileInfo) {11 console.log(`${fileInfo.wrote} / ${fileInfo.size} byte(s)`);12 });13 uploader.on('complete', function (fileInfo) {14 console.log('Upload Complete.');15 console.log(fileInfo);16 });17 uploader.on('error', function (err) {18 console.log('Error!', err);19 });20 uploader.on('abort', function (fileInfo) {21 console.log('Aborted: ', fileInfo);22 });23});24var SocketIOFile = require('socket.io-file');25var io = require('socket.io').listen(3000);26io.sockets.on('connection', function (socket) {27 var uploader = new SocketIOFile(socket, {
Using AI Code Generation
1var fs = require('fs');2var http = require('http');3var SocketIOFile = require('socket.io-file');4var server = http.createServer(function(req, res) {5 res.writeHead(200, { 'Content-Type': 'text/html' });6 res.end(fs.readFileSync(__dirname + '/index.html'));7});8server.listen(8080);9var io = require('socket.io').listen(server);10io.on('connection', function(socket) {11 var uploader = new SocketIOFile(socket, {12 });13 uploader.on('start', function(fileInfo) {14 console.log('Start uploading');15 console.log(fileInfo);16 });17 uploader.on('stream', function(fileInfo) {18 console.log(`${fileInfo.wrote} / ${fileInfo.size} byte(s)`);19 });20 uploader.on('complete', function(fileInfo) {21 console.log('Upload Complete.');22 console.log(fileInfo);23 });24 uploader.on('error', function(err) {25 console.log('Error!', err);26 });27 uploader.on('abort', function(fileInfo) {28 console.log('Aborted: ', fileInfo);29 });30});31 var uploader = new SocketIOFileUpload(document.getElementById('file'));32 uploader.listenOnInput(document.getElementById
Using AI Code Generation
1var SocketIOFile = require('socket.io-file');2var fs = require('fs');3var io = require('socket.io')(8000);4io.on('connection', function (socket) {5 var uploader = new SocketIOFile(socket, {6 });7 uploader.on('start', function (fileInfo) {8 console.log('Start uploading');9 console.log(fileInfo);10 });11 uploader.on('stream', function (fileInfo) {12 console.log(`${fileInfo.wrote} / ${fileInfo.size} byte(s)`);13 });14 uploader.on('complete', function (fileInfo) {15 console.log('Upload Complete.');16 console.log(fileInfo);17 });18 uploader.on('error', function (err) {19 console.log('Error!', err);20 });21 uploader.on('abort', function (fileInfo) {22 console.log('Aborted: ', fileInfo);23 });24});25var SocketIOFile = require('socket.io-file');26var fs = require('fs');27var io = require('socket.io')(8000);28io.on('connection', function (socket) {29 var uploader = new SocketIOFile(socket, {
Using AI Code Generation
1var express = require('express');2var app = express();3var http = require('http').Server(app);4var io = require('socket.io')(http);5var fs = require('fs');6var path = require('path');7var bodyParser = require('body-parser');8var multer = require('multer');9var upload = multer({dest: 'uploads/'});10var port = 3000;11app.use(express.static(__dirname + '/public'));12app.use(bodyParser.json());13app.use(bodyParser.urlencoded({extended: true}));14app.get('/', function(req, res){15 res.sendFile(__dirname + '/index.html');16});17app.post('/upload', upload.single('singleInputFileName'), function(req, res){18 console.log(req.file);19 res.send('uploaded');20});21io.on('connection', function(socket){22 console.log('a user connected');23 socket.on('disconnect', function(){24 console.log('user disconnected');25 });26});27http.listen(port, function(){28 console.log('listening on *:' + port);29});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!