@fncts/express 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ import { Cause } from "@fncts/base/data/Cause";
2
+ import { URIO } from "@fncts/io/IO";
3
+ import type { NextFunction, Request, Response } from "express";
4
+ export declare type ExitHandler<R> = (req: Request, res: Response, next: NextFunction) => (cause: Cause<never>) => URIO<R, any>;
5
+ export declare type ErasedExitHandler = ExitHandler<any>;
6
+ export declare function defaultExitHandler(_req: Request, _res: Response, _next: NextFunction): (cause: Cause<never>) => URIO<unknown, void>;
@@ -0,0 +1,27 @@
1
+ /// <reference types="node" />
2
+ import { IO, URIO } from "@fncts/io/IO";
3
+ import { HKT } from "@fncts/typelevel/HKT";
4
+ import { Has } from "@fncts/base/typeclass";
5
+ import { Scope } from "@fncts/io/Scope";
6
+ import { Layer } from "@fncts/io/Layer";
7
+ import { Cause } from "@fncts/base/data/Cause";
8
+ import type { ExpressAppConfig } from "./ExpressAppConfig.js";
9
+ import type { ErasedRequestHandlerIO, RequestHandlerRouteIO } from "./RequestHandlerIO";
10
+ import type { Express, NextFunction, Request, RequestHandler, Response } from "express";
11
+ import type { Server } from "http";
12
+ export interface ExpressApp {
13
+ readonly app: Express;
14
+ readonly server: Server;
15
+ readonly runtime: <Handlers extends Array<RequestHandlerRouteIO>>(handlers: Handlers) => IO<HKT._R<{
16
+ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? URIO<R, void> : never;
17
+ }[number]>, never, ReadonlyArray<RequestHandler>>;
18
+ }
19
+ export declare const ExpressAppTag: import("@fncts/base/data/Tag.js").Tag<ExpressApp>;
20
+ export declare const makeExpressApp: IO<Has<Scope> & Has<ExpressAppConfig>, never, ExpressApp>;
21
+ export declare const LiveExpressApp: import("@fncts/io/Layer.js").Layer<import("@fncts/base/typeclass.js").Has<ExpressAppConfig>, never, import("@fncts/base/typeclass.js").Has<ExpressApp>>;
22
+ export declare type ExpressEnv = Has<ExpressAppConfig> & Has<ExpressApp>;
23
+ export declare function LiveExpress(host: string, port: number): Layer<unknown, never, ExpressEnv>;
24
+ export declare function LiveExpress<R>(host: string, port: number, exitHandler: (req: Request, res: Response, next: NextFunction) => (cause: Cause<never>) => URIO<R, void>): Layer<R, never, ExpressEnv>;
25
+ export declare function expressRuntime<Handlers extends Array<RequestHandlerRouteIO>>(handlers: never extends Handlers ? Array<RequestHandlerRouteIO> : Handlers): IO<HKT._R<{
26
+ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? URIO<R, void> : never;
27
+ }[number]> & Has<ExpressApp>, never, ReadonlyArray<RequestHandler>>;
@@ -0,0 +1,11 @@
1
+ import { Layer } from "@fncts/io/Layer";
2
+ import { Has } from "@fncts/base/typeclass";
3
+ import { Environment } from "@fncts/base/data/Environment";
4
+ import type { ExitHandler } from "./ExitHandler.js";
5
+ export interface ExpressAppConfig {
6
+ readonly port: number;
7
+ readonly host: string;
8
+ readonly exitHandler: ExitHandler<unknown>;
9
+ }
10
+ export declare const ExpressAppConfigTag: import("@fncts/base/data/Tag.js").Tag<ExpressAppConfig>;
11
+ export declare function LiveExpressAppConfig<R>(host: string, port: number, exitHandler: ExitHandler<R>): Layer<R, never, Has<ExpressAppConfig>>;
@@ -0,0 +1,11 @@
1
+ import { URIO } from "@fncts/io/IO";
2
+ import type { NextFunction, Request, Response } from "express";
3
+ import type { RouteParameters } from "express-serve-static-core";
4
+ export interface ParsedQs {
5
+ [key: string]: undefined | string | string[] | ParsedQs | ParsedQs[];
6
+ }
7
+ export interface RequestHandlerIO<R, Route extends string = any, P = RouteParameters<Route>, ResBody = any, ReqBody = any, ReqQuery = ParsedQs, Locals extends Record<string, any> = Record<string, any>> {
8
+ (req: Request<P, ResBody, ReqBody, ReqQuery, Locals>, res: Response<ResBody, Locals>, next: NextFunction): URIO<R, void>;
9
+ }
10
+ export declare type ErasedRequestHandlerIO<R> = RequestHandlerIO<R, any, any, any, any, any, any>;
11
+ export declare type RequestHandlerRouteIO<R = unknown, Route extends string = any> = RequestHandlerIO<R, Route, RouteParameters<Route>>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.defaultExitHandler = defaultExitHandler;
7
+
8
+ var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Cause/api"));
9
+
10
+ var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Cause/api/prettyPrint"));
11
+
12
+ var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api"));
13
+
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
+
18
+ const fileName_1 = "(@fncts/express) src/ExitHandler.ts";
19
+
20
+ function defaultExitHandler(_req, _res, _next) {
21
+ return cause => tsplus_module_3.succeed(() => {
22
+ if (tsplus_module_1.halted(cause)) {
23
+ console.error(tsplus_module_2.prettyPrint(cause));
24
+ }
25
+
26
+ _res.status(500).end();
27
+ }, fileName_1 + ":13:15");
28
+ }
29
+ //# sourceMappingURL=ExitHandler.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExitHandler.cjs","mappings":";;;;;;;;;;;;;;;;;;;AAMM,SAAUA,kBAAV,CACJC,IADI,EAEJC,IAFI,EAGJC,KAHI,EAGe;EAEnB,OAAQC,KAAD,IACLC,wBAAW,MAAK;IACd,2BAAID,KAAJ,GAAkB;MAChBE,OAAO,CAACC,KAAR,CAAaC,4BAACJ,KAAD,CAAb;IACD;;IACDF,IAAI,CAACO,MAAL,CAAY,GAAZ,EAAiBC,GAAjB;EACD,CALD,EAKCC,qBALD,CADF;AAOD","names":["defaultExitHandler","_req","_res","_next","cause","tsplus_module_3","console","error","tsplus_module_2","status","end","fileName_1"],"sourceRoot":"","sources":["../_src/ExitHandler.ts"],"sourcesContent":[null]}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ExpressAppTag = void 0;
7
+ exports.LiveExpress = LiveExpress;
8
+ exports.LiveExpressApp = void 0;
9
+ exports.expressRuntime = expressRuntime;
10
+ exports.makeExpressApp = void 0;
11
+
12
+ var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Tag/constructors"));
13
+
14
+ var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api/interrupt"));
15
+
16
+ var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api/onTermination"));
17
+
18
+ var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/runtime"));
19
+
20
+ var tsplus_module_5 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api"));
21
+
22
+ var tsplus_module_6 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api/acquireRelease"));
23
+
24
+ var tsplus_module_7 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api/environment"));
25
+
26
+ var tsplus_module_8 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Layer/api"));
27
+
28
+ var _AtomicBoolean = /*#__PURE__*/require("@fncts/base/internal/AtomicBoolean");
29
+
30
+ var _IO = /*#__PURE__*/require("@fncts/io/IO");
31
+
32
+ var _express = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("express"));
33
+
34
+ var _errors = /*#__PURE__*/require("./errors.cjs");
35
+
36
+ var _ExitHandler = /*#__PURE__*/require("./ExitHandler.cjs");
37
+
38
+ var _ExpressAppConfig = /*#__PURE__*/require("./ExpressAppConfig.cjs");
39
+
40
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
+
42
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
43
+
44
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
45
+
46
+ const fileName_1 = "(@fncts/express) src/ExpressApp.ts";
47
+ const ExpressAppTag = /*#__PURE__*/tsplus_module_1.makeTag();
48
+ exports.ExpressAppTag = ExpressAppTag;
49
+ const makeExpressApp = /*#__PURE__*/tsplus_module_5.flatMap_( /*#__PURE__*/tsplus_module_6.acquireRelease(() => tsplus_module_5.succeed(() => new _AtomicBoolean.AtomicBoolean(true), fileName_1 + ":34:28"), _ => tsplus_module_5.succeed(() => _.set(false), fileName_1 + ":34:86")), open => tsplus_module_5.flatMap_(tsplus_module_5.succeed(() => (0, _express.default)(), fileName_1 + ":36:27"), app => tsplus_module_5.flatMap_(tsplus_module_7.service(_ExpressAppConfig.ExpressAppConfigTag, fileName_1 + ":38:30"), config => tsplus_module_5.map_(tsplus_module_6.acquireRelease(() => tsplus_module_5.async(cb => {
50
+ const onError = err => {
51
+ cb(tsplus_module_5.halt(() => new _errors.NodeServerListenError(err), fileName_1 + ":43:19"));
52
+ };
53
+
54
+ const server = app.listen(config.port, config.host, () => {
55
+ cb(tsplus_module_5.succeed(() => {
56
+ server.removeListener("error", onError);
57
+ return server;
58
+ }, fileName_1 + ":47:21"));
59
+ });
60
+ server.addListener("error", onError);
61
+ }), server => tsplus_module_5.async(cb => {
62
+ server.close(err => {
63
+ if (err) {
64
+ cb(tsplus_module_5.halt(() => new _errors.NodeServerCloseError(err), fileName_1 + ":58:23"));
65
+ } else {
66
+ cb(tsplus_module_5.via(tsplus_module_5.unit));
67
+ }
68
+ });
69
+ })), server => {
70
+ function runtime(handlers) {
71
+ return tsplus_module_5.map_(tsplus_module_5.map_(tsplus_module_4.runtime(fileName_1 + ":68:22"), r => new _IO.Runtime(r.environment, r.runtimeConfig), fileName_1 + ":75:11"), r => handlers.map(handler => (req, res, next) => r.unsafeRunAsync(tsplus_module_3.onTermination(() => open.get ? handler(req, res, next) : tsplus_module_2.interrupt, config.exitHandler(req, res, next)), fileName_1 + ":80:31")), fileName_1 + ":76:11");
72
+ }
73
+
74
+ return {
75
+ app,
76
+ server,
77
+ runtime
78
+ };
79
+ }, fileName_1 + ":40:19"), fileName_1 + ":38:19"), fileName_1 + ":36:16"), fileName_1 + ":34:17");
80
+ exports.makeExpressApp = makeExpressApp;
81
+ const LiveExpressApp = /*#__PURE__*/tsplus_module_8.scoped(() => makeExpressApp, ExpressAppTag);
82
+ exports.LiveExpressApp = LiveExpressApp;
83
+
84
+ function LiveExpress(host, port, exitHandler) {
85
+ return tsplus_module_8.andTo_((0, _ExpressAppConfig.LiveExpressAppConfig)(host, port, exitHandler ?? _ExitHandler.defaultExitHandler), LiveExpressApp);
86
+ }
87
+
88
+ function expressRuntime(handlers) {
89
+ return tsplus_module_7.serviceWithIO(_ => _.runtime(handlers), ExpressAppTag, fileName_1 + ":124:26");
90
+ }
91
+ //# sourceMappingURL=ExpressApp.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressApp.cjs","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;AAmBO,MAAMA,aAAa,gBAAGC,yBAAtB;;AAEA,MAAMC,cAAc,uDACVC,mEAAW,IAAIC,4BAAJ,CAAkB,IAAlB,CAAX,EAAkCC,qBAAlC,GAAoDC,CAAD,IAAOC,wBAAW,MAAMD,CAAC,CAACE,GAAF,CAAM,KAAN,CAAjB,EAA6BH,qBAA7B,CAA1D,CADU,EACnBI,IAAI,6BAEIF,wBAAW,MAAM,uBAAjB,EAA0BF,qBAA1B,CAFJ,EAEJK,GAAG,6BAEQC,wBAAWC,qCAAX,EAA8BP,qBAA9B,CAFR,EAEHQ,MAAM,yBAGVV,2DAAkCW,EAAD,IAAO;EACtC,MAAMC,OAAO,GAAIC,GAAD,IAAe;IAC7BF,EAAE,CAACP,2BAAQ,IAAIU,6BAAJ,CAA0BD,GAA1B,CAAR,EAAsCX,qBAAtC,CAAD,CAAF;EACD,CAFD;;EAGA,MAAMa,MAAM,GAAGR,GAAG,CAACS,MAAJ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ApB;;AA6DA,MAAMgB,cAAc,gBAAGC,6BAAazC,cAAb,EAA6BF,aAA7B,CAAvB;;;AAUD,SAAU4C,WAAV,CACJvB,IADI,EAEJD,IAFI,EAGJqB,WAHI,EAGqG;EAEzG,OAAOE,mEAAqBtB,IAArB,EAA2BD,IAA3B,EAAiCqB,WAAW,IAAII,+BAAhD,GAA0EH,cAA1E,CAAP;AACD;;AAEK,SAAUI,cAAV,CACJnB,QADI,EACsE;EAW1E,OAAOhB,8BAAkBL,CAAD,IAAOA,CAAC,CAACoB,OAAF,CAAUC,QAAV,CAAxB,EAA6C3B,aAA7C,EAA0DK,sBAA1D,CAAP;AACD","names":["ExpressAppTag","tsplus_module_1","makeExpressApp","tsplus_module_6","AtomicBoolean","fileName_1","_","tsplus_module_5","set","open","app","tsplus_module_7","ExpressAppConfigTag","config","cb","onError","err","NodeServerListenError","server","listen","port","host","removeListener","addListener","close","NodeServerCloseError","runtime","handlers","r","Runtime","environment","runtimeConfig","map","handler","req","res","next","unsafeRunAsync","tsplus_module_3","get","tsplus_module_2","exitHandler","LiveExpressApp","tsplus_module_8","LiveExpress","defaultExitHandler","expressRuntime"],"sourceRoot":"","sources":["../_src/ExpressApp.ts"],"sourcesContent":[null]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ExpressAppConfigTag = void 0;
7
+ exports.LiveExpressAppConfig = LiveExpressAppConfig;
8
+
9
+ var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Tag/constructors"));
10
+
11
+ var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api/environment"));
12
+
13
+ var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/Layer/api"));
14
+
15
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
+
17
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
+
19
+ const fileName_1 = "(@fncts/express) src/ExpressAppConfig.ts";
20
+ const ExpressAppConfigTag = /*#__PURE__*/tsplus_module_1.makeTag();
21
+ exports.ExpressAppConfigTag = ExpressAppConfigTag;
22
+
23
+ function LiveExpressAppConfig(host, port, exitHandler) {
24
+ return tsplus_module_3.fromIO(tsplus_module_2.environmentWith(r => ({
25
+ host,
26
+ port,
27
+ exitHandler: (req, res, next) => cause => tsplus_module_2.provideEnvironment_(exitHandler(req, res, next)(cause), r, fileName_1 + ":20:104")
28
+ }), fileName_1 + ":17:23"), ExpressAppConfigTag);
29
+ }
30
+ //# sourceMappingURL=ExpressAppConfig.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressAppConfig.cjs","mappings":";;;;;;;;;;;;;;;;;;;AAQO,MAAMA,mBAAmB,gBAAGC,yBAA5B;;;AAED,SAAUC,oBAAV,CACJC,IADI,EAEJC,IAFI,EAGJC,WAHI,EAGuB;EAE3B,OAAOC,uBACLC,gCAAoBC,CAAD,KAAwB;IACzCL,IADyC;IAEzCC,IAFyC;IAGzCC,WAAW,EAAE,CAACI,GAAD,EAAMC,GAAN,EAAWC,IAAX,KAAqBC,KAAD,IAAWL,+CAAW,CAACE,GAAD,EAAMC,GAAN,EAAWC,IAAX,CAAX,CAA4BC,KAA5B,GAAsDJ,CAAtD,EAAuDK,sBAAvD;EAHH,CAAxB,CAAnB,EAIEA,qBAJF,CADK,EAMLb,mBANK,CAAP;AAQD","names":["ExpressAppConfigTag","tsplus_module_1","LiveExpressAppConfig","host","port","exitHandler","tsplus_module_3","tsplus_module_2","r","req","res","next","cause","fileName_1"],"sourceRoot":"","sources":["../_src/ExpressAppConfig.ts"],"sourcesContent":[null]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=RequestHandlerIO.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RequestHandlerIO.cjs","mappings":"","names":[],"sourceRoot":"","sources":[],"sourcesContent":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NodeServerListenError = exports.NodeServerCloseError = void 0;
7
+
8
+ class NodeServerCloseError {
9
+ constructor(error) {
10
+ this.error = error;
11
+ this._tag = "NodeServerCloseError";
12
+ }
13
+
14
+ }
15
+
16
+ exports.NodeServerCloseError = NodeServerCloseError;
17
+
18
+ class NodeServerListenError {
19
+ constructor(error) {
20
+ this.error = error;
21
+ this._tag = "NodeServerListenError";
22
+ }
23
+
24
+ }
25
+
26
+ exports.NodeServerListenError = NodeServerListenError;
27
+ //# sourceMappingURL=errors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.cjs","mappings":";;;;;;;AAAM,MAAOA,oBAAP,CAA2B;EAE/BC,YAAqBC,KAArB,EAAiC;IAAZ;IADZ,YAAO,sBAAP;EAC4B;;AAFN;;;;AAK3B,MAAOC,qBAAP,CAA4B;EAEhCF,YAAqBC,KAArB,EAAiC;IAAZ;IADZ,YAAO,uBAAP;EAC4B;;AAFL","names":["NodeServerCloseError","constructor","error","NodeServerListenError"],"sourceRoot":"","sources":["../_src/errors.ts"],"sourcesContent":[null]}
package/_cjs/index.cjs ADDED
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ methods: true,
8
+ match: true,
9
+ use: true,
10
+ all: true,
11
+ get: true,
12
+ post: true,
13
+ put: true,
14
+ "delete": true,
15
+ patch: true,
16
+ options: true,
17
+ head: true,
18
+ checkout: true,
19
+ connect: true,
20
+ copy: true,
21
+ lock: true,
22
+ merge: true,
23
+ mkactivity: true,
24
+ mkcol: true,
25
+ move: true,
26
+ mSearch: true,
27
+ notify: true,
28
+ propfind: true,
29
+ proppatch: true,
30
+ purge: true,
31
+ report: true,
32
+ search: true,
33
+ subscribe: true,
34
+ trace: true,
35
+ unlock: true,
36
+ unsubscribe: true,
37
+ classic: true
38
+ };
39
+ exports.checkout = exports.all = void 0;
40
+ exports.classic = classic;
41
+ exports.mSearch = exports.lock = exports.head = exports.get = exports.delete = exports.copy = exports.connect = void 0;
42
+ exports.match = match;
43
+ exports.unsubscribe = exports.unlock = exports.trace = exports.subscribe = exports.search = exports.report = exports.put = exports.purge = exports.proppatch = exports.propfind = exports.post = exports.patch = exports.options = exports.notify = exports.move = exports.mkcol = exports.mkactivity = exports.methods = exports.merge = void 0;
44
+ exports.use = use;
45
+
46
+ var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api"));
47
+
48
+ var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/io/IO/api/environment"));
49
+
50
+ var _ExpressApp = /*#__PURE__*/require("./ExpressApp.cjs");
51
+
52
+ Object.keys(_ExpressApp).forEach(function (key) {
53
+ if (key === "default" || key === "__esModule") return;
54
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
55
+ if (key in exports && exports[key] === _ExpressApp[key]) return;
56
+ Object.defineProperty(exports, key, {
57
+ enumerable: true,
58
+ get: function () {
59
+ return _ExpressApp[key];
60
+ }
61
+ });
62
+ });
63
+
64
+ var _errors = /*#__PURE__*/require("./errors.cjs");
65
+
66
+ Object.keys(_errors).forEach(function (key) {
67
+ if (key === "default" || key === "__esModule") return;
68
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
69
+ if (key in exports && exports[key] === _errors[key]) return;
70
+ Object.defineProperty(exports, key, {
71
+ enumerable: true,
72
+ get: function () {
73
+ return _errors[key];
74
+ }
75
+ });
76
+ });
77
+
78
+ var _ExitHandler = /*#__PURE__*/require("./ExitHandler.cjs");
79
+
80
+ Object.keys(_ExitHandler).forEach(function (key) {
81
+ if (key === "default" || key === "__esModule") return;
82
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
83
+ if (key in exports && exports[key] === _ExitHandler[key]) return;
84
+ Object.defineProperty(exports, key, {
85
+ enumerable: true,
86
+ get: function () {
87
+ return _ExitHandler[key];
88
+ }
89
+ });
90
+ });
91
+
92
+ var _ExpressAppConfig = /*#__PURE__*/require("./ExpressAppConfig.cjs");
93
+
94
+ Object.keys(_ExpressAppConfig).forEach(function (key) {
95
+ if (key === "default" || key === "__esModule") return;
96
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
97
+ if (key in exports && exports[key] === _ExpressAppConfig[key]) return;
98
+ Object.defineProperty(exports, key, {
99
+ enumerable: true,
100
+ get: function () {
101
+ return _ExpressAppConfig[key];
102
+ }
103
+ });
104
+ });
105
+
106
+ var _RequestHandlerIO = /*#__PURE__*/require("./RequestHandlerIO.cjs");
107
+
108
+ Object.keys(_RequestHandlerIO).forEach(function (key) {
109
+ if (key === "default" || key === "__esModule") return;
110
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
111
+ if (key in exports && exports[key] === _RequestHandlerIO[key]) return;
112
+ Object.defineProperty(exports, key, {
113
+ enumerable: true,
114
+ get: function () {
115
+ return _RequestHandlerIO[key];
116
+ }
117
+ });
118
+ });
119
+
120
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
121
+
122
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
123
+
124
+ const fileName_1 = "(@fncts/express) src/index.ts";
125
+ const methods = ["all", "get", "post", "put", "delete", "patch", "options", "head", "checkout", "connect", "copy", "lock", "merge", "mkactivity", "mkcol", "move", "m-search", "notify", "propfind", "proppatch", "purge", "report", "search", "subscribe", "trace", "unlock", "unsubscribe"];
126
+ exports.methods = methods;
127
+
128
+ function match(method) {
129
+ return function (path, ...handlers) {
130
+ return tsplus_module_1.flatMap_((0, _ExpressApp.expressRuntime)(handlers), expressHandlers => tsplus_module_2.serviceWithIO(service => tsplus_module_1.succeed(() => service.app[method](path, ...expressHandlers), fileName_1 + ":70:44"), _ExpressApp.ExpressAppTag, fileName_1 + ":69:23"), fileName_1 + ":68:82");
131
+ };
132
+ }
133
+
134
+ function use(...args) {
135
+ return tsplus_module_1.asUnit(tsplus_module_2.serviceWithIO(service => {
136
+ if (typeof args[0] === "function") {
137
+ return tsplus_module_1.flatMap_((0, _ExpressApp.expressRuntime)(args), expressHandlers => tsplus_module_1.succeed(() => service.app.use(...expressHandlers), fileName_1 + ":103:74"), fileName_1 + ":103:42");
138
+ } else {
139
+ return tsplus_module_1.flatMap_((0, _ExpressApp.expressRuntime)(args.slice(1) ?? []), expressHandlers => tsplus_module_1.succeed(() => service.app.use(args[0], ...expressHandlers), fileName_1 + ":106:19"), fileName_1 + ":105:57");
140
+ }
141
+ }, _ExpressApp.ExpressAppTag, fileName_1 + ":101:26"));
142
+ }
143
+
144
+ const all = /*#__PURE__*/match("all");
145
+ exports.all = all;
146
+ const get = /*#__PURE__*/match("get");
147
+ exports.get = get;
148
+ const post = /*#__PURE__*/match("post");
149
+ exports.post = post;
150
+ const put = /*#__PURE__*/match("put");
151
+ exports.put = put;
152
+ const delete_ = /*#__PURE__*/match("delete");
153
+ exports.delete = delete_;
154
+ const patch = /*#__PURE__*/match("patch");
155
+ exports.patch = patch;
156
+ const options = /*#__PURE__*/match("options");
157
+ exports.options = options;
158
+ const head = /*#__PURE__*/match("head");
159
+ exports.head = head;
160
+ const checkout = /*#__PURE__*/match("checkout");
161
+ exports.checkout = checkout;
162
+ const connect = /*#__PURE__*/match("connect");
163
+ exports.connect = connect;
164
+ const copy = /*#__PURE__*/match("copy");
165
+ exports.copy = copy;
166
+ const lock = /*#__PURE__*/match("lock");
167
+ exports.lock = lock;
168
+ const merge = /*#__PURE__*/match("merge");
169
+ exports.merge = merge;
170
+ const mkactivity = /*#__PURE__*/match("mkactivity");
171
+ exports.mkactivity = mkactivity;
172
+ const mkcol = /*#__PURE__*/match("mkcol");
173
+ exports.mkcol = mkcol;
174
+ const move = /*#__PURE__*/match("move");
175
+ exports.move = move;
176
+ const mSearch = /*#__PURE__*/match("m-search");
177
+ exports.mSearch = mSearch;
178
+ const notify = /*#__PURE__*/match("notify");
179
+ exports.notify = notify;
180
+ const propfind = /*#__PURE__*/match("propfind");
181
+ exports.propfind = propfind;
182
+ const proppatch = /*#__PURE__*/match("proppatch");
183
+ exports.proppatch = proppatch;
184
+ const purge = /*#__PURE__*/match("purge");
185
+ exports.purge = purge;
186
+ const report = /*#__PURE__*/match("report");
187
+ exports.report = report;
188
+ const search = /*#__PURE__*/match("search");
189
+ exports.search = search;
190
+ const subscribe = /*#__PURE__*/match("subscribe");
191
+ exports.subscribe = subscribe;
192
+ const trace = /*#__PURE__*/match("trace");
193
+ exports.trace = trace;
194
+ const unlock = /*#__PURE__*/match("unlock");
195
+ exports.unlock = unlock;
196
+ const unsubscribe = /*#__PURE__*/match("unsubscribe");
197
+ exports.unsubscribe = unsubscribe;
198
+
199
+ function classic(_) {
200
+ return (req, res, next) => tsplus_module_1.succeed(() => _(req, res, next), fileName_1 + ":147:40");
201
+ }
202
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AAIA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAFA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;;;;;;AAEO,MAAMA,OAAO,GAAG,CACrB,KADqB,EAErB,KAFqB,EAGrB,MAHqB,EAIrB,KAJqB,EAKrB,QALqB,EAMrB,OANqB,EAOrB,SAPqB,EAQrB,MARqB,EASrB,UATqB,EAUrB,SAVqB,EAWrB,MAXqB,EAYrB,MAZqB,EAarB,OAbqB,EAcrB,YAdqB,EAerB,OAfqB,EAgBrB,MA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qC,SAAS,gBAAKrC,KAAK,CAAC,WAAD,CAAzB;;AACA,MAAMsC,KAAK,gBAAStC,KAAK,CAAC,OAAD,CAAzB;;AACA,MAAMuC,MAAM,gBAAQvC,KAAK,CAAC,QAAD,CAAzB;;AACA,MAAMwC,WAAW,gBAAGxC,KAAK,CAAC,aAAD,CAAzB;;;AAOD,SAAUyC,OAAV,CAAkBC,CAAlB,EAAwD;EAC5D,OAAO,CAACC,GAAD,EAAMC,GAAN,EAAWC,IAAX,KAAoBzC,wBAAW,MAAMsC,CAAC,CAACC,GAAD,EAAMC,GAAN,EAAWC,IAAX,CAAlB,EAAkCpC,sBAAlC,CAA3B;AACD","names":["methods","match","method","path","handlers","tsplus_module_1","expressHandlers","tsplus_module_2","service","app","fileName_1","ExpressAppTag","use","args","slice","all","get","post","put","delete_","patch","options","head","checkout","connect","copy","lock","merge","mkactivity","mkcol","move","mSearch","notify","propfind","proppatch","purge","report","search","subscribe","trace","unlock","unsubscribe","classic","_","req","res","next"],"sourceRoot":"","sources":["../_src/index.ts"],"sourcesContent":[null]}
@@ -0,0 +1,14 @@
1
+ const fileName_1 = "(@fncts/express) src/ExitHandler.ts";
2
+ import * as tsplus_module_1 from "@fncts/base/data/Cause/api";
3
+ import * as tsplus_module_2 from "@fncts/base/data/Cause/api/prettyPrint";
4
+ import * as tsplus_module_3 from "@fncts/io/IO/api";
5
+ export function defaultExitHandler(_req, _res, _next) {
6
+ return cause => tsplus_module_3.succeed(() => {
7
+ if (tsplus_module_1.halted(cause)) {
8
+ console.error(tsplus_module_2.prettyPrint(cause));
9
+ }
10
+
11
+ _res.status(500).end();
12
+ }, fileName_1 + ":13:15");
13
+ }
14
+ //# sourceMappingURL=ExitHandler.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExitHandler.mjs","mappings":";;;;AAMA,OAAM,SAAUA,kBAAV,CACJC,IADI,EAEJC,IAFI,EAGJC,KAHI,EAGe;EAEnB,OAAQC,KAAD,IACLC,wBAAW,MAAK;IACd,2BAAID,KAAJ,GAAkB;MAChBE,OAAO,CAACC,KAAR,CAAaC,4BAACJ,KAAD,CAAb;IACD;;IACDF,IAAI,CAACO,MAAL,CAAY,GAAZ,EAAiBC,GAAjB;EACD,CALD,EAKCC,qBALD,CADF;AAOD","names":["defaultExitHandler","_req","_res","_next","cause","tsplus_module_3","console","error","tsplus_module_2","status","end","fileName_1"],"sourceRoot":"","sources":["../_src/ExitHandler.ts"],"sourcesContent":[null]}
@@ -0,0 +1,56 @@
1
+ const fileName_1 = "(@fncts/express) src/ExpressApp.ts";
2
+ import * as tsplus_module_1 from "@fncts/base/data/Tag/constructors";
3
+ import * as tsplus_module_2 from "@fncts/io/IO/api/interrupt";
4
+ import * as tsplus_module_3 from "@fncts/io/IO/api/onTermination";
5
+ import * as tsplus_module_4 from "@fncts/io/IO/runtime";
6
+ import * as tsplus_module_5 from "@fncts/io/IO/api";
7
+ import * as tsplus_module_6 from "@fncts/io/IO/api/acquireRelease";
8
+ import * as tsplus_module_7 from "@fncts/io/IO/api/environment";
9
+ import * as tsplus_module_8 from "@fncts/io/Layer/api";
10
+ import { AtomicBoolean } from "@fncts/base/internal/AtomicBoolean";
11
+ import { Runtime } from "@fncts/io/IO";
12
+ import express from "express";
13
+ import { NodeServerCloseError, NodeServerListenError } from "./errors.mjs";
14
+ import { defaultExitHandler } from "./ExitHandler.mjs";
15
+ import { LiveExpressAppConfig } from "./ExpressAppConfig.mjs";
16
+ import { ExpressAppConfigTag } from "./ExpressAppConfig.mjs";
17
+ export const ExpressAppTag = /*#__PURE__*/tsplus_module_1.makeTag();
18
+ export const makeExpressApp = /*#__PURE__*/tsplus_module_5.flatMap_( /*#__PURE__*/tsplus_module_6.acquireRelease(() => tsplus_module_5.succeed(() => new AtomicBoolean(true), fileName_1 + ":34:28"), _ => tsplus_module_5.succeed(() => _.set(false), fileName_1 + ":34:86")), open => tsplus_module_5.flatMap_(tsplus_module_5.succeed(() => express(), fileName_1 + ":36:27"), app => tsplus_module_5.flatMap_(tsplus_module_7.service(ExpressAppConfigTag, fileName_1 + ":38:30"), config => tsplus_module_5.map_(tsplus_module_6.acquireRelease(() => tsplus_module_5.async(cb => {
19
+ const onError = err => {
20
+ cb(tsplus_module_5.halt(() => new NodeServerListenError(err), fileName_1 + ":43:19"));
21
+ };
22
+
23
+ const server = app.listen(config.port, config.host, () => {
24
+ cb(tsplus_module_5.succeed(() => {
25
+ server.removeListener("error", onError);
26
+ return server;
27
+ }, fileName_1 + ":47:21"));
28
+ });
29
+ server.addListener("error", onError);
30
+ }), server => tsplus_module_5.async(cb => {
31
+ server.close(err => {
32
+ if (err) {
33
+ cb(tsplus_module_5.halt(() => new NodeServerCloseError(err), fileName_1 + ":58:23"));
34
+ } else {
35
+ cb(tsplus_module_5.via(tsplus_module_5.unit));
36
+ }
37
+ });
38
+ })), server => {
39
+ function runtime(handlers) {
40
+ return tsplus_module_5.map_(tsplus_module_5.map_(tsplus_module_4.runtime(fileName_1 + ":68:22"), r => new Runtime(r.environment, r.runtimeConfig), fileName_1 + ":75:11"), r => handlers.map(handler => (req, res, next) => r.unsafeRunAsync(tsplus_module_3.onTermination(() => open.get ? handler(req, res, next) : tsplus_module_2.interrupt, config.exitHandler(req, res, next)), fileName_1 + ":80:31")), fileName_1 + ":76:11");
41
+ }
42
+
43
+ return {
44
+ app,
45
+ server,
46
+ runtime
47
+ };
48
+ }, fileName_1 + ":40:19"), fileName_1 + ":38:19"), fileName_1 + ":36:16"), fileName_1 + ":34:17");
49
+ export const LiveExpressApp = /*#__PURE__*/tsplus_module_8.scoped(() => makeExpressApp, ExpressAppTag);
50
+ export function LiveExpress(host, port, exitHandler) {
51
+ return tsplus_module_8.andTo_(LiveExpressAppConfig(host, port, exitHandler ?? defaultExitHandler), LiveExpressApp);
52
+ }
53
+ export function expressRuntime(handlers) {
54
+ return tsplus_module_7.serviceWithIO(_ => _.runtime(handlers), ExpressAppTag, fileName_1 + ":124:26");
55
+ }
56
+ //# sourceMappingURL=ExpressApp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AAOb,8BAAkBL,CAAD,IAAOA,CAAC,CAACiB,OAAF,CAAUC,QAAV,CAAxB,EAA6CvB,aAA7C,EAA0DI,sBAA1D,CAAP;AACD","names":["AtomicBoolean","Runtime","express","NodeServerCloseError","NodeServerListenError","defaultExitHandler","LiveExpressAppConfig","ExpressAppConfigTag","ExpressAppTag","tsplus_module_1","makeExpressApp","tsplus_module_6","fileName_1","_","tsplus_module_5","set","open","app","tsplus_module_7","config","cb","onError","err","server","listen","port","host","removeListener","addListener","close","runtime","handlers","r","environment","runtimeConfig","map","handler","req","res","next","unsafeRunAsync","tsplus_module_3","get","tsplus_module_2","exitHandler","LiveExpressApp","tsplus_module_8","LiveExpress","expressRuntime"],"sourceRoot":"","sources":["../_src/ExpressApp.ts"],"sourcesContent":[null]}
@@ -0,0 +1,13 @@
1
+ const fileName_1 = "(@fncts/express) src/ExpressAppConfig.ts";
2
+ import * as tsplus_module_1 from "@fncts/base/data/Tag/constructors";
3
+ import * as tsplus_module_2 from "@fncts/io/IO/api/environment";
4
+ import * as tsplus_module_3 from "@fncts/io/Layer/api";
5
+ export const ExpressAppConfigTag = /*#__PURE__*/tsplus_module_1.makeTag();
6
+ export function LiveExpressAppConfig(host, port, exitHandler) {
7
+ return tsplus_module_3.fromIO(tsplus_module_2.environmentWith(r => ({
8
+ host,
9
+ port,
10
+ exitHandler: (req, res, next) => cause => tsplus_module_2.provideEnvironment_(exitHandler(req, res, next)(cause), r, fileName_1 + ":20:104")
11
+ }), fileName_1 + ":17:23"), ExpressAppConfigTag);
12
+ }
13
+ //# sourceMappingURL=ExpressAppConfig.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpressAppConfig.mjs","mappings":";;;;AAQA,OAAO,MAAMA,mBAAmB,gBAAGC,yBAA5B;AAEP,OAAM,SAAUC,oBAAV,CACJC,IADI,EAEJC,IAFI,EAGJC,WAHI,EAGuB;EAE3B,OAAOC,uBACLC,gCAAoBC,CAAD,KAAwB;IACzCL,IADyC;IAEzCC,IAFyC;IAGzCC,WAAW,EAAE,CAACI,GAAD,EAAMC,GAAN,EAAWC,IAAX,KAAqBC,KAAD,IAAWL,+CAAW,CAACE,GAAD,EAAMC,GAAN,EAAWC,IAAX,CAAX,CAA4BC,KAA5B,GAAsDJ,CAAtD,EAAuDK,sBAAvD;EAHH,CAAxB,CAAnB,EAIEA,qBAJF,CADK,EAMLb,mBANK,CAAP;AAQD","names":["ExpressAppConfigTag","tsplus_module_1","LiveExpressAppConfig","host","port","exitHandler","tsplus_module_3","tsplus_module_2","r","req","res","next","cause","fileName_1"],"sourceRoot":"","sources":["../_src/ExpressAppConfig.ts"],"sourcesContent":[null]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=RequestHandlerIO.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RequestHandlerIO.mjs","mappings":"","names":[],"sourceRoot":"","sources":[],"sourcesContent":[]}
@@ -0,0 +1,15 @@
1
+ export class NodeServerCloseError {
2
+ constructor(error) {
3
+ this.error = error;
4
+ this._tag = "NodeServerCloseError";
5
+ }
6
+
7
+ }
8
+ export class NodeServerListenError {
9
+ constructor(error) {
10
+ this.error = error;
11
+ this._tag = "NodeServerListenError";
12
+ }
13
+
14
+ }
15
+ //# sourceMappingURL=errors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.mjs","mappings":"AAAA,OAAM,MAAOA,oBAAP,CAA2B;EAE/BC,YAAqBC,KAArB,EAAiC;IAAZ;IADZ,YAAO,sBAAP;EAC4B;;AAFN;AAKjC,OAAM,MAAOC,qBAAP,CAA4B;EAEhCF,YAAqBC,KAArB,EAAiC;IAAZ;IADZ,YAAO,uBAAP;EAC4B;;AAFL","names":["NodeServerCloseError","constructor","error","NodeServerListenError"],"sourceRoot":"","sources":["../_src/errors.ts"],"sourcesContent":[null]}
package/_mjs/index.mjs ADDED
@@ -0,0 +1,56 @@
1
+ const fileName_1 = "(@fncts/express) src/index.ts";
2
+ import * as tsplus_module_1 from "@fncts/io/IO/api";
3
+ import * as tsplus_module_2 from "@fncts/io/IO/api/environment";
4
+ import { ExpressAppTag, expressRuntime } from "./ExpressApp.mjs";
5
+ export * from "./errors.mjs";
6
+ export * from "./ExitHandler.mjs";
7
+ export * from "./ExpressApp.mjs";
8
+ export * from "./ExpressAppConfig.mjs";
9
+ export * from "./RequestHandlerIO.mjs";
10
+ export const methods = ["all", "get", "post", "put", "delete", "patch", "options", "head", "checkout", "connect", "copy", "lock", "merge", "mkactivity", "mkcol", "move", "m-search", "notify", "propfind", "proppatch", "purge", "report", "search", "subscribe", "trace", "unlock", "unsubscribe"];
11
+ export function match(method) {
12
+ return function (path, ...handlers) {
13
+ return tsplus_module_1.flatMap_(expressRuntime(handlers), expressHandlers => tsplus_module_2.serviceWithIO(service => tsplus_module_1.succeed(() => service.app[method](path, ...expressHandlers), fileName_1 + ":70:44"), ExpressAppTag, fileName_1 + ":69:23"), fileName_1 + ":68:82");
14
+ };
15
+ }
16
+ export function use(...args) {
17
+ return tsplus_module_1.asUnit(tsplus_module_2.serviceWithIO(service => {
18
+ if (typeof args[0] === "function") {
19
+ return tsplus_module_1.flatMap_(expressRuntime(args), expressHandlers => tsplus_module_1.succeed(() => service.app.use(...expressHandlers), fileName_1 + ":103:74"), fileName_1 + ":103:42");
20
+ } else {
21
+ return tsplus_module_1.flatMap_(expressRuntime(args.slice(1) ?? []), expressHandlers => tsplus_module_1.succeed(() => service.app.use(args[0], ...expressHandlers), fileName_1 + ":106:19"), fileName_1 + ":105:57");
22
+ }
23
+ }, ExpressAppTag, fileName_1 + ":101:26"));
24
+ }
25
+ export const all = /*#__PURE__*/match("all");
26
+ export const get = /*#__PURE__*/match("get");
27
+ export const post = /*#__PURE__*/match("post");
28
+ export const put = /*#__PURE__*/match("put");
29
+ const delete_ = /*#__PURE__*/match("delete");
30
+ export { delete_ as delete };
31
+ export const patch = /*#__PURE__*/match("patch");
32
+ export const options = /*#__PURE__*/match("options");
33
+ export const head = /*#__PURE__*/match("head");
34
+ export const checkout = /*#__PURE__*/match("checkout");
35
+ export const connect = /*#__PURE__*/match("connect");
36
+ export const copy = /*#__PURE__*/match("copy");
37
+ export const lock = /*#__PURE__*/match("lock");
38
+ export const merge = /*#__PURE__*/match("merge");
39
+ export const mkactivity = /*#__PURE__*/match("mkactivity");
40
+ export const mkcol = /*#__PURE__*/match("mkcol");
41
+ export const move = /*#__PURE__*/match("move");
42
+ export const mSearch = /*#__PURE__*/match("m-search");
43
+ export const notify = /*#__PURE__*/match("notify");
44
+ export const propfind = /*#__PURE__*/match("propfind");
45
+ export const proppatch = /*#__PURE__*/match("proppatch");
46
+ export const purge = /*#__PURE__*/match("purge");
47
+ export const report = /*#__PURE__*/match("report");
48
+ export const search = /*#__PURE__*/match("search");
49
+ export const subscribe = /*#__PURE__*/match("subscribe");
50
+ export const trace = /*#__PURE__*/match("trace");
51
+ export const unlock = /*#__PURE__*/match("unlock");
52
+ export const unsubscribe = /*#__PURE__*/match("unsubscribe");
53
+ export function classic(_) {
54
+ return (req, res, next) => tsplus_module_1.succeed(() => _(req, res, next), fileName_1 + ":147:40");
55
+ }
56
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","mappings":";;;AAMA,SAASA,aAAT,EAAwBC,cAAxB,QAA8C,kBAA9C;AAEA,cAAc,cAAd;AACA,cAAc,mBAAd;AACA,cAAc,kBAAd;AACA,cAAc,wBAAd;AACA,cAAc,wBAAd;AAEA,OAAO,MAAMC,OAAO,GAAG,CACrB,KADqB,EAErB,KAFqB,EAGrB,MAHqB,EAIrB,KAJqB,EAKrB,QALqB,EAMrB,OANqB,EAOrB,SAPqB,EAQrB,MARqB,EASrB,UATqB,EAUrB,SAVqB,EAWrB,MAXqB,EAYrB,MAZqB,EAarB,OAbqB,EAcrB,YAdqB,EAerB,OAfqB,EAgBrB,MAhBqB,EAiBrB,UAjBqB,EAkBrB,QAlBqB,EAmBrB,UAnBqB,EAoBrB,WApB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QnC,KAAK,CAAC,QAAD,CAAzB;AACP,OAAO,MAAMoC,MAAM,gBAAQpC,KAAK,CAAC,QAAD,CAAzB;AACP,OAAO,MAAMqC,SAAS,gBAAKrC,KAAK,CAAC,WAAD,CAAzB;AACP,OAAO,MAAMsC,KAAK,gBAAStC,KAAK,CAAC,OAAD,CAAzB;AACP,OAAO,MAAMuC,MAAM,gBAAQvC,KAAK,CAAC,QAAD,CAAzB;AACP,OAAO,MAAMwC,WAAW,gBAAGxC,KAAK,CAAC,aAAD,CAAzB;AAOP,OAAM,SAAUyC,OAAV,CAAkBC,CAAlB,EAAwD;EAC5D,OAAO,CAACC,GAAD,EAAMC,GAAN,EAAWC,IAAX,KAAoBzC,wBAAW,MAAMsC,CAAC,CAACC,GAAD,EAAMC,GAAN,EAAWC,IAAX,CAAlB,EAAkCpC,sBAAlC,CAA3B;AACD","names":["ExpressAppTag","expressRuntime","methods","match","method","path","handlers","tsplus_module_1","expressHandlers","tsplus_module_2","service","app","fileName_1","use","args","slice","all","get","post","put","delete_","delete","patch","options","head","checkout","connect","copy","lock","merge","mkactivity","mkcol","move","mSearch","notify","propfind","proppatch","purge","report","search","subscribe","trace","unlock","unsubscribe","classic","_","req","res","next"],"sourceRoot":"","sources":["../_src/index.ts"],"sourcesContent":[null]}
@@ -0,0 +1,19 @@
1
+ import type { NextFunction, Request, Response } from "express";
2
+
3
+ export type ExitHandler<R> = (req: Request, res: Response, next: NextFunction) => (cause: Cause<never>) => URIO<R, any>;
4
+
5
+ export type ErasedExitHandler = ExitHandler<any>;
6
+
7
+ export function defaultExitHandler(
8
+ _req: Request,
9
+ _res: Response,
10
+ _next: NextFunction,
11
+ ): (cause: Cause<never>) => URIO<unknown, void> {
12
+ return (cause) =>
13
+ IO.succeed(() => {
14
+ if (cause.halted) {
15
+ console.error(cause.prettyPrint);
16
+ }
17
+ _res.status(500).end();
18
+ });
19
+ }
@@ -0,0 +1,125 @@
1
+ import type { ExpressAppConfig } from "./ExpressAppConfig.js";
2
+ import type { ErasedRequestHandlerIO, RequestHandlerRouteIO } from "./RequestHandlerIO";
3
+ import type { Express, NextFunction, Request, RequestHandler, Response } from "express";
4
+ import type { Server } from "http";
5
+
6
+ import { AtomicBoolean } from "@fncts/base/internal/AtomicBoolean";
7
+ import { Runtime } from "@fncts/io/IO";
8
+ import express from "express";
9
+
10
+ import { NodeServerCloseError, NodeServerListenError } from "./errors.js";
11
+ import { defaultExitHandler } from "./ExitHandler.js";
12
+ import { LiveExpressAppConfig } from "./ExpressAppConfig.js";
13
+ import { ExpressAppConfigTag } from "./ExpressAppConfig.js";
14
+
15
+ export interface ExpressApp {
16
+ readonly app: Express;
17
+ readonly server: Server;
18
+ readonly runtime: <Handlers extends Array<RequestHandlerRouteIO>>(
19
+ handlers: Handlers,
20
+ ) => IO<
21
+ HKT._R<
22
+ {
23
+ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? URIO<R, void> : never;
24
+ }[number]
25
+ >,
26
+ never,
27
+ ReadonlyArray<RequestHandler>
28
+ >;
29
+ }
30
+
31
+ export const ExpressAppTag = Tag<ExpressApp>();
32
+
33
+ export const makeExpressApp: IO<Has<Scope> & Has<ExpressAppConfig>, never, ExpressApp> = Do((Δ) => {
34
+ const open = Δ(IO.succeed(new AtomicBoolean(true)).acquireRelease((_) => IO.succeed(() => _.set(false))));
35
+
36
+ const app = Δ(IO.succeed(() => express()));
37
+
38
+ const config = Δ(IO.service(ExpressAppConfigTag));
39
+
40
+ const server = Δ(
41
+ IO.async<unknown, never, Server>((cb) => {
42
+ const onError = (err: Error) => {
43
+ cb(IO.halt(new NodeServerListenError(err)));
44
+ };
45
+ const server = app.listen(config.port, config.host, () => {
46
+ cb(
47
+ IO.succeed(() => {
48
+ server.removeListener("error", onError);
49
+ return server;
50
+ }),
51
+ );
52
+ });
53
+ server.addListener("error", onError);
54
+ }).acquireRelease((server) =>
55
+ IO.async<unknown, never, void>((cb) => {
56
+ server.close((err) => {
57
+ if (err) {
58
+ cb(IO.halt(new NodeServerCloseError(err)));
59
+ } else {
60
+ cb(IO.unit());
61
+ }
62
+ });
63
+ }),
64
+ ),
65
+ );
66
+
67
+ function runtime<Handlers extends Array<RequestHandlerRouteIO>>(handlers: Handlers) {
68
+ return IO.runtime<
69
+ HKT._R<
70
+ {
71
+ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? URIO<R, void> : never;
72
+ }[number]
73
+ >
74
+ >()
75
+ .map((r) => new Runtime(r.environment, r.runtimeConfig))
76
+ .map((r) =>
77
+ handlers.map(
78
+ (handler): RequestHandler =>
79
+ (req, res, next) =>
80
+ r.unsafeRunAsync(
81
+ (open.get ? handler(req, res, next) : IO.interrupt).onTermination(config.exitHandler(req, res, next)),
82
+ ),
83
+ ),
84
+ );
85
+ }
86
+
87
+ return {
88
+ app,
89
+ server,
90
+ runtime,
91
+ };
92
+ });
93
+
94
+ export const LiveExpressApp = Layer.scoped(makeExpressApp, ExpressAppTag);
95
+
96
+ export type ExpressEnv = Has<ExpressAppConfig> & Has<ExpressApp>;
97
+
98
+ export function LiveExpress(host: string, port: number): Layer<unknown, never, ExpressEnv>;
99
+ export function LiveExpress<R>(
100
+ host: string,
101
+ port: number,
102
+ exitHandler: (req: Request, res: Response, next: NextFunction) => (cause: Cause<never>) => URIO<R, void>,
103
+ ): Layer<R, never, ExpressEnv>;
104
+ export function LiveExpress<R>(
105
+ host: string,
106
+ port: number,
107
+ exitHandler?: (req: Request, res: Response, next: NextFunction) => (cause: Cause<never>) => URIO<R, void>,
108
+ ): Layer<R, never, ExpressEnv> {
109
+ return LiveExpressAppConfig(host, port, exitHandler ?? defaultExitHandler).andTo(LiveExpressApp);
110
+ }
111
+
112
+ export function expressRuntime<Handlers extends Array<RequestHandlerRouteIO>>(
113
+ handlers: never extends Handlers ? Array<RequestHandlerRouteIO> : Handlers,
114
+ ): IO<
115
+ HKT._R<
116
+ {
117
+ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? URIO<R, void> : never;
118
+ }[number]
119
+ > &
120
+ Has<ExpressApp>,
121
+ never,
122
+ ReadonlyArray<RequestHandler>
123
+ > {
124
+ return IO.serviceWithIO((_) => _.runtime(handlers), ExpressAppTag);
125
+ }
@@ -0,0 +1,24 @@
1
+ import type { ExitHandler } from "./ExitHandler.js";
2
+
3
+ export interface ExpressAppConfig {
4
+ readonly port: number;
5
+ readonly host: string;
6
+ readonly exitHandler: ExitHandler<unknown>;
7
+ }
8
+
9
+ export const ExpressAppConfigTag = Tag<ExpressAppConfig>();
10
+
11
+ export function LiveExpressAppConfig<R>(
12
+ host: string,
13
+ port: number,
14
+ exitHandler: ExitHandler<R>,
15
+ ): Layer<R, never, Has<ExpressAppConfig>> {
16
+ return Layer.fromIO(
17
+ IO.environmentWith((r: Environment<R>) => ({
18
+ host,
19
+ port,
20
+ exitHandler: (req, res, next) => (cause) => exitHandler(req, res, next)(cause).provideEnvironment(r),
21
+ })),
22
+ ExpressAppConfigTag,
23
+ );
24
+ }
@@ -0,0 +1,29 @@
1
+ import type { NextFunction, Request, Response } from "express";
2
+ import type { RouteParameters } from "express-serve-static-core";
3
+
4
+ export interface ParsedQs {
5
+ [key: string]: undefined | string | string[] | ParsedQs | ParsedQs[];
6
+ }
7
+
8
+ export interface RequestHandlerIO<
9
+ R,
10
+ Route extends string = any,
11
+ P = RouteParameters<Route>,
12
+ ResBody = any,
13
+ ReqBody = any,
14
+ ReqQuery = ParsedQs,
15
+ Locals extends Record<string, any> = Record<string, any>,
16
+ > {
17
+ (req: Request<P, ResBody, ReqBody, ReqQuery, Locals>, res: Response<ResBody, Locals>, next: NextFunction): URIO<
18
+ R,
19
+ void
20
+ >;
21
+ }
22
+
23
+ export type ErasedRequestHandlerIO<R> = RequestHandlerIO<R, any, any, any, any, any, any>;
24
+
25
+ export type RequestHandlerRouteIO<R = unknown, Route extends string = any> = RequestHandlerIO<
26
+ R,
27
+ Route,
28
+ RouteParameters<Route>
29
+ >;
package/_src/errors.ts ADDED
@@ -0,0 +1,9 @@
1
+ export class NodeServerCloseError {
2
+ readonly _tag = "NodeServerCloseError";
3
+ constructor(readonly error: Error) {}
4
+ }
5
+
6
+ export class NodeServerListenError {
7
+ readonly _tag = "NodeServerListenError";
8
+ constructor(readonly error: Error) {}
9
+ }
package/_src/index.ts ADDED
@@ -0,0 +1,148 @@
1
+ import type { ExpressApp, ExpressEnv } from "./ExpressApp.js";
2
+ import type { ErasedRequestHandlerIO, RequestHandlerIO, RequestHandlerRouteIO } from "./RequestHandlerIO.js";
3
+ import type { NextHandleFunction } from "connect";
4
+ import type { RequestHandler } from "express";
5
+ import type { RouteParameters } from "express-serve-static-core";
6
+
7
+ import { ExpressAppTag, expressRuntime } from "./ExpressApp.js";
8
+
9
+ export * from "./errors.js";
10
+ export * from "./ExitHandler.js";
11
+ export * from "./ExpressApp.js";
12
+ export * from "./ExpressAppConfig.js";
13
+ export * from "./RequestHandlerIO.js";
14
+
15
+ export const methods = [
16
+ "all",
17
+ "get",
18
+ "post",
19
+ "put",
20
+ "delete",
21
+ "patch",
22
+ "options",
23
+ "head",
24
+ "checkout",
25
+ "connect",
26
+ "copy",
27
+ "lock",
28
+ "merge",
29
+ "mkactivity",
30
+ "mkcol",
31
+ "move",
32
+ "m-search",
33
+ "notify",
34
+ "propfind",
35
+ "proppatch",
36
+ "purge",
37
+ "report",
38
+ "search",
39
+ "subscribe",
40
+ "trace",
41
+ "unlock",
42
+ "unsubscribe",
43
+ ] as const;
44
+
45
+ export type Methods = typeof methods[number];
46
+
47
+ export type PathParams = string | RegExp | Array<string | RegExp>;
48
+
49
+ export interface ParamsDictionary {
50
+ [key: string]: string;
51
+ }
52
+
53
+ export function match(method: Methods): {
54
+ <Route extends string, Handlers extends Array<RequestHandlerRouteIO<any, Route>>>(
55
+ path: Route,
56
+ ...handlers: never extends Handlers ? Array<RequestHandlerIO<any, Route, RouteParameters<Route>>> : Handlers
57
+ ): URIO<
58
+ ExpressEnv &
59
+ HKT._R<
60
+ {
61
+ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? URIO<R, void> : never;
62
+ }[number]
63
+ >,
64
+ void
65
+ >;
66
+ } {
67
+ return function (path, ...handlers) {
68
+ return expressRuntime(handlers as Array<ErasedRequestHandlerIO<any>>).flatMap((expressHandlers) =>
69
+ IO.serviceWithIO(
70
+ (service: ExpressApp) => IO.succeed(() => service.app[method](path, ...expressHandlers)),
71
+ ExpressAppTag,
72
+ ),
73
+ );
74
+ };
75
+ }
76
+
77
+ export function use<Handlers extends Array<RequestHandlerRouteIO>>(
78
+ ...handlers: Handlers
79
+ ): URIO<
80
+ ExpressEnv &
81
+ HKT._R<
82
+ {
83
+ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? URIO<R, void> : never;
84
+ }[number]
85
+ >,
86
+ void
87
+ >;
88
+ export function use<Route extends string, Handlers extends Array<RequestHandlerRouteIO<any, Route>>>(
89
+ path: Route,
90
+ ...handlers: never extends Handlers ? Array<RequestHandlerRouteIO<any, Route>> : Handlers
91
+ ): URIO<
92
+ ExpressEnv &
93
+ HKT._R<
94
+ {
95
+ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? URIO<R, void> : never;
96
+ }[number]
97
+ >,
98
+ void
99
+ >;
100
+ export function use(...args: Array<any>): URIO<ExpressEnv, void> {
101
+ return IO.serviceWithIO((service: ExpressApp) => {
102
+ if (typeof args[0] === "function") {
103
+ return expressRuntime(args).flatMap((expressHandlers) => IO.succeed(() => service.app.use(...expressHandlers)));
104
+ } else {
105
+ return expressRuntime(args.slice(1) ?? []).flatMap((expressHandlers) =>
106
+ IO.succeed(() => service.app.use(args[0], ...expressHandlers)),
107
+ );
108
+ }
109
+ }, ExpressAppTag).asUnit;
110
+ }
111
+
112
+ export const all = match("all");
113
+ export const get = match("get");
114
+ export const post = match("post");
115
+ export const put = match("put");
116
+ const delete_ = match("delete");
117
+ export { delete_ as delete };
118
+ export const patch = match("patch");
119
+ export const options = match("options");
120
+ export const head = match("head");
121
+ export const checkout = match("checkout");
122
+ export const connect = match("connect");
123
+ export const copy = match("copy");
124
+ export const lock = match("lock");
125
+ export const merge = match("merge");
126
+ export const mkactivity = match("mkactivity");
127
+ export const mkcol = match("mkcol");
128
+ export const move = match("move");
129
+ export const mSearch = match("m-search");
130
+ export const notify = match("notify");
131
+ export const propfind = match("propfind");
132
+ export const proppatch = match("proppatch");
133
+ export const purge = match("purge");
134
+ export const report = match("report");
135
+ export const search = match("search");
136
+ export const subscribe = match("subscribe");
137
+ export const trace = match("trace");
138
+ export const unlock = match("unlock");
139
+ export const unsubscribe = match("unsubscribe");
140
+
141
+ /**
142
+ * Lift an express requestHandler into an effectified variant
143
+ */
144
+ export function classic(_: NextHandleFunction): RequestHandlerIO<unknown, any>;
145
+ export function classic(_: RequestHandler): RequestHandlerIO<unknown, any>;
146
+ export function classic(_: RequestHandler | NextHandleFunction): RequestHandlerIO<unknown, any> {
147
+ return (req, res, next) => IO.succeed(() => _(req, res, next));
148
+ }
package/errors.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ export declare class NodeServerCloseError {
2
+ readonly error: Error;
3
+ readonly _tag = "NodeServerCloseError";
4
+ constructor(error: Error);
5
+ }
6
+ export declare class NodeServerListenError {
7
+ readonly error: Error;
8
+ readonly _tag = "NodeServerListenError";
9
+ constructor(error: Error);
10
+ }
package/index.d.ts ADDED
@@ -0,0 +1,62 @@
1
+ import { URIO } from "@fncts/io/IO";
2
+ import { HKT } from "@fncts/typelevel/HKT";
3
+ import type { ExpressApp, ExpressEnv } from "./ExpressApp.js";
4
+ import type { ErasedRequestHandlerIO, RequestHandlerIO, RequestHandlerRouteIO } from "./RequestHandlerIO.js";
5
+ import type { NextHandleFunction } from "connect";
6
+ import type { RequestHandler } from "express";
7
+ import type { RouteParameters } from "express-serve-static-core";
8
+ export * from "./errors.js";
9
+ export * from "./ExitHandler.js";
10
+ export * from "./ExpressApp.js";
11
+ export * from "./ExpressAppConfig.js";
12
+ export * from "./RequestHandlerIO.js";
13
+ export declare const methods: readonly ["all", "get", "post", "put", "delete", "patch", "options", "head", "checkout", "connect", "copy", "lock", "merge", "mkactivity", "mkcol", "move", "m-search", "notify", "propfind", "proppatch", "purge", "report", "search", "subscribe", "trace", "unlock", "unsubscribe"];
14
+ export declare type Methods = typeof methods[number];
15
+ export declare type PathParams = string | RegExp | Array<string | RegExp>;
16
+ export interface ParamsDictionary {
17
+ [key: string]: string;
18
+ }
19
+ export declare function match(method: Methods): {
20
+ <Route extends string, Handlers extends Array<RequestHandlerRouteIO<any, Route>>>(path: Route, ...handlers: never extends Handlers ? Array<RequestHandlerIO<any, Route, RouteParameters<Route>>> : Handlers): URIO<ExpressEnv & HKT._R<{
21
+ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? URIO<R, void> : never;
22
+ }[number]>, void>;
23
+ };
24
+ export declare function use<Handlers extends Array<RequestHandlerRouteIO>>(...handlers: Handlers): URIO<ExpressEnv & HKT._R<{
25
+ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? URIO<R, void> : never;
26
+ }[number]>, void>;
27
+ export declare function use<Route extends string, Handlers extends Array<RequestHandlerRouteIO<any, Route>>>(path: Route, ...handlers: never extends Handlers ? Array<RequestHandlerRouteIO<any, Route>> : Handlers): URIO<ExpressEnv & HKT._R<{
28
+ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? URIO<R, void> : never;
29
+ }[number]>, void>;
30
+ export declare const all: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
31
+ export declare const get: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
32
+ export declare const post: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
33
+ export declare const put: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
34
+ declare const delete_: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
35
+ export { delete_ as delete };
36
+ export declare const patch: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
37
+ export declare const options: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
38
+ export declare const head: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
39
+ export declare const checkout: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
40
+ export declare const connect: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
41
+ export declare const copy: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
42
+ export declare const lock: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
43
+ export declare const merge: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
44
+ export declare const mkactivity: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
45
+ export declare const mkcol: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
46
+ export declare const move: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
47
+ export declare const mSearch: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
48
+ export declare const notify: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
49
+ export declare const propfind: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
50
+ export declare const proppatch: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
51
+ export declare const purge: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
52
+ export declare const report: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
53
+ export declare const search: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
54
+ export declare const subscribe: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
55
+ export declare const trace: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
56
+ export declare const unlock: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
57
+ export declare const unsubscribe: <Route extends string, Handlers extends RequestHandlerRouteIO<any, Route>[]>(path: Route, ...handlers: never extends Handlers ? RequestHandlerIO<any, Route, RouteParameters<Route>, any, any, import("./RequestHandlerIO.js").ParsedQs, Record<string, any>>[] : Handlers) => import("@fncts/io/IO.js").URIO<import("@fncts/base/typeclass.js").Has<import("./ExpressAppConfig.js").ExpressAppConfig> & import("@fncts/base/typeclass.js").Has<ExpressApp> & import("@fncts/typelevel/HKT.js").HKT._R<{ [k in keyof Handlers]: [Handlers[k]] extends [ErasedRequestHandlerIO<infer R>] ? import("@fncts/io/IO.js").URIO<R, void> : never; }[number]>, void>;
58
+ /**
59
+ * Lift an express requestHandler into an effectified variant
60
+ */
61
+ export declare function classic(_: NextHandleFunction): RequestHandlerIO<unknown, any>;
62
+ export declare function classic(_: RequestHandler): RequestHandlerIO<unknown, any>;
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@fncts/express",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "@fncts/io": "0.0.9"
6
+ },
7
+ "peerDependencies": {
8
+ "express": "^4.18.1"
9
+ },
10
+ "exports": {
11
+ "./*": {
12
+ "import": "./_mjs/*.mjs",
13
+ "require": "./_cjs/*.cjs"
14
+ }
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ }
19
+ }