This file contains 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 electron = require("electron"); | |
const { app, BrowserWindow } = electron; | |
const path = require("path"); | |
const url = require("url"); | |
const isDev = require("electron-is-dev"); | |
let mainWindow; | |
const localUrl = "http://localhost:3000"; |
This file contains 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 mongoose = require("mongoose"); | |
const validUrl = require("valid-url"); | |
const UrlShorten = mongoose.model("UrlShorten"); | |
const shortid = require("shortid"); | |
const errorUrl='http://localhost/error'; | |
module.exports = app => { | |
app.get("/api/item/:code", async (req, res) => { | |
const urlCode = req.params.code; | |
const item = await UrlShorten.findOne({ urlCode: urlCode }); | |
if (item) { |
This file contains 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 mongoose = require("mongoose"); | |
const { Schema } = mongoose; | |
const urlShortenSchema = new Schema({ | |
originalUrl: String, | |
urlCode: String, | |
shortUrl: String, | |
createdAt: { type: Date, default: Date.now }, | |
updatedAt: { type: Date, default: Date.now } | |
}); | |
mongoose.model("UrlShorten", urlShortenSchema); |
This file contains 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 express = require("express"); | |
const mongoose = require("mongoose"); | |
const bodyParser = require("body-parser"); | |
const mongoURI = "mongodb://localhost/url-shortner"; | |
const connectOptions = { | |
keepAlive: true, | |
reconnectTries: Number.MAX_VALUE | |
}; | |
//Connect to MongoDB | |
mongoose.Promise = global.Promise; |
This file contains 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
{ | |
"name": "server", | |
"version": "1.0.0", | |
"main": "index.js", | |
"license": "MIT", | |
"scripts": { | |
"start": "nodemon index.js " | |
}, | |
"dependencies": { | |
"express": "^4.16.3", |
This file contains 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
process.env.UV_THREADPOOL_SIZE = 5; | |
const https = require("https"); | |
const crypto = require("crypto"); | |
const fs = require("fs"); | |
const start = Date.now(); | |
function doRequest() { | |
https | |
.request("https://www.google.com", res => { |
This file contains 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
// Suppose we are running ,node myFile.js | |
const pendingTimers = []; | |
const pendingOSTasks = []; | |
const pendingOperations = []; | |
// New timers, tasks, operations are recorded from myFile running [We are pretending here] | |
myFile.runContents(); | |
function shouldContinue() { |
This file contains 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
var moment = require('moment'); | |
var result = [{ | |
"rank": 1, | |
"u_total_price": 10, | |
"user": { | |
"_id": "59381ca1d48d69e140518ea3", | |
"u_firstname": "Abin", | |
"u_created_at": "2017-06-07T15:32:49.240Z" | |
} | |
}, { |