Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Commit

Permalink
fix: fixed krabs version in example
Browse files Browse the repository at this point in the history
  • Loading branch information
micheleriva committed Jul 6, 2021
1 parent 60acced commit 35a683f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 40 deletions.
2 changes: 1 addition & 1 deletion examples/advanced/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const express = require('express');
const next = require('next');
const krabs = require('../../dist/index').default;
const krabs = require('krabs').default;
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });

Expand Down
2 changes: 1 addition & 1 deletion examples/advanced/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@emotion/styled": "^11.0.0",
"classnames": "^2.2.6",
"framer-motion": "^3.1.1",
"krabs": "^0.0.12",
"krabs": "^0.0.14",
"next": "9.5.5",
"react": "17.0.1",
"react-dom": "17.0.1"
Expand Down
13 changes: 9 additions & 4 deletions examples/advanced/pages/veggies/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
const getImage = (tenant) => {
switch (tenant) {
case 'local.cabbage.eat.com':
case 'cabbage.krabs.eat.micheleriva.com':
return 'https://images.unsplash.com/photo-1592587828054-10f56e3350db?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1267&q=80';
case 'local.pumpkin.eat.com':
case 'pumpkin.krabs.eat.micheleriva.com':
return 'https://images.unsplash.com/photo-1506917728037-b6af01a7d403?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1267&q=80';
default:
return 'https://images.unsplash.com/photo-1567306295427-94503f8300d7?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1326&q=80';
}
};

function Index(props) {
const image = getImage(props.tenant);
export function getServerSideProps(ctx) {
return {
props: {
hostname: ctx.req.hostname,
},
};
}

function Index(props) {
const image = getImage(props.hostname);
return (
<div>
<div>
Expand Down
14 changes: 4 additions & 10 deletions examples/advanced/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3655,11 +3655,6 @@ fast-json-stable-stringify@^2.0.0:
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==

fast-memoize@^2.5.2:
version "2.5.2"
resolved "https://registry.yarnpkg.com/fast-memoize/-/fast-memoize-2.5.2.tgz#79e3bb6a4ec867ea40ba0e7146816f6cdce9b57e"
integrity sha512-Ue0LwpDYErFbmNnZSF0UH6eImUwDmogUO1jyE+JbN2gsQz/jICm1Ve7t9QT0rNSsfJt+Hs4/S3GnsDVjL4HVrw==

figgy-pudding@^3.5.1:
version "3.5.2"
resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e"
Expand Down Expand Up @@ -4429,14 +4424,13 @@ klona@^2.0.3:
resolved "https://registry.yarnpkg.com/klona/-/klona-2.0.4.tgz#7bb1e3affb0cb8624547ef7e8f6708ea2e39dfc0"
integrity sha512-ZRbnvdg/NxqzC7L9Uyqzf4psi1OM4Cuc+sJAkQPjO6XkQIJTNbfK2Rsmbw8fx1p2mkZdp2FZYo2+LwXYY/uwIA==

krabs@^0.0.12:
version "0.0.12"
resolved "https://registry.yarnpkg.com/krabs/-/krabs-0.0.12.tgz#0212d36d776dfe1ba32aed4c6ebba000941bd46c"
integrity sha512-pNPGmOI59bkKRwtVrh/b8FPMl3OR8mWmGyU+/yuWDumt4x4fDbS4TJnnb+DCrW/cfSzw++1VrRq4xpp6DLuLrQ==
krabs@^0.0.14:
version "0.0.14"
resolved "https://registry.yarnpkg.com/krabs/-/krabs-0.0.14.tgz#af110601f017dbdaf1613ed57eb1fcd313942782"
integrity sha512-Syg2jlRa1lcDh+y5hcL3nGwgdekkUpUvbUgmAfBQ2OFjHhGr5310n7WYTXaAn2RUUdjPpovBwkMHOiqI/f/DAQ==
dependencies:
chalk "^4.1.1"
express "^4.17.1"
fast-memoize "^2.5.2"
krabs "^0.0.8"
next "^10.0.4"

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"chalk": "^4.1.1",
"express": "^4.17.1",
"krabs": "^0.0.8",
"moize": "^6.0.3",
"next": "^10.0.4"
},
"devDependencies": {
Expand Down
7 changes: 2 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Request, Response } from 'express';
import * as chalk from 'chalk';
import { parse } from 'url';
import * as path from 'path';
import moize from 'moize';
import { getTenantConfig } from './config';
import { Config } from './config/config.d';
import findTenant from './tenants/findTenant';
Expand Down Expand Up @@ -30,13 +29,11 @@ async function krabs(
app: any,
config?: Config,
): Promise<void> {
const { tenants } = await (
await moize.promise(async () => config ?? (await getTenantConfig()))
)();
const { tenants } = config ?? (await getTenantConfig());
const { hostname } = req;
const parsedUrl = parse(req.url, true);
const { pathname = '/', query } = parsedUrl;
const tenant = (await moize(() => findTenant(tenants, hostname)))();
const tenant = findTenant(tenants, hostname);

if (!tenant) {
res.status(500);
Expand Down
18 changes: 0 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3850,11 +3850,6 @@ fast-diff@^1.1.2:
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"
integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==

fast-equals@^2.0.1:
version "2.0.3"
resolved "https://registry.yarnpkg.com/fast-equals/-/fast-equals-2.0.3.tgz#7039b0a039909f345a2ce53f6202a14e5f392efc"
integrity sha512-0EMw4TTUxsMDpDkCg0rXor2gsg+npVrMIHbEhvD0HZyIhUX6AktC/yasm+qKwfyswd06Qy95ZKk8p2crTo0iPA==

fast-glob@^3.1.1:
version "3.2.4"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.4.tgz#d20aefbf99579383e7f3cc66529158c9b98554d3"
Expand Down Expand Up @@ -5662,11 +5657,6 @@ methods@^1.1.2, methods@~1.1.2:
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=

micro-memoize@^4.0.9:
version "4.0.9"
resolved "https://registry.yarnpkg.com/micro-memoize/-/micro-memoize-4.0.9.tgz#b44a38c9dffbee1cefc2fd139bc8947952268b62"
integrity sha512-Z2uZi/IUMGQDCXASdujXRqrXXEwSY0XffUrAOllhqzQI3wpUyZbiZTiE2JuYC0HSG2G7DbCS5jZmsEKEGZuemg==

micromatch@^3.1.10, micromatch@^3.1.4:
version "3.1.10"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"
Expand Down Expand Up @@ -5802,14 +5792,6 @@ mock-fs@^4.13.0:
resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-4.13.0.tgz#31c02263673ec3789f90eb7b6963676aa407a598"
integrity sha512-DD0vOdofJdoaRNtnWcrXe6RQbpHkPPmtqGq14uRX0F8ZKJ5nv89CVTYl/BZdppDxBDaV0hl75htg3abpEWlPZA==

moize@^6.0.3:
version "6.0.3"
resolved "https://registry.yarnpkg.com/moize/-/moize-6.0.3.tgz#20881786b68678bc75215ac15ac48a010592b221"
integrity sha512-7Jz9TSiqW9G2u8HwUWnaBQMFMPLblrWKEiWN4BA/GPOfQlsnfQqq0yRnTGHckGPlKApA9Eu1HPb/eTqvK9EtKg==
dependencies:
fast-equals "^2.0.1"
micro-memoize "^4.0.9"

move-concurrently@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"
Expand Down

0 comments on commit 35a683f

Please sign in to comment.