@hulla/api-netlify-functions 0.0.0-stage → 2.0.0

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,29 @@
1
+ import { FetchServerErrorInput } from "@hulla/api/fetch";
2
+ import { Awaitable, ServerAdapter, ServerContextInput, ServerExecutableFor } from "@hulla/api/server";
3
+ import { Contract } from "@hulla/api";
4
+ import { Config, Context } from "@netlify/functions";
5
+ //#region src/index.d.ts
6
+ type NetlifyContext = Context;
7
+ type NetlifyConfig = Config;
8
+ type NetlifyFunction = (request: Request, context: NetlifyContext) => Promise<Response>;
9
+ type NetlifyAdapterContext = {
10
+ readonly request: Request;
11
+ readonly netlifyContext: NetlifyContext;
12
+ };
13
+ type NetlifyContextInput<ContractType extends Contract> = ServerContextInput<ContractType> & NetlifyAdapterContext;
14
+ type NetlifyServerErrorInput = Omit<FetchServerErrorInput<NetlifyContext>, 'handlerContext'> & {
15
+ readonly netlifyContext: NetlifyContext;
16
+ };
17
+ type NetlifyAdapterOptions = {
18
+ readonly onError?: (input: NetlifyServerErrorInput) => Awaitable<Response | undefined | void>;
19
+ };
20
+ type NetlifyMountOptions = NetlifyAdapterOptions;
21
+ type NetlifyMount = {
22
+ <const ContractType extends Contract, const Context extends object>(implementation: ServerExecutableFor<ContractType, Context, 'netlify-functions', NetlifyAdapterContext>, options?: NetlifyMountOptions): NetlifyFunction;
23
+ };
24
+ type NetlifyAdapter = ServerAdapter<'netlify-functions', NetlifyAdapterContext> & {
25
+ readonly mount: NetlifyMount;
26
+ };
27
+ declare function netlifyFunctionsAdapter(options?: NetlifyAdapterOptions): NetlifyAdapter;
28
+ //#endregion
29
+ export { NetlifyAdapter, NetlifyAdapterContext, NetlifyAdapterOptions, NetlifyConfig, NetlifyContext, NetlifyContextInput, NetlifyFunction, NetlifyMountOptions, NetlifyServerErrorInput, netlifyFunctionsAdapter };
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ import { createFetchHandler } from "@hulla/api/fetch";
2
+ import { createServerAdapter } from "@hulla/api/server";
3
+
4
+ //#region src/index.ts
5
+ function createNetlifyHandler(implementation, options) {
6
+ const handler = createFetchHandler(implementation, {
7
+ contextAdapter: "netlify-functions",
8
+ contextInput: (request, netlifyContext) => ({
9
+ request,
10
+ netlifyContext
11
+ }),
12
+ ...options.onError === void 0 ? {} : { onError: ({ handlerContext, ...input }) => options.onError?.({
13
+ ...input,
14
+ netlifyContext: handlerContext
15
+ }) }
16
+ });
17
+ return (request, context) => handler(request, context);
18
+ }
19
+ let netlifyFunctionsAdapterValue;
20
+ function createNetlifyFunctionsAdapter(defaults) {
21
+ return createServerAdapter("netlify-functions", { mount: (implementation, options) => createNetlifyHandler(implementation, options === void 0 ? defaults : {
22
+ ...defaults,
23
+ ...options
24
+ }) });
25
+ }
26
+ function netlifyFunctionsAdapter(options) {
27
+ if (options !== void 0) return createNetlifyFunctionsAdapter({ ...options });
28
+ netlifyFunctionsAdapterValue ??= createNetlifyFunctionsAdapter({});
29
+ return netlifyFunctionsAdapterValue;
30
+ }
31
+
32
+ //#endregion
33
+ export { netlifyFunctionsAdapter };
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@hulla/api-netlify-functions",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.0",
4
+ "description": "Netlify Functions server adapter for @hulla/api",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/hulladev/api.git",
9
+ "directory": "packages/netlify-functions"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "type": "module",
15
+ "sideEffects": false,
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js"
20
+ }
21
+ },
22
+ "publishConfig": {
23
+ "access": "public",
24
+ "registry": "https://registry.npmjs.org/"
25
+ },
26
+ "scripts": {
27
+ "build": "tsdown",
28
+ "clean": "rm -rf dist coverage",
29
+ "test": "bun run build && vitest run",
30
+ "test:coverage": "bun run build && vitest run --coverage",
31
+ "test:watch": "vitest",
32
+ "typecheck": "tsc --noEmit"
33
+ },
34
+ "devDependencies": {
35
+ "@hulla/api": "2.0.0",
36
+ "@netlify/functions": "^5.3.0",
37
+ "zod": "^4.4.3"
38
+ },
39
+ "peerDependencies": {
40
+ "@hulla/api": "^2.0.0",
41
+ "@netlify/functions": "^4.0.0 || ^5.0.0"
42
+ },
43
+ "engines": {
44
+ "node": ">=22"
45
+ }
46
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.