Skip to content

Instantly share code, notes, and snippets.

{
"cache": false,
"check-coverage": false,
"extension": [
".ts"
],
"include": [
"**/*.js",
"**/*.ts"
],
import { expect } from 'chai';
import { bar, barAsync } from '../src/foo';
describe('bar', () => {
it('sync function returns true', () => {
const result = bar();
expect(result).to.be.true;
});
it('async function returns true', async () => {
export function bar() {
if (true) {
return true;
} else {
return false;
}
}
export async function barAsync() {
return new Promise((resolve, reject) => {
{
"compilerOptions": {
"module": "commonjs",
"sourceMap": true,
"target": "es2015"
}
}
{
"name": "sample",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
worker_processes auto;
events {
worker_connections 1024;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
const express = require('express');
const helmet = require('helmet');
const { MongoClient, ObjectID } = require('mongodb');
const url = process.env.MONGO_URL || 'mongodb://localhost:27017/twtsnt';
const dbName = 'twtsnt';
let client = null;
const port = process.env.PORT || 3000;
const app = express();
const { MongoClient } = require('mongodb');
const axios = require('axios');
const createStream = require('./tweetCrawler');
// Either take the MongoDB connection string from envrionment variable MONGODB_URL or the local mongodb 'twtsnt'
const url = process.env.MONGO_URL || 'mongodb://localhost:27017/twtsnt';
const dbName = 'twtsnt';
// Create a MongoDB client instance
const client = new MongoClient(url, { useNewUrlParser: true });
const Twit = require('twit');
const Sentiment = require('sentiment');
// Create a sentiment instance
const sentiment = new Sentiment();
// Create a Twit instance
const T = new Twit({
consumer_key: 'consumer key obtained from twitter developer', // Twitter Developer - https://developer.twitter.com
consumer_secret: 'consumer secret obtained from twitter developer',
{
"name": "tweet-sentiment",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"keywords": [],
"author": "",