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

Commit

Permalink
refactor: refactored codebase into a monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
micheleriva committed Jul 25, 2021
1 parent 5742ce6 commit 5136b80
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 29 deletions.
2 changes: 1 addition & 1 deletion environment.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Env } from './src/config/config';
import { Env } from './packages/utils/config/config';

declare global {
namespace NodeJS {
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"name": "krabs",
"version": "0.0.14",
"description": "Multitenant middleware for Next.js",
"workspaces": [
"packages/express-krabs",
"packages/fastify-krabs",
"packages/utils"
],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
Expand All @@ -10,19 +15,19 @@
"repository": "https://github.com/MicheleRiva/krabs",
"author": "Michele Riva <ciao@micheleriva.it>",
"license": "GPL-3.0",
"private": false,
"private": true,
"scripts": {
"dev": "NODE_ENV=dev ts-node ./dev/index.ts",
"format": "prettier --write './**/*.{js,jsx,ts,tsx,css,md,json}' --config ./.prettierrc.js",
"lint": "eslint --fix .",
"test": "NODE_ENV=test && jest --coverage",
"prepare": "npm run test && npm run build",
"build": "tsc src/index.ts --outDir dist --declarationDir dist --declaration true"
"build:express": "tsc packages/express-krabs/index.ts --outDir packages/express-krabs/dist --declarationDir packages/express-krabs/dist --declaration true",
"build:fastify": "tsc packages/express-fastify/index.ts --outDir packages/express-fastify/dist --declarationDir packages/express-fastify/dist --declaration true"
},
"dependencies": {
"chalk": "^4.1.1",
"express": "^4.17.1",
"krabs": "^0.0.8",
"next": "^10.0.4"
},
"devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts → packages/express-krabs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Request, Response } from 'express';
import * as chalk from 'chalk';
import { parse } from 'url';
import * as path from 'path';
import { getTenantConfig } from './config';
import { Config } from './config/config.d';
import findTenant from './tenants/findTenant';
import resolveRoutes from './routes/resolve';
import { currentEnv, safeEnv } from './env';
import { getTenantConfig } from '../utils/config';
import { Config } from '../utils/config/config';
import findTenant from '../utils/tenants/findTenant';
import resolveRoutes from '../utils/routes/resolve';
import { currentEnv, safeEnv } from '../utils/env';

if (!currentEnv) {
const warningMessage = `
Expand Down
17 changes: 17 additions & 0 deletions packages/express-krabs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "krabs",
"version": "0.1.0",
"description": "Multitenant middleware for Next.js",
"main": "./dist/index.js",
"files": [
"dist"
],
"repository": "https://github.com/MicheleRiva/krabs",
"author": "Michele Riva <ciao@micheleriva.it>",
"license": "GPL-3.0",
"private": false,
"dependencies": {
"chalk": "^4.1.1",
"express": "^4.17.1"
}
}
17 changes: 17 additions & 0 deletions packages/fastify-krabs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "fastify-krabs",
"version": "0.0.1",
"description": "Multitenant middleware for Next.js and Fastify",
"main": "./dist/index.js",
"files": [
"dist"
],
"repository": "https://github.com/MicheleRiva/krabs",
"author": "Michele Riva <ciao@micheleriva.it>",
"license": "GPL-3.0",
"private": false,
"dependencies": {
"chalk": "^4.1.1",
"express": "^4.17.1"
}
}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/config/index.ts → packages/utils/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { existsSync } from 'fs';
import { join } from 'path';
import { Config, ConfigEntry } from './config.d';
import { Config, ConfigEntry } from './config';

export function getCwdConfig() {
const validConfigNames = ['.krabs.js', 'krabs.config.js'];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tenant, DomainSpec } from '../config/config.d';
import { Tenant, DomainSpec } from '../config/config';
import { safeEnv } from '../env';

export function findTenant(tenants: Tenant[], hostname: string): Tenant | undefined {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tenant, Domain, DomainSpec } from '../config/config.d';
import { Tenant, Domain, DomainSpec } from '../config/config';
import 'array-flat-polyfill';

export function concatDomains(acc: string[], domain: Domain): string[] {
Expand Down
17 changes: 0 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5409,23 +5409,6 @@ klona@^2.0.4:
resolved "https://registry.yarnpkg.com/klona/-/klona-2.0.4.tgz#7bb1e3affb0cb8624547ef7e8f6708ea2e39dfc0"
integrity sha512-ZRbnvdg/NxqzC7L9Uyqzf4psi1OM4Cuc+sJAkQPjO6XkQIJTNbfK2Rsmbw8fx1p2mkZdp2FZYo2+LwXYY/uwIA==

krabs@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/krabs/-/krabs-0.0.2.tgz#b17ee1adfc70e8d0963851b2c5487a84f49d42c5"
integrity sha512-adpQb6wGPKbZhSK6OOdBmlZbNZqPJ1GYd51iimq+Vt6+CQ9rL4P8cv/EfxOsJtxOqfP4+qu3cUB9T8M9a8do3w==
dependencies:
express "^4.17.1"
next "^10.0.4"

krabs@^0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/krabs/-/krabs-0.0.8.tgz#04d633abe43f6225f8526ab76c6567a779593386"
integrity sha512-HdFsQKidWDN3B2HaEkBk1RmJkMyvceS5461Xy7ikkoZeQGT3/hg+mPPHRh/+3NiXDi4HBgvOAqNJDsGi2Dm9SQ==
dependencies:
express "^4.17.1"
krabs "^0.0.2"
next "^10.0.4"

language-subtag-registry@~0.3.2:
version "0.3.21"
resolved "https://registry.yarnpkg.com/language-subtag-registry/-/language-subtag-registry-0.3.21.tgz#04ac218bea46f04cb039084602c6da9e788dd45a"
Expand Down

0 comments on commit 5136b80

Please sign in to comment.