How to use projectId method in Best

Best JavaScript code snippet using best

api.js

Source:api.js Github

copy

Full Screen

1import axios from 'axios';2import segment from './lib/segment';3import config from './config';4axios.defaults.withCredentials = true;5const url = path => `${config.endpoint}/${path}`;6const get = (path, ...rest) => axios.get(url(path), ...rest);7const post = (path, ...rest) => axios.post(url(path), ...rest);8const del = (path, ...rest) => axios.delete(url(path), ...rest);9const put = (path, ...rest) => axios.put(url(path), ...rest);10const patch = (path, ...rest) => axios.patch(url(path), ...rest);11const api = {12 login: ({ email, password }) => post('login', { email, password }),13 loginSSO: data => post('loginsso', data),14 logout: () =>15 post('logout').then(() => {16 segment.reset();17 }),18 signup: ({ email, password }) =>19 post(`register`, {20 email,21 password,22 }),23 signupSSO: data => post('registersso', data),24 completeRegistration: ({ registrationTokenValue }) =>25 post('completeregistration', { registrationTokenValue }),26 resetPassword: ({ email }) => post('recoverpassword', { email }),27 verifyPasswordResetToken: ({ token }) =>28 get(`passwordrecoverytokens/${token}`),29 updatePassword: ({ token, password }) =>30 post('changepassword', {31 passwordRecoveryTokenValue: token,32 password,33 }),34 user: () => get('me'),35 updateUser: data => patch('me', data),36 project: ({ projectId }) => get(`projects/${projectId}`),37 projects: () =>38 get(`memberships?full`).then(({ data }) =>39 data.map(({ project }) => project)40 ),41 createProject: data =>42 post(`projects`, data).then(response => {43 segment.track('Project Created');44 return response;45 }),46 updateProject: ({ projectId, data }) => put(`projects/${projectId}`, data),47 deleteProject: ({ projectId }) => del(`projects/${projectId}`),48 devices: ({ projectId, queryString = '' }) =>49 get(`projects/${projectId}/devices${queryString}`),50 scheduledDevices: ({ projectId, applicationId, schedulingRule, search }) =>51 get(52 `projects/${projectId}/devices/previewscheduling/${applicationId}?search=${encodeURIComponent(53 search54 )}&schedulingRule=${encodeURIComponent(55 btoa(JSON.stringify(schedulingRule))56 )}`57 ),58 device: ({ projectId, deviceId }) =>59 get(`projects/${projectId}/devices/${deviceId}?full`),60 updateDevice: ({ projectId, deviceId, data: { name } }) =>61 patch(`projects/${projectId}/devices/${deviceId}`, { name }),62 deleteDevice: ({ projectId, deviceId }) =>63 del(`projects/${projectId}/devices/${deviceId}`),64 reboot: ({ projectId, deviceId }) =>65 post(`projects/${projectId}/devices/${deviceId}/reboot`, {}),66 addDeviceLabel: ({ projectId, deviceId, data }) =>67 put(`projects/${projectId}/devices/${deviceId}/labels`, data).then(68 response => {69 segment.track('Device Label Added');70 return response;71 }72 ),73 removeDeviceLabel: ({ projectId, deviceId, labelId }) =>74 del(`projects/${projectId}/devices/${deviceId}/labels/${labelId}`),75 addEnvironmentVariable: ({ projectId, deviceId, data }) =>76 put(77 `projects/${projectId}/devices/${deviceId}/environmentvariables`,78 data79 ).then(response => {80 segment.track('Environment Variable Added');81 return response;82 }),83 removeEnvironmentVariable: ({ projectId, deviceId, key }) =>84 del(85 `projects/${projectId}/devices/${deviceId}/environmentvariables/${key}`86 ),87 defaultRegistrationToken: ({ projectId }) =>88 get(`projects/${projectId}/deviceregistrationtokens/default`),89 registrationToken: ({ projectId, tokenId }) =>90 get(`projects/${projectId}/deviceregistrationtokens/${tokenId}?full`),91 registrationTokens: ({ projectId }) =>92 get(`projects/${projectId}/deviceregistrationtokens?full`),93 createRegistrationToken: ({94 projectId,95 data: { name, description, maxRegistrations },96 }) =>97 post(`projects/${projectId}/deviceregistrationtokens`, {98 name,99 description,100 maxRegistrations: Number.parseInt(maxRegistrations),101 }).then(response => {102 segment.track('Registration Token Created');103 return response;104 }),105 updateRegistrationToken: ({106 projectId,107 tokenId,108 data: { name, description, maxRegistrations, settings },109 }) =>110 put(`projects/${projectId}/deviceregistrationtokens/${tokenId}`, {111 name,112 description,113 maxRegistrations: Number.parseInt(maxRegistrations),114 settings,115 }),116 deleteRegistrationToken: ({ projectId, tokenId }) =>117 del(`projects/${projectId}/deviceregistrationtokens/${tokenId}`),118 addRegistrationTokenLabel: ({ projectId, tokenId, data }) =>119 put(120 `projects/${projectId}/deviceregistrationtokens/${tokenId}/labels`,121 data122 ),123 removeRegistrationTokenLabel: ({ projectId, tokenId, labelId }) =>124 del(125 `projects/${projectId}/deviceregistrationtokens/${tokenId}/labels/${labelId}`126 ),127 addRegistrationTokenEnvironmentVariable: ({ projectId, tokenId, data }) =>128 put(129 `projects/${projectId}/deviceregistrationtokens/${tokenId}/environmentvariables`,130 data131 ).then(response => {132 segment.track('Registration Token Environment Variable Added');133 return response;134 }),135 removeRegistrationTokenEnvironmentVariable: ({ projectId, tokenId, key }) =>136 del(137 `projects/${projectId}/deviceregistrationtokens/${tokenId}/environmentvariables/${key}`138 ),139 applications: ({ projectId }) =>140 get(`projects/${projectId}/applications?full`),141 application: ({ projectId, applicationId }) =>142 get(`projects/${projectId}/applications/${applicationId}?full`),143 createApplication: ({ projectId, data: { name, description } }) =>144 post(`projects/${projectId}/applications`, { name, description }).then(145 response => {146 segment.track('Application Created');147 return response;148 }149 ),150 connections: ({ projectId }) => get(`projects/${projectId}/connections`),151 connection: ({ projectId, connectionId }) =>152 get(`projects/${projectId}/connections/${connectionId}`),153 updateConnection: ({ projectId, connectionId, data }) =>154 put(`projects/${projectId}/connections/${connectionId}`, data),155 deleteConnection: ({ projectId, connectionId }) =>156 del(`projects/${projectId}/connections/${connectionId}`),157 createConnection: ({ projectId, data: { name, protocol, port } }) =>158 post(`projects/${projectId}/connections`, { name, protocol, port }).then(159 response => {160 segment.track('Connection Created');161 return response;162 }163 ),164 updateApplication: ({ projectId, applicationId, data }) =>165 patch(`projects/${projectId}/applications/${applicationId}`, data),166 deleteApplication: ({ projectId, applicationId }) =>167 del(`projects/${projectId}/applications/${applicationId}`),168 roles: ({ projectId }) => get(`projects/${projectId}/roles`),169 role: ({ projectId, roleId }) => get(`projects/${projectId}/roles/${roleId}`),170 createRole: ({ projectId, data: { name, description, config } }) =>171 post(`projects/${projectId}/roles`, { name, description, config }).then(172 response => {173 segment.track('Role Created');174 return response;175 }176 ),177 updateRole: ({ projectId, roleId, data: { name, description, config } }) =>178 put(`projects/${projectId}/roles/${roleId}`, { name, description, config }),179 deleteRole: ({ projectId, roleId }) =>180 del(`projects/${projectId}/roles/${roleId}`),181 memberships: ({ projectId }) => get(`projects/${projectId}/memberships?full`),182 membership: ({ projectId, userId }) =>183 get(`projects/${projectId}/memberships/${userId}?full`),184 addMember: ({ projectId, data: { email, userId } }) =>185 post(`projects/${projectId}/memberships`, { email, userId }).then(186 response => {187 segment.track('Member Added');188 return response;189 }190 ),191 removeMember: ({ projectId, userId }) =>192 del(`projects/${projectId}/memberships/${userId}`),193 addMembershipRoleBindings: ({ projectId, userId, roleId }) =>194 post(195 `projects/${projectId}/memberships/${userId}/roles/${roleId}/membershiprolebindings`,196 {}197 ),198 removeMembershipRoleBindings: ({ projectId, userId, roleId }) =>199 del(200 `projects/${projectId}/memberships/${userId}/roles/${roleId}/membershiprolebindings`201 ),202 serviceAccounts: ({ projectId }) =>203 get(`projects/${projectId}/serviceaccounts?full`),204 serviceAccount: ({ projectId, serviceId }) =>205 get(`projects/${projectId}/serviceaccounts/${serviceId}?full`),206 createServiceAccount: ({ projectId, data }) =>207 post(`projects/${projectId}/serviceaccounts`, data).then(response => {208 segment.track('Service Account Created');209 return response;210 }),211 updateServiceAccount: ({212 projectId,213 serviceId,214 data: { name, description },215 }) =>216 put(`projects/${projectId}/serviceaccounts/${serviceId}`, {217 name,218 description,219 }),220 deleteServiceAccount: ({ projectId, serviceId }) =>221 del(`projects/${projectId}/serviceaccounts/${serviceId}`),222 addServiceAccountRoleBindings: ({ projectId, serviceId, roleId }) =>223 post(224 `projects/${projectId}/serviceaccounts/${serviceId}/roles/${roleId}/serviceaccountrolebindings`,225 {}226 ),227 removeServiceAccountRoleBindings: ({ projectId, serviceId, roleId }) =>228 del(229 `projects/${projectId}/serviceaccounts/${serviceId}/roles/${roleId}/serviceaccountrolebindings`230 ),231 serviceAccountAccessKeys: ({ projectId, serviceId }) =>232 get(233 `projects/${projectId}/serviceaccounts/${serviceId}/serviceaccountaccesskeys`234 ),235 createServiceAccountAccessKey: ({ projectId, serviceId }) =>236 post(237 `projects/${projectId}/serviceaccounts/${serviceId}/serviceaccountaccesskeys`,238 {}239 ),240 deleteServiceAccountAccessKey: ({ projectId, serviceId, accessKeyId }) =>241 del(242 `projects/${projectId}/serviceaccounts/${serviceId}/serviceaccountaccesskeys/${accessKeyId}`243 ),244 releases: ({ projectId, applicationId }) =>245 get(`projects/${projectId}/applications/${applicationId}/releases?full`),246 release: ({ projectId, applicationId, releaseId }) =>247 get(248 `projects/${projectId}/applications/${applicationId}/releases/${releaseId}?full`249 ),250 createRelease: ({ projectId, applicationId, data: { rawConfig } }) =>251 post(`projects/${projectId}/applications/${applicationId}/releases`, {252 rawConfig,253 }).then(response => {254 segment.track('Release Created');255 return response;256 }),257 latestReleases: ({ projectId, applicationId }) =>258 get(`projects/${projectId}/applications/${applicationId}/releases/latest`),259 userAccessKeys: () => get(`useraccesskeys`),260 createUserAccessKey: () => post(`useraccesskeys`, {}),261 deleteUserAccessKey: ({ id }) => del(`useraccesskeys/${id}`),262 imagePullProgress: ({ projectId, deviceId, applicationId, serviceId }) =>263 get(264 `projects/${projectId}/devices/${deviceId}/applications/${applicationId}/services/${serviceId}/imagepullprogress`265 ),266};...

Full Screen

Full Screen

Mutation.externallink.spec.ts

Source:Mutation.externallink.spec.ts Github

copy

Full Screen

1import {2 doQuery,3 onAfterAll,4 onAfterEach,5 onBeforeAll,6 onBeforeEach,7 setupTestUsers, testEntityManager, testUser,8} from '../../../tests/graphqlTestEnvironment'9import { Project as ProjectModel, UserProjectRoleOptions as UPRO } from '../model'10import { ExternalLink } from '../ExternalLink'11import { PublicationStatusOptions as PSO } from '../Publishing'12import { createTestProject, createTestUserProject } from '../../../tests/testDataCreation'13describe('Project external links', () => {14 beforeAll(onBeforeAll)15 afterAll(onAfterAll)16 beforeEach(async() => {17 await onBeforeEach()18 await setupTestUsers()19 })20 afterEach(onAfterEach)21 interface ResultType {22 id: string;23 externalLinks: ExternalLink[] | null;24 }25 const addLink = async(projectId: string, provider: string, link: string, replaceExisting: boolean) =>26 await doQuery<ResultType>(`27 mutation($projectId: ID!, $provider: String!, $link: String!, $replaceExisting: Boolean!) {28 addProjectExternalLink(projectId: $projectId, provider: $provider, link: $link, replaceExisting: $replaceExisting) {29 id30 externalLinks { provider link }31 }32 }`, { projectId, provider, link, replaceExisting })33 const removeLink = async(projectId: string, provider: string, link?: string) =>34 await doQuery<ResultType>(`35 mutation($projectId: ID!, $provider: String!, $link: String) {36 removeProjectExternalLink(projectId: $projectId, provider: $provider, link: $link) {37 id38 externalLinks { provider link }39 }40 }`, { projectId, provider, link })41 const provider = 'MetaboLights'42 const link = 'https://www.ebi.ac.uk/metabolights/MTBLS313'43 const link2 = 'https://www.ebi.ac.uk/metabolights/MTBLS317'44 const link3 = 'https://www.ebi.ac.uk/metabolights/MTBLS378'45 const DOIProvider = 'DOI'46 const DOILink = 'https://doi.org/10.1038/nmeth.4072'47 it('Should be able to add links', async() => {48 const projectId = (await createTestProject()).id49 await createTestUserProject(testUser.id, projectId, UPRO.MANAGER)50 const result1 = await addLink(projectId, provider, link, false)51 await addLink(projectId, provider, link, false) // Duplication should do nothing52 const result2 = await addLink(projectId, provider, link2, false)53 const updatedProject = await testEntityManager.findOneOrFail(ProjectModel, projectId)54 expect(updatedProject.externalLinks).toEqual([{ provider, link }, { provider, link: link2 }])55 expect(result1.id).toEqual(projectId)56 expect(result1.externalLinks).toEqual([{ provider, link }])57 expect(result2.externalLinks).toEqual(updatedProject.externalLinks)58 })59 it('Should be able to overwrite existing links', async() => {60 const projectId = (await createTestProject()).id61 await createTestUserProject(testUser.id, projectId, UPRO.MANAGER)62 await addLink(projectId, provider, link, false)63 await addLink(projectId, provider, link2, false)64 const result = await addLink(projectId, provider, link3, true)65 const updatedProject = await testEntityManager.findOneOrFail(ProjectModel, projectId)66 expect(result.id).toEqual(projectId)67 expect(result.externalLinks).toEqual([68 { provider, link: link3 },69 ])70 expect(updatedProject.externalLinks).toEqual(result.externalLinks)71 })72 it('Should be able to remove specific links', async() => {73 const projectId = (await createTestProject()).id74 await createTestUserProject(testUser.id, projectId, UPRO.MANAGER)75 await addLink(projectId, provider, link, false)76 await addLink(projectId, provider, link2, false)77 const result = await removeLink(projectId, provider, link2)78 const updatedProject = await testEntityManager.findOneOrFail(ProjectModel, projectId)79 expect(updatedProject.externalLinks).toEqual([80 { provider, link },81 ])82 expect(result.id).toEqual(projectId)83 expect(result.externalLinks).toEqual(updatedProject.externalLinks)84 })85 it('Should be able to remove all links from a provider', async() => {86 const projectId = (await createTestProject()).id87 await createTestUserProject(testUser.id, projectId, UPRO.MANAGER)88 await addLink(projectId, provider, link, false)89 await addLink(projectId, provider, link2, false)90 const result = await removeLink(projectId, provider)91 const updatedProject = await testEntityManager.findOneOrFail(ProjectModel, projectId)92 expect(updatedProject.externalLinks).toEqual([])93 expect(result.id).toEqual(projectId)94 expect(result.externalLinks).toEqual(updatedProject.externalLinks)95 })96 it('Should be able to add DOI links from doi.org', async() => {97 const projectId = (await createTestProject({ publicationStatus: PSO.PUBLISHED })).id98 await createTestUserProject(testUser.id, projectId, UPRO.MANAGER)99 const result1 = await addLink(projectId, DOIProvider, DOILink, false)100 expect(result1.id).toEqual(projectId)101 expect(result1.externalLinks).toEqual([{ provider: DOIProvider, link: DOILink }])102 const updatedProject = await testEntityManager.findOneOrFail(ProjectModel, projectId)103 expect(updatedProject.externalLinks).toEqual([{ provider: DOIProvider, link: DOILink }])104 })105 it('Should not be able to add DOI links not from doi.org', async() => {106 const projectId = (await createTestProject({ publicationStatus: PSO.PUBLISHED })).id107 await createTestUserProject(testUser.id, projectId, UPRO.MANAGER)108 const promise = addLink(projectId, DOIProvider, link, false)109 await expect(promise).rejects.toThrow('DOI link should start with "https://doi.org/"')110 const updatedProject = await testEntityManager.findOneOrFail(ProjectModel, projectId)111 expect(updatedProject.externalLinks).toBe(null)112 })...

Full Screen

Full Screen

socket.js

Source:socket.js Github

copy

Full Screen

1const socketio = require('socket.io')2const winston = require('winston')3const Redis = require('ioredis')4const mongoose = require('mongoose')5const Project = mongoose.model('Project')6/**7 * @param {Object} server server instance8 */9module.exports = (server) => {10 // Initiate socket.io conection11 const io = socketio(server)12 // Initiate redis connection for persist data13 const redis = new Redis()14 const projects = {} // store users role in each project15 // Event routing16 io.on('connection', (client) => {17 // recieve project id from client and stored in projectId18 let projectId = ''19 let curUser = ''20 winston.info('Client connected')21 client.on('submit review', (payload) => {22 // projects[projectId]['reviews'].push(payload)23 winston.info(payload)24 io.in(projectId).emit('new review', payload)25 })26 /**27 * `join project` evnet trigged when user joining project in playground page28 * @param {Object} payload receive project id from client payload29 * after that socket will fire `init state` with editor code to initiate local editor30 */31 client.on('join project', async (payload) => {32 try {33 projectId = payload.pid34 curUser = payload.username35 winston.info(`User ${payload.username} joined at pid: ${payload.pid}`)36 client.join(projectId)37 Project.update({38 pid: projectId39 }, {40 $set: {41 createdAt: Date.now()42 }43 }, (err) => {44 if (err) throw err45 })46 // Checking if this project hasn't have any roles assigned.47 if (!projects[projectId]) {48 winston.info(`created new projects['${projectId}']`)49 projects[projectId] = {50 roles: {51 coder: '',52 reviewer: '',53 reviews: []54 },55 count: 156 }57 winston.info(projects[projectId].count)58 client.emit('role selection')59 } else {60 projects[projectId].count += 161 winston.info(projects[projectId].count)62 client.emit('role updated', projects[projectId])63 }64 client.emit('init state', {65 editor: await redis.hget(`project:${projectId}`, 'editor', (err, ret) => ret)66 })67 } catch (error) {68 winston.info(`catching error: ${error}`)69 }70 })71 /**72 * `role selected` event fired when one of the project user select his role73 * @param {Ibject} payload user selected role and partner username74 * then socket will broadcast the role to his partner75 */76 client.on('role selected', (payload) => {77 if (payload.select === 0) {78 projects[projectId].roles.reviewer = curUser79 projects[projectId].roles.coder = payload.partner80 } else {81 projects[projectId].roles.reviewer = payload.partner82 projects[projectId].roles.coder = curUser83 }84 io.in(projectId).emit('role updated', projects[projectId])85 })86 client.on('switch role', () => {87 const temp = projects[projectId].roles.coder88 projects[projectId].roles.coder = projects[projectId].roles.reviewer89 projects[projectId].roles.reviewer = temp90 io.in(projectId).emit('role updated', projects[projectId])91 })92 /**93 * `code change` event fired when user typing in editor94 * @param {Object} payload receive code from client payload95 */96 client.on('code change', (payload) => {97 const origin = !!payload.code.origin && (payload.code.origin !== 'setValue')98 // origin mustn't be an `undefined` or `setValue` type99 if (origin) {100 // winston.info(`Emitted 'editor update' to client with pid: ${projectId}`)101 client.to(projectId).emit('editor update', payload.code)102 redis.hset(`project:${projectId}`, 'editor', payload.editor)103 }104 })105 /**106 * `user status` event fired every 3 seconds for checking user status107 * @param {Object} payload user status from client-side108 */109 client.on('user status', (payload) => {110 client.to(projectId).emit('update status', payload)111 })112 /**113 * `run code` event fired when user click on run button from front-end114 * @param {Object} payload code from editor115 */116 client.on('run code', (payload) => {117 const fs = require('fs')118 const path = require('path')119 fs.writeFile('pytest.py', payload.code, (err) => {120 if (err) throw err121 })122 const nodepty = require('node-pty')123 const pty = nodepty.spawn('python', ['pytest.py'])124 pty.on('data', (data) => {125 io.in(projectId).emit('term update', data)126 })127 })128 /**129 * `disconnect` event fired when user exit from playground page130 * by exit means: reload page, close page/browser, session lost131 */132 client.on('disconnect', () => {133 try {134 projects[projectId].count -= 1135 winston.info(`user left project ${projectId} now has ${projects[projectId].count} user(s) online`)136 if (projects[projectId].count === 0) {137 delete projects[projectId]138 }139 client.leave(projectId)140 winston.info('Client disconnected')141 } catch (error) {142 winston.info(`catching error: ${error}`)143 }144 })145 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var bestBuy = require('bestbuy')(apiKey);2bestBuy.products('(search=ipod)', {show: 'sku,name,salePrice', pageSize: 15, page: 3})3 .then(function(data){4 console.log(data);5 })6 .catch(function(err){7 console.log(err);8 });9### BestBuy(apiKey)10### BestBuy.products(query, options)11### BestBuy.stores(query, options)12### BestBuy.categories(query, options)13### BestBuy.departments(query, options)

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestMovies = require('./BestMovies');2var movies = BestMovies();3movies.projectId(1);4module.exports = function() {5 return {6 projectId: function(id) {7 console.log('The id of the movie is: ' + id);8 }9 }10}

Full Screen

Using AI Code Generation

copy

Full Screen

1const BestBuy = require('./BestBuy.js');2const bestBuy = new BestBuy();3bestBuy.projectId(1000, 1001);4const BestBuy = require('./BestBuy.js');5const bestBuy = new BestBuy();6bestBuy.name('name', 'name2');7const BestBuy = require('./BestBuy.js');8const bestBuy = new BestBuy();9bestBuy.type('type', 'type2');10const BestBuy = require('./BestBuy.js');11const bestBuy = new BestBuy();12bestBuy.upc('upc', 'upc2');13const BestBuy = require('./BestBuy.js');14const bestBuy = new BestBuy();15bestBuy.shipping('shipping', 'shipping2');16const BestBuy = require('./BestBuy.js');17const bestBuy = new BestBuy();18bestBuy.description('description', 'description2');19const BestBuy = require('./BestBuy.js');20const bestBuy = new BestBuy();21bestBuy.manufacturer('manufacturer', 'manufacturer2');22const BestBuy = require('./BestBuy.js');23const bestBuy = new BestBuy();24bestBuy.model('model', 'model2');25const BestBuy = require('./BestBuy.js');26const bestBuy = new BestBuy();27bestBuy.url('url', 'url2');28const BestBuy = require('./BestBuy.js');29const bestBuy = new BestBuy();

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestPlaces = require('./index.js');2var bestPlaces = new BestPlaces();3bestPlaces.projectId('test', function(err, data) {4 console.log(err, data);5});61. Fork it (

Full Screen

Using AI Code Generation

copy

Full Screen

1var bestBuy = require('bestbuy')('g3q3h3b4t8y9a9c4j4y4d4y4');2var express = require('express');3var app = express();4var bodyParser = require('body-parser');5var path = require('path');6app.use(bodyParser.urlencoded({ extended: true }));7app.use(express.static(path.join(__dirname, './static')));8app.set('views', path.join(__dirname, './views'));9app.set('view engine', 'ejs');10app.get('/', function(req, res) {11 res.render('index');12})13app.post('/search', function(req, res) {14 bestBuy.products('(search='+req.body.search+')', {show: 'name,sku,regularPrice,salePrice,onSale,shortDescription,image', format: 'json', pageSize: 15}).then(function(data) {15 res.render('search', {products: data.products});16 }).catch(function(err) {17 console.log(err);18 });19})20app.post('/add', function(req, res) {21 var product = new BestBuy({name: req.body.name, price: req.body.price, category: req.body.category, description: req.body.description, image: req.body.image});22 product.save(function(err) {23 if(err) {24 console.log("something went wrong");25 } else {26 console.log("successfully added a product!");27 res.redirect('/');28 }29 })30})31app.get('/products', function(req, res) {32 BestBuy.find({}, function(err, products) {33 if(err) {34 console.log("something went wrong");35 } else {36 res.render('products', {products: products});37 }38 })39})40app.get('/products/:id', function(req, res) {41 BestBuy.findOne({_id: req.params

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Best automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful