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 express = require('express'); | |
var mongoose = require('mongoose'); | |
var dbs = {}; | |
for (var i = 0; i < 40; i++) { | |
dbs['t' + i] = mongoose.createConnection('mongodb://localhost/t' + i + '__multitenant', { server: { poolSize: 5 } }); | |
} | |
var app = express(); |
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 express = require('express'); | |
var mongoose = require('mongoose-multitenant')(); | |
mongoose.connect('mongodb://localhost/multitenant', { server: { poolSize: 5 } }); | |
var app = express(); | |
app.use(express.bodyParser()); | |
app.post('/posts', function (req, 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
var request = require('superagent'); | |
var _ = require('underscore'); | |
function firePost (tenant) { | |
var name = 'Post from tenant ' + tenant; | |
request | |
.post('http://localhost:3000/posts?tenant=t' + tenant) | |
.send({ name: name }) | |
.set('Content-Type', 'application/json') |
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 dbs = db.getMongo().getDBNames(); | |
for (var i in dbs) { | |
db = db.getMongo().getDB( dbs[i] ); | |
if (db.getName().indexOf('multitenant') > -1) { | |
print('dropping db ' + db.getName()); | |
db.dropDatabase(); | |
} | |
} |
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 path = require("path"); | |
module.exports = { | |
mode: "production", | |
devtool: "source-map", | |
entry: { | |
index: "./index.js", | |
}, |
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
function HelloComponent() { | |
const element = document.createElement("div"); | |
element.innerText = "Hello from bundle size demo"; | |
return element; | |
} | |
document.body.appendChild(HelloComponent()); |
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": "bundle-size-demo", | |
"version": "1.0.0", | |
"private": true, | |
"scripts": { | |
"build": "webpack --watch", | |
"start": "node server.js" | |
}, | |
"devDependencies": { | |
"webpack": "^5.4.0", |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Bundle size demo</title> | |
</head> | |
<body> | |
<script src="index.js"></script> | |
</body> | |
</html> |
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
import _ from "lodash"; | |
function HelloComponent() { | |
const element = document.createElement("div"); | |
element.innerText = _.join( | |
["Hello from bundle size demo", "with lodash"], | |
" " | |
); | |
return element; | |
} |
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 app = express(); | |
app.use(express.static("dist")); | |
app.listen(8080); | |
console.log("Server running on http://localhost:8080"); |
OlderNewer