@hyperspan/framework 1.0.0-alpha.12 → 1.0.0-alpha.13

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperspan/framework",
3
- "version": "1.0.0-alpha.12",
3
+ "version": "1.0.0-alpha.13",
4
4
  "description": "Hyperspan Web Framework",
5
5
  "main": "src/server.ts",
6
6
  "types": "src/server.ts",
package/src/server.ts CHANGED
@@ -65,6 +65,7 @@ export function createContext(req: Request, route?: HS.Route): HS.Context {
65
65
  return {
66
66
  vars: {},
67
67
  route: {
68
+ name: route?._config.name || undefined,
68
69
  path,
69
70
  params: params,
70
71
  cssImports: route ? route._config.cssImports ?? [] : [],
@@ -101,7 +102,7 @@ export function createContext(req: Request, route?: HS.Route): HS.Context {
101
102
  * Define a route that can handle a direct HTTP request.
102
103
  * Route handlers should return a HSHtml or Response object
103
104
  */
104
- export function createRoute(config: HS.RouteConfig = {}): HS.Route {
105
+ export function createRoute(config: Partial<HS.RouteConfig> = {}): HS.Route {
105
106
  const _handlers: Record<string, HS.RouteHandler> = {};
106
107
  let _middleware: Record<string, Array<HS.MiddlewareFunction>> = { '*': [] };
107
108
 
package/src/types.ts CHANGED
@@ -88,10 +88,10 @@ export namespace Hyperspan {
88
88
  };
89
89
 
90
90
  export type RouteConfig = {
91
- name?: string;
92
- path?: string;
93
- params?: Record<string, string | undefined>;
94
- cssImports?: string[];
91
+ name: string | undefined;
92
+ path: string;
93
+ params: Record<string, string | undefined>;
94
+ cssImports: string[];
95
95
  };
96
96
  export type RouteHandler = (context: Hyperspan.Context) => unknown;
97
97
  export type RouteHandlerOptions = {
@@ -124,7 +124,7 @@ export namespace Hyperspan {
124
124
 
125
125
  export interface Route {
126
126
  _kind: 'hsRoute';
127
- _config: Hyperspan.RouteConfig;
127
+ _config: Partial<Hyperspan.RouteConfig>;
128
128
  _path(): string;
129
129
  _methods(): string[];
130
130
  get: (handler: Hyperspan.RouteHandler, handlerOptions?: Hyperspan.RouteHandlerOptions) => Hyperspan.Route;