@strav/http 0.1.0 → 0.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strav/http",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "description": "HTTP layer for the Strav framework — router, server, middleware, authentication, sessions, validation, and views",
6
6
  "license": "MIT",
package/src/auth/auth.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { inject } from '@stravigor/kernel/core/inject'
2
- import { ConfigurationError } from '@stravigor/kernel/exceptions/errors'
3
- import Configuration from '@stravigor/kernel/config/configuration'
4
- import Database from '@stravigor/database/database/database'
1
+ import { inject } from '@strav/kernel/core/inject'
2
+ import { ConfigurationError } from '@strav/kernel/exceptions/errors'
3
+ import Configuration from '@strav/kernel/config/configuration'
4
+ import Database from '@strav/database/database/database'
5
5
 
6
6
  // Re-export helpers that were originally defined here
7
- export { extractUserId } from '@stravigor/database/helpers/identity'
8
- export { randomHex } from '@stravigor/kernel/helpers/crypto'
7
+ export { extractUserId } from '@strav/database/helpers/identity'
8
+ export { randomHex } from '@strav/kernel/helpers/crypto'
9
9
 
10
10
  export interface TokenConfig {
11
11
  expiration: number | null
@@ -1,6 +1,9 @@
1
1
  import { parseCookies } from './cookie.ts'
2
- import type { ViewEngine } from '@stravigor/view'
3
- import { ConfigurationError } from '@stravigor/kernel/exceptions/errors'
2
+ // ViewEngine interface - concrete implementation provided by @strav/view
3
+ interface ViewEngine {
4
+ render(template: string, data?: Record<string, unknown>): Promise<string>
5
+ }
6
+ import { ConfigurationError } from '@strav/kernel/exceptions/errors'
4
7
 
5
8
  /**
6
9
  * HTTP request context — the primary object handlers interact with.
package/src/http/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { app } from '@stravigor/kernel/core/application'
1
+ import { app } from '@strav/kernel/core/application'
2
2
  import Router from './router.ts'
3
3
 
4
4
  export { default as Context } from './context.ts'
@@ -1,5 +1,5 @@
1
1
  import { DateTime } from 'luxon'
2
- import type { PaginationResult, PaginationMeta } from '@stravigor/database/database/query_builder'
2
+ import type { PaginationResult, PaginationMeta } from '@strav/database/database/query_builder'
3
3
 
4
4
  // ---------------------------------------------------------------------------
5
5
  // Resource base class
@@ -1,11 +1,11 @@
1
1
  import type { ServerWebSocket } from 'bun'
2
- import { app } from '@stravigor/kernel/core/application'
2
+ import { app } from '@strav/kernel/core/application'
3
3
  import Context from './context.ts'
4
4
  import { resolveCorsConfig, preflightResponse, withCorsHeaders } from './cors.ts'
5
5
  import type { CorsOptions, ResolvedCorsConfig } from './cors.ts'
6
6
  import { compose } from './middleware.ts'
7
7
  import type { Handler, Middleware } from './middleware.ts'
8
- import type { ExceptionHandler } from '@stravigor/kernel/exceptions/exception_handler'
8
+ import type { ExceptionHandler } from '@strav/kernel/exceptions/exception_handler'
9
9
 
10
10
  // ---------------------------------------------------------------------------
11
11
  // Types
@@ -1,7 +1,7 @@
1
1
  import { readdirSync, statSync, existsSync } from 'node:fs'
2
2
  import { join, resolve, normalize, relative } from 'node:path'
3
- import { inject } from '@stravigor/kernel/core/inject'
4
- import Configuration from '@stravigor/kernel/config/configuration'
3
+ import { inject } from '@strav/kernel/core/inject'
4
+ import Configuration from '@strav/kernel/config/configuration'
5
5
  import type Router from './router.ts'
6
6
  import type { WebSocketData } from './router.ts'
7
7
 
@@ -1,6 +1,6 @@
1
1
  import type Context from '../http/context.ts'
2
2
  import type { Middleware } from '../http/middleware.ts'
3
- // Moved from @stravigor/kernel/cache — depends on http types
3
+ // Moved from @strav/kernel/cache — depends on http types
4
4
 
5
5
  export interface HttpCacheOptions {
6
6
  /** Cache-Control max-age in seconds. @default 0 */
@@ -1,8 +1,8 @@
1
1
  import type Context from '../http/context.ts'
2
2
  import type { Next } from '../http/middleware.ts'
3
3
  import type { Middleware } from '../http/middleware.ts'
4
- import I18nManager from '@stravigor/kernel/i18n/i18n_manager'
5
- import { localeStorage } from '@stravigor/kernel/i18n/helpers'
4
+ import I18nManager from '@strav/kernel/i18n/i18n_manager'
5
+ import { localeStorage } from '@strav/kernel/i18n/helpers'
6
6
 
7
7
  /**
8
8
  * i18n middleware — detects the request locale and sets it for the
@@ -11,7 +11,7 @@ import { localeStorage } from '@stravigor/kernel/i18n/helpers'
11
11
  * Detection strategies are tried in the order configured in `config/i18n.ts`.
12
12
  *
13
13
  * @example
14
- * import { i18n } from '@stravigor/http/middleware/i18n'
14
+ * import { i18n } from '@strav/http/middleware/i18n'
15
15
  * router.use(i18n())
16
16
  */
17
17
  export function i18n(): Middleware {
@@ -1,5 +1,5 @@
1
1
  import type { Middleware } from '../http/middleware.ts'
2
- import type Logger from '@stravigor/kernel/logger/logger'
2
+ import type Logger from '@strav/kernel/logger/logger'
3
3
 
4
4
  export function requestLogger(logger: Logger): Middleware {
5
5
  return async (ctx, next) => {
@@ -1,5 +1,5 @@
1
- import ServiceProvider from '@stravigor/kernel/core/service_provider'
2
- import type Application from '@stravigor/kernel/core/application'
1
+ import ServiceProvider from '@strav/kernel/core/service_provider'
2
+ import type Application from '@strav/kernel/core/application'
3
3
  import Auth from '../auth/auth.ts'
4
4
 
5
5
  export interface AuthProviderOptions {
@@ -1,5 +1,5 @@
1
- import ServiceProvider from '@stravigor/kernel/core/service_provider'
2
- import type Application from '@stravigor/kernel/core/application'
1
+ import ServiceProvider from '@strav/kernel/core/service_provider'
2
+ import type Application from '@strav/kernel/core/application'
3
3
  import Server from '../http/server.ts'
4
4
  import Router from '../http/router.ts'
5
5
 
@@ -1,5 +1,5 @@
1
- import ServiceProvider from '@stravigor/kernel/core/service_provider'
2
- import type Application from '@stravigor/kernel/core/application'
1
+ import ServiceProvider from '@strav/kernel/core/service_provider'
2
+ import type Application from '@strav/kernel/core/application'
3
3
  import SessionManager from '../session/session_manager.ts'
4
4
 
5
5
  export interface SessionProviderOptions {
@@ -1,6 +1,7 @@
1
- import ServiceProvider from '@stravigor/kernel/core/service_provider'
2
- import type Application from '@stravigor/kernel/core/application'
3
- import { ViewEngine } from '@stravigor/view'
1
+ import ServiceProvider from '@strav/kernel/core/service_provider'
2
+ import type Application from '@strav/kernel/core/application'
3
+ // ViewProvider is implemented by @strav/view package
4
+ // This provider stub allows http to work without view package
4
5
  import Context from '../http/context.ts'
5
6
 
6
7
  export default class ViewProvider extends ServiceProvider {
@@ -8,11 +9,10 @@ export default class ViewProvider extends ServiceProvider {
8
9
  override readonly dependencies = ['config']
9
10
 
10
11
  override register(app: Application): void {
11
- app.singleton(ViewEngine)
12
+ // ViewEngine registration handled by @strav/view package
12
13
  }
13
14
 
14
15
  override boot(app: Application): void {
15
- const engine = app.resolve(ViewEngine)
16
- Context.setViewEngine(engine)
16
+ // ViewEngine setup handled by @strav/view package
17
17
  }
18
18
  }
@@ -13,7 +13,7 @@ import SessionManager from './session_manager.ts'
13
13
  * 5. After the handler: saves dirty data and refreshes the cookie
14
14
  *
15
15
  * @example
16
- * import { session } from '@stravigor/http/session'
16
+ * import { session } from '@strav/http/session'
17
17
  * router.use(session())
18
18
  */
19
19
  export function session(): Middleware {
@@ -1,7 +1,7 @@
1
1
  import type Context from '../http/context.ts'
2
2
  import { clearCookie } from '../http/cookie.ts'
3
- import { randomHex } from '@stravigor/kernel/helpers/crypto'
4
- import { extractUserId } from '@stravigor/database/helpers/identity'
3
+ import { randomHex } from '@strav/kernel/helpers/crypto'
4
+ import { extractUserId } from '@strav/database/helpers/identity'
5
5
  import SessionManager from './session_manager.ts'
6
6
 
7
7
  const FLASH_KEY = '_flash'
@@ -1,7 +1,7 @@
1
- import { inject } from '@stravigor/kernel/core/inject'
2
- import { ConfigurationError } from '@stravigor/kernel/exceptions/errors'
3
- import Configuration from '@stravigor/kernel/config/configuration'
4
- import Database from '@stravigor/database/database/database'
1
+ import { inject } from '@strav/kernel/core/inject'
2
+ import { ConfigurationError } from '@strav/kernel/exceptions/errors'
3
+ import Configuration from '@strav/kernel/config/configuration'
4
+ import Database from '@strav/database/database/database'
5
5
 
6
6
  export interface SessionConfig {
7
7
  cookie: string
@@ -1,4 +1,4 @@
1
- import { t } from '@stravigor/kernel/i18n/helpers'
1
+ import { t } from '@strav/kernel/i18n/helpers'
2
2
 
3
3
  export interface Rule {
4
4
  name: string
@@ -1,4 +1,4 @@
1
- import { TemplateError } from '@stravigor/kernel/exceptions/errors'
1
+ import { TemplateError } from '@strav/kernel/exceptions/errors'
2
2
  import type { Token } from './tokenizer.ts'
3
3
 
4
4
  export interface CompilationResult {
@@ -1,12 +1,12 @@
1
1
  import { resolve, join } from 'node:path'
2
- import { inject } from '@stravigor/kernel/core/inject'
3
- import Configuration from '@stravigor/kernel/config/configuration'
2
+ import { inject } from '@strav/kernel/core/inject'
3
+ import Configuration from '@strav/kernel/config/configuration'
4
4
  import { escapeHtml } from './escape.ts'
5
5
  import { tokenize } from './tokenizer.ts'
6
6
  import { compile } from './compiler.ts'
7
7
  import TemplateCache from './cache.ts'
8
8
  import type { CacheEntry, RenderFunction, IncludeFn } from './cache.ts'
9
- import { ConfigurationError, TemplateError } from '@stravigor/kernel/exceptions/errors'
9
+ import { ConfigurationError, TemplateError } from '@strav/kernel/exceptions/errors'
10
10
 
11
11
  const MAX_INCLUDE_DEPTH = 50
12
12
 
@@ -1,4 +1,4 @@
1
- import { TemplateError } from '@stravigor/kernel/exceptions/errors'
1
+ import { TemplateError } from '@strav/kernel/exceptions/errors'
2
2
  export type TokenType = 'text' | 'escaped' | 'raw' | 'comment' | 'directive' | 'vue_island'
3
3
 
4
4
  export interface VueAttr {