Best JavaScript code snippet using argos
contractController.js
Source:contractController.js
...26exports.uploadDs = multer(multerOptions).single('ds');27exports.uploadActs = multer(multerOptions).single('acts');28exports.deleteContractFile = async (req, res) => {29 const contract = await Contract.findOneAndUpdate({ _id: req.params.id }, { $pull: { files: { path: req.params.path} } });30 await unlinkAsync('./public/uploads/' + req.params.path);31 req.flash('success', `Файл ÑÑпеÑно Ñдален`);32 res.redirect(`/contracts/${contract.slug}`);33}34exports.deleteContractDs = async (req, res) => {35 const contract = await Contract.findOneAndUpdate({ _id: req.params.id }, { $pull: { ds: { path: req.params.path} } });36 await unlinkAsync('./public/uploads/' + req.params.path);37 req.flash('success', `Файл ÑÑпеÑно Ñдален`);38 res.redirect(`/contracts/${contract.slug}`);39}40exports.deleteContractAct = async (req, res) => {41 const contract = await Contract.findOneAndUpdate({ _id: req.params.id }, { $pull: { acts: { path: req.params.path} } });42 await unlinkAsync('./public/uploads/' + req.params.path);43 req.flash('success', `Файл ÑÑпеÑно Ñдален`);44 res.redirect(`/contracts/${contract.slug}`);45}46exports.deleteContractClaim = async (req, res) => {47 const contract = await Contract.findOneAndUpdate({ _id: req.params.id }, { $pull: { claims: { path: req.params.path} } });48 await unlinkAsync('./public/uploads/' + req.params.path);49 req.flash('success', `Файл ÑÑпеÑно Ñдален`);50 res.redirect(`/contracts/${contract.slug}`);51}52exports.updateFiles = async (req, res) => {53 const contract = await Contract.findOneAndUpdate({ _id: req.params.id }, { $push: { files: { path: req.file.filename, name: req.file.originalname } } }, {54 new: true,55 runValidators: true56 }).exec();57 req.flash('success', `Ð¤Ð°Ð¹Ð»Ñ ÑÑпеÑно добавленÑ`);58 res.redirect(`/contracts/${contract.slug}`);59}60exports.updateDs = async (req, res) => {61 const contract = await Contract.findOneAndUpdate({ _id: req.params.id }, { $push: { ds: { path: req.file.filename, name: req.file.originalname } } }, {62 new: true,63 runValidators: true64 }).exec();65 req.flash('success', `Ð¤Ð°Ð¹Ð»Ñ ÑÑпеÑно добавленÑ`);66 res.redirect(`/contracts/${contract.slug}`);67}68exports.updateActs = async (req, res) => {69 const contract = await Contract.findOneAndUpdate({ _id: req.params.id }, { $push: { acts: { path: req.file.filename, name: req.file.originalname } } }, {70 new: true,71 runValidators: true72 }).exec();73 req.flash('success', `Ð¤Ð°Ð¹Ð»Ñ ÑÑпеÑно добавленÑ`);74 res.redirect(`/contracts/${contract.slug}`);75}76exports.updateClaims = async (req, res) => {77 const contract = await Contract.findOneAndUpdate({ _id: req.params.id }, { $push: { claims: { path: req.file.filename, name: req.file.originalname } } }, {78 new: true,79 runValidators: true80 }).exec();81 req.flash('success', `Ð¤Ð°Ð¹Ð»Ñ ÑÑпеÑно добавленÑ`);82 res.redirect(`/contracts/${contract.slug}`);83}84exports.addContract = async (req, res) => {85 const tenantsSearch = Tenant.find();86 const buildingSearch = Building.findOne({ _id: req.params.id });87 const [tenants, building] = await Promise.all([tenantsSearch, buildingSearch]);88 res.render('addContract', { mainTitle: 'ÐбÑекÑÑ', title: 'ÐобавиÑÑ Ð´Ð¾Ð³Ð¾Ð²Ð¾Ñ', tenants, building});89}90exports.createContract = async (req, res) => {91 req.body.debt = 0;92 const contract = await (new Contract(req.body).save())93 req.flash('success', `Ð´Ð¾Ð³Ð¾Ð²Ð¾Ñ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½.`);94 res.redirect(`/buildings/${req.body.buildingSlug}`);95}96exports.chartContractDistricts = async (req, res) => {97 const result = await Building.getContractDistrictList();98 res.json(result);99}100exports.placeDistricts = async (req, res) => {101 const result = await Building.getPlaceDistrict();102 res.json(result);103}104exports.getContracts = async (req, res) => {105 const contracts = await Contract.find();106 res.render('contracts', { mainTitle: 'ÐоговоÑÑ', contracts });107}108exports.deleteContract = async (req, res) => {109 const contract = await Contract.findOne({_id: req.params.id});110 const inspections = await Inspection.find({contract: req.params.id});111 await Contract.deleteOne({ _id: req.params.id });112 await contract.files.forEach(item => unlinkAsync('./public/uploads/' + item.path));113 await contract.claims.forEach(item => unlinkAsync('./public/uploads/' + item.path));114 await contract.ds.forEach(item => unlinkAsync('./public/uploads/' + item.path));115 await contract.acts.forEach(item => unlinkAsync('./public/uploads/' + item.path));116 if(inspections) {117 await Inspection.deleteMany({contract: req.params.id});118 for(let i = 0; i < inspections.length; i++) {119 await unlinkAsync('./public/uploads/' + inspections[i].mainfile.path);120 if(inspections[i].gallery) {121 for(let y = 0; y < inspections[i].gallery.length; y++) {122 await unlinkAsync('./public/uploads/' + inspections[i].gallery[y])123 }124 }125 }126 }127 req.flash('success', `ÐÐ¾Ð³Ð¾Ð²Ð¾Ñ Ñдален.`);128 res.redirect(`/contracts/`);129}130exports.deleteBuilding = async (req, res) => {131 const building = await Building132 .findOne({_id: req.params.id})133 .populate({134 path: 'contracts',135 populate: { path: 'building' } 136 });...
helper.js
Source:helper.js
...56 sizeArray: [ [1920, 1080], [1280, 720], [500, Jimp.AUTO], [50, 50] ],57 removeFiles: async function (fileName) {58 for (let i in this.sizeArray) {59 try {60 this.unlinkAsync(path.join(config.imagesPath, 'thumbs', `${this.sizeArray[i][0] || ''}_${this.sizeArray[i][1] || ''}`, fileName))61 } catch (e) {62 console.log('cant find file ', path.join(config.imagesPath, 'thumbs', `${this.sizeArray[i][0] || ''}_${this.sizeArray[i][1] || ''}`, fileName))63 }64 }65 try {66 this.unlinkAsync(path.join(config.imagesPath, 'original', fileName))67 } catch (e) {68 console.log('cant find file ', path.join(config.imagesPath, 'original', fileName))69 }70 },71 saveAndCrop: async function (file) {72 let filename = `${Date.now()}_${this.genRandomString(10)}.jpg`73 let image = await Jimp.read(`${file.destination}${file.filename}`)74 // image.write(path.join(config.imagesPath, 'original', filename))75 for (let i in this.sizeArray) {76 image.scaleToFit(...this.sizeArray[i]).quality(81).write(77 path.join(config.imagesPath, 'thumbs', `${this.sizeArray[i][0] !== Jimp.AUTO ? this.sizeArray[i][0] : ''}_${this.sizeArray[i][1] !== Jimp.AUTO ? this.sizeArray[i][1] : ''}`, filename)78 )79 }80 // this.renameAsync(path.join(file.destination, file.filename), path.join(config.imagesPath, 'original', filename))81 // this.unlinkAsync(path.join(file.destination, file.filename))82 return filename83 },84 getImageLink: async function (filename, size = 'original') {85 return `${config.hostName}routes/file/get/${size}/${filename}`86 }...
index.js
Source:index.js
...48 console.log(err)49 }else{50 console.log('send!')51 // Delete the file like normal52 unlinkAsync(req.files[0].path)53 unlinkAsync(req.files[1].path)54 console.log(data)55 console.log(data[0]['resultImages'])56 res.send({57 resultImages: data[0]['resultImages'] //pythonã§å®æ½ããæ¼ç®çµæãããã³ãã¨ã³ãã«è¿ãã¦ããã58 })59 }60 })61})...
bucket-upload.js
Source:bucket-upload.js
...8 if (err) {9 reject(err);10 }11 await file.makePublic();12 await unlinkAsync(path);13 resolve(14 `http://storage.googleapis.com/${bucketName}/${options.destination}`,15 );16 });17 });18};19export const withSignedUrlUpload = (path, options, config) => {20 return new Promise((resolve, reject) => {21 Bucket.upload(path, options, async (err, file) => {22 if (err) {23 reject(err);24 }25 const [url] = await file.getSignedUrl(config);26 await unlinkAsync(path);27 resolve(url);28 });29 });...
Using AI Code Generation
1var unlink = require('argosy-unlink');2unlink.unlinkAsync('test.txt', function (err) {3 if (err) {4 console.log(err);5 } else {6 console.log('file deleted');7 }8});9var unlink = require('argosy-unlink');10unlink.unlinkSync('test.txt');11var unlink = require('argosy-unlink');12unlink.unlink('test.txt', function (err) {13 if (err) {14 console.log(err);15 } else {16 console.log('file deleted');17 }18});19var unlink = require('argosy-unlink');20unlink.unlink('test.txt', function (err) {21 if (err) {22 console.log(err);23 } else {24 console.log('file deleted');25 }26});27var unlink = require('argosy-unlink');28unlink.unlink('test.txt', function (err) {29 if (err) {30 console.log(err);31 } else {32 console.log('file deleted');33 }34});35var unlink = require('argosy-unlink');36unlink.unlink('test.txt', function (err) {37 if (err) {38 console.log(err);39 } else {40 console.log('file deleted');41 }42});43var unlink = require('argosy-unlink');44unlink.unlink('test.txt', function (err) {45 if (err) {46 console.log(err);47 } else {48 console.log('file deleted');49 }50});51var unlink = require('argosy-unlink');
Using AI Code Generation
1var unlinkAsync = require('argosy-unlink').unlinkAsync;2var fs = require('fs');3unlinkAsync('test.txt',function(err){4 if(err){5 console.log('error');6 }7 else{8 console.log('success');9 }10});11var unlinkSync = require('argosy-unlink').unlinkSync;12var fs = require('fs');13unlinkSync('test.txt');
Using AI Code Generation
1const unlinkAsync = require('argosy-fs').unlinkAsync2unlinkAsync('test.txt').then(() => console.log('file deleted')).catch(console.error)3const unlinkSync = require('argosy-fs').unlinkSync4unlinkSync('test.txt')5console.log('file deleted')6const writeFileAsync = require('argosy-fs').writeFileAsync7writeFileAsync('test.txt', 'Hello World').then(() => console.log('file written')).catch(console.error)8const writeFileSync = require('argosy-fs').writeFileSync9writeFileSync('test.txt', 'Hello World')10console.log('file written')11const writeStreamAsync = require('argosy-fs').writeStreamAsync12writeStreamAsync('test.txt', 'Hello World').then(() => console.log('file written')).catch(console.error)13const writeStreamSync = require('argosy-fs').writeStreamSync14writeStreamSync('test.txt', 'Hello World')15console.log('file written')16const writeStreamAsync = require('argosy-fs').writeStreamAsync17writeStreamAsync('test.txt', 'Hello World').then(() => console.log('file written')).catch(console.error)18const writeStreamSync = require('argosy-fs').writeStreamSync19writeStreamSync('test.txt', 'Hello World')20console.log('file written')21const writeStreamAsync = require('argosy-fs').write
Using AI Code Generation
1unlinkAsync('path/to/file')2 .then(function (result) {3 })4 .catch(function (err) {5 console.error(err)6 });7MIT © [Argosy](
Using AI Code Generation
1const unlinkAsync = require('argosy').unlinkAsync2const unlink = require('argosy').unlink3const rename = require('argosy').rename4const renameAsync = require('argosy').renameAsync5const rmdir = require('argosy').rmdir6const rmdirAsync = require('argosy').rmdirAsync7const mkdir = require('argosy').mkdir8const mkdirAsync = require('argosy').mkdirAsync9const mkdirp = require('argosy').mkdirp
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!!