Skip to content

Commit

Permalink
Refactoring into projects
Browse files Browse the repository at this point in the history
  • Loading branch information
corrideat committed Jun 1, 2023
1 parent 53e0f4c commit 6b5eaea
Show file tree
Hide file tree
Showing 29 changed files with 620 additions and 881 deletions.
1,261 changes: 428 additions & 833 deletions package-lock.json

Large diffs are not rendered by default.

35 changes: 20 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,56 @@
{
"name": "@exact-realty/routemate",
"version": "1.0.2",
"version": "1.0.3",
"description": "",
"dist": "dist/index.js",
"main": "dist/index.js",
"module": "./dist/index.mjs",
"exports": {
".": {
"deno": "./dist/deno.mjs",
"types": "./dist/index.d.ts",
"deno": {
"types": "./dist/index.d.ts",
"import": "./dist/deno.mjs"
},
"cloudflare-workers": {
"types": "./dist/index.d.ts",
"import": "./dist/cloudflare-workers.mjs",
"require": "./dist/cloudflare-workers.mjs"
},
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"./cloudflare-workers": {
"types": "./dist/index.d.ts",
"import": "./dist/cloudflare-workers.mjs",
"re5quire": "./dist/cloudflare-workers.mjs"
"require": "./dist/cloudflare-workers.mjs"
}
},
"files": [
"dist/**/*"
],
"devDependencies": {
"@azure/functions": "^3.5.1",
"@cloudflare/workers-types": "^4.20230404.0",
"@types/aws-lambda": "^8.10.114",
"@cloudflare/workers-types": "^4.20230518.0",
"@types/aws-lambda": "^8.10.115",
"@types/mocha": "^10.0.1",
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"deno-types": "^1.25.0",
"esbuild": "^0.17.16",
"eslint": "^8.38.0",
"esbuild": "^0.17.19",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"firebase-functions": "^4.2.1",
"google-closure-compiler": "^20230228.0.0",
"firebase-functions": "^4.4.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"prettier": "^2.8.7",
"prettier": "^2.8.8",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
"typescript": "^5.1.3"
},
"peerDependencies": {
"firebase-functions": "^4.2.1"
"firebase-functions": "^4.4.0"
},
"peerDependenciesMeta": {
"firebase-functions": {
Expand All @@ -55,7 +60,7 @@
"scripts": {
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
"build": "tsc --emitDeclarationOnly --declarationMap --declaration && node esbuild.mjs",
"build": "tsc -b --emitDeclarationOnly --declarationMap --declaration && node esbuild.mjs",
"test": "nyc mocha",
"prepare": "npm run build",
"prepublishOnly": "npm test && npm run lint",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions src/common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "../../dist",
},
"include": ["**/*", "**/*.json"],
"exclude": ["**/*.spec.ts"]
}
File renamed without changes.
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
* PERFORMANCE OF THIS SOFTWARE.
*/

export * as dotWellKnownHandlers from './dotWellKnownHandlers/index.js';
export * as dotWellKnownHandlers from './common/dotWellKnownHandlers/index.js';
export * as listeners from './listeners/index.js';
export {
default as ResponseError_,
handleResponseError as handleResponseError,
} from './ResponseError';
export { default, Router } from './server';
} from './common/ResponseError/index.js';
export { default, Router } from './common/server.js';
export type {
TErrorHandler,
TListen,
Expand All @@ -28,4 +28,4 @@ export type {
TResponse,
TRouter,
TServer,
} from './types';
} from './common/types/index.js';
2 changes: 1 addition & 1 deletion src/listeners/aws-lambda/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/

import type { TListener } from '../../types/index.js';
import type { TListener } from '../../common/types/index.js';

const createServer_: TListener = (r) => async () => {
void r;
Expand Down
14 changes: 14 additions & 0 deletions src/listeners/aws-lambda/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "../../../dist",
},
"include": ["**/*"],
"exclude": [],
"references": [
{
"path": "../../common"
}
]
}
2 changes: 1 addition & 1 deletion src/listeners/azure-functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/

import type { TListener } from '../../types/index.js';
import type { TListener } from '../../common/types/index.js';

const createServer_: TListener = (r) => async () => {
void r;
Expand Down
14 changes: 14 additions & 0 deletions src/listeners/azure-functions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "../../../dist",
},
"include": ["**/*"],
"exclude": [],
"references": [
{
"path": "../../common"
}
]
}
21 changes: 3 additions & 18 deletions src/listeners/cloudflare-workers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,9 @@
* PERFORMANCE OF THIS SOFTWARE.
*/

// /// <reference types="@cloudflare/workers-types" />
import type {
EventListenerOrEventListenerObject,
EventTargetAddEventListenerOptions,
FetchEvent,
Response as CfResponse,
WorkerGlobalScopeEventMap,
} from '@cloudflare/workers-types';
/// <reference types="@cloudflare/workers-types" />

import type { TListener } from '../../types/index.js';

declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(
type: Type,
handler: EventListenerOrEventListenerObject<
WorkerGlobalScopeEventMap[Type]
>,
options?: EventTargetAddEventListenerOptions | boolean,
): void;
import type { TListener } from '../../common/types/index.js';

const createServer_: TListener =
(r) =>
Expand Down Expand Up @@ -60,7 +45,7 @@ const createServer_: TListener =
);

try {
event.respondWith(response as unknown as Promise<CfResponse>);
event.respondWith(response as unknown as Promise<Response>);
} catch (e) {
void e;
// log error
Expand Down
14 changes: 14 additions & 0 deletions src/listeners/cloudflare-workers/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "../../../dist",
},
"include": ["**/*"],
"exclude": [],
"references": [
{
"path": "../../common"
}
]
}
2 changes: 1 addition & 1 deletion src/listeners/deno/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

/// <reference types="deno-types" />

import type { TListener } from '../../types/index.js';
import type { TListener } from '../../common/types/index.js';

const createServer_: TListener =
(r) =>
Expand Down
14 changes: 14 additions & 0 deletions src/listeners/deno/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "../../../dist",
},
"include": ["**/*"],
"exclude": [],
"references": [
{
"path": "../../common"
}
]
}
3 changes: 1 addition & 2 deletions src/listeners/dynamic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
* PERFORMANCE OF THIS SOFTWARE.
*/

// import type { CacheStorage } from '@cloudflare/workers-types';

declare const caches: unknown;
declare const WebSocketPair: unknown;
declare const Deno: unknown;

const dynamic_ = async () => {
if (typeof process !== 'undefined' && process.release?.name === 'node') {
Expand Down
29 changes: 29 additions & 0 deletions src/listeners/dynamic/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "../../../dist",
},
"include": ["**/*"],
"exclude": [],
"references": [
{
"path": "../aws-lambda"
},
{
"path": "../azure-functions"
},
{
"path": "../cloudflare-workers"
},
{
"path": "../deno"
},
{
"path": "../gcp-cloudfunction"
},
{
"path": "../node"
}
]
}
2 changes: 1 addition & 1 deletion src/listeners/gcp-cloudfunction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/

import { TListener } from '../../types/index.js';
import { TListener } from '../../common/types/index.js';
import { nodeHandler_ as nodeHandler } from '../node/index.js';

const createServer_: TListener =
Expand Down
17 changes: 17 additions & 0 deletions src/listeners/gcp-cloudfunction/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "../../../dist",
},
"include": ["**/*"],
"exclude": [],
"references": [
{
"path": "../../common"
},
{
"path": "../node"
}
]
}
4 changes: 2 additions & 2 deletions src/listeners/node/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

import assert from 'node:assert/strict';
import nodeListener from './index.js';
import server, { Router } from '../../server.js';
import { handleResponseError as handleResponseError } from '../../ResponseError/index.js';
import server, { Router } from '../../common/server.js';
import { handleResponseError as handleResponseError } from '../../common/ResponseError/index.js';

const abortController = new AbortController();
const port = (Math.random() * (1 << 15)) | 0 | (1 << 11);
Expand Down
2 changes: 1 addition & 1 deletion src/listeners/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import type { IncomingMessage, ServerResponse } from 'node:http';
import { createServer } from 'node:http';
import { TListen, TListener, TRouter } from '../../types/index.js';
import { TListen, TListener, TRouter } from '../../common/types/index.js';

const nodeHandler_ =
(r: TRouter) => (req: IncomingMessage, res: ServerResponse) => {
Expand Down
14 changes: 14 additions & 0 deletions src/listeners/node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "../../../dist",
},
"include": ["**/*"],
"exclude": [],
"references": [
{
"path": "../../common"
}
]
}
23 changes: 23 additions & 0 deletions src/listeners/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "../../dist",
},
"include": ["*", "*.json"],
"exclude": ["**/*.spec.ts"],
"references": [
{
"path": "cloudflare-workers"
},
{
"path": "deno"
},
{
"path": "dynamic"
},
{
"path": "node"
}
]
}
11 changes: 9 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"compilerOptions": {
"composite": true,
"declaration": true,
"target": "es2018",
"module": "commonjs",
"moduleResolution": "node",
Expand All @@ -15,11 +17,16 @@
"allowJs": true,
"checkJs": true,
"lib": ["ES2016", "ES2019.object", "dom"],
"typeRoots": ["./node_modules/@types", "./@types"]
"typeRoots": ["./node_modules/@types", "./@types"],
"rootDir": "./src"
},
"ts-node": {
"experimentalResolver": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
"exclude": ["node_modules", "**/*.spec.ts", "src/common", "src/listeners"],
"references": [
{ "path": "src/common" },
{ "path": "src/listeners" }
]
}

0 comments on commit 6b5eaea

Please sign in to comment.