This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const delay = () => new Promise((resolve) => setTimeout(resolve, 300)); | |
| const delayedLog = async (item) => { | |
| await delay(); | |
| console.log(item); | |
| }; | |
| const processArray = (array) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - package.json | |
| "scripts": { | |
| "start": "./node_modules/.bin/serverless offline -s dev", | |
| "debug": "export SLS_DEBUG=* && node --inspect ./node_modules/.bin/serverless offline -s dev", | |
| "test": "mocha" | |
| }, | |
| - serverless.yml | |
| plugins: | |
| - serverless-offline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const app = require('../../app'); | |
| const request = require('supertest'); | |
| const sinon = require('sinon'); | |
| const { expect } = require('chai'); | |
| const ElasticSearch = require('../../models/elasticsearch'); | |
| const url = '/api/search?q=money&page_id=333&lang=en'; | |
| describe('GET /api/search', () => { | |
| let sandbox; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (conditionA | |
| ? fs.writeFileAsync(file, jsonData) | |
| : Promise.resolve()) | |
| .then(functionA); | |
| var waitFor; | |
| if (conditionA) | |
| waitFor = fs.writeFileAsync(file, jsonData); | |
| else | |
| waitFor = Promise.resolve(undefined); // wait for nothing, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (conditionA | |
| ? fs.writeFileAsync(file, jsonData) | |
| : Promise.resolve()) | |
| .then(functionA); | |
| var waitFor; | |
| if (conditionA) | |
| waitFor = fs.writeFileAsync(file, jsonData); | |
| else | |
| waitFor = Promise.resolve(undefined); // wait for nothing, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| POST movies | |
| { | |
| "settings": { | |
| "index": { | |
| "analysis": { | |
| "filter": {}, | |
| "analyzer": { | |
| "keyword_analyzer": { | |
| "filter": [ | |
| "lowercase", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const form = new formidable.IncomingForm(); | |
| form.parse(req, (err, fields, files) => { | |
| const oldPath = files.file.path; | |
| const newPath = path.join(process.cwd(), '/uploads/', files.file.name); | |
| fs.rename(oldPath, newPath, (errRn) => { | |
| if (errRn) { | |
| res.status(500); | |
| res.json({ success: false }); | |
| return; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
| { | |
| "extends": "airbnb-base", | |
| "env": { | |
| "browser": true, | |
| "node": true, | |
| "commonjs": true, | |
| "es6": true | |
| }, | |
| "rules": { | |
| "max-len": [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <body> | |
| <form action="/upload" enctype="multipart/form-data" method="post"> | |
| <input type="text" name="title"> | |
| <input type="file" name="file"> | |
| <input type="submit" value="Upload"> | |
| </form> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://balsamiq.com/ |