@stacksjs/server 0.72.103 → 0.73.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/dist/controllers/base.d.ts +9 -10
- package/dist/controllers/base.js +1 -1
- package/dist/start.js +1 -1
- package/package.json +5 -5
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare type Request = any;
|
|
1
|
+
import type { Request, ResponseStatus } from '@stacksjs/router';
|
|
3
2
|
/**
|
|
4
3
|
* Base Controller class providing Laravel-like functionality
|
|
5
4
|
*/
|
|
6
5
|
export declare class Controller {
|
|
7
|
-
protected json(data:
|
|
8
|
-
protected success(data:
|
|
9
|
-
protected created(data:
|
|
6
|
+
protected json(data: unknown, status?: ResponseStatus): Response;
|
|
7
|
+
protected success(data: unknown): Response;
|
|
8
|
+
protected created(data: unknown): Response;
|
|
10
9
|
protected noContent(): any;
|
|
11
|
-
protected error(message: string, status?:
|
|
12
|
-
protected notFound(message?: string):
|
|
13
|
-
protected unauthorized(message?: string):
|
|
14
|
-
protected forbidden(message?: string):
|
|
15
|
-
protected validate(request: Request, rules: Record<string,
|
|
10
|
+
protected error(message: string, status?: ResponseStatus): Response;
|
|
11
|
+
protected notFound(message?: string): Response;
|
|
12
|
+
protected unauthorized(message?: string): Response;
|
|
13
|
+
protected forbidden(message?: string): Response;
|
|
14
|
+
protected validate(request: Request, rules: Record<string, unknown>): Promise<void>;
|
|
16
15
|
}
|
package/dist/controllers/base.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{response}from"@stacksjs/router";import{log}from"@stacksjs/logging";export class Controller{json(data,status=200){return response.json(data,status)}success(data){return this.json(data,200)}created(data){return this.json(data,201)}noContent(){return response.noContent()}error(message,status=500){return this.json({error:message},status)}notFound(message="Resource not found"){return this.error(message,404)}unauthorized(message="Unauthorized"){return this.error(message,401)}forbidden(message="Forbidden"){return this.error(message,403)}async validate(request,rules){if(typeof request.validate!=="function")throw TypeError("This request does not carry the validation macro.");const result=await request.validate(rules);log.info("Validation result:",result)}}
|
package/dist/start.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
globalThis.__STACKS_BINARY_MODE__=!0;import{assertRouteMiddlewareResolvable,loadRoutes,serve}from"@stacksjs/router";import{log,report}from"@stacksjs/logging";import config from"./config-production";import routeRegistry from"../../../../../app/Routes";process.on("unhandledRejection",(reason)=>{report(reason,{label:"[server] unhandledRejection"})});process.on("uncaughtException",(error)=>{report(error,{label:"[server] uncaughtException"});log.flush().finally(()=>process.exit(1))});console.log("[START] Application starting...");console.log("[START] Node version:",process.version);console.log("[START] Working directory:",process.cwd());console.log("[START] Environment:",process.env.APP_ENV||"not set");process.env.SKIP_CONFIG_LOADING="true";console.log("[START] Config loaded:",{port:config.server.port,host:config.server.host,appName:config.app.name,appUrl:config.app.url});console.log("[START] Loading routes from registry...");loadRoutes(routeRegistry).then(async()=>{console.log("[START] Routes loaded successfully");try{const ormRoutesPackage="@stacksjs/orm/routes";try{await import(ormRoutesPackage)}catch{await import("../../orm/routes")}console.log("[START] ORM routes loaded successfully")}catch(ormError){console.warn("[START] ORM routes skipped:",ormError instanceof Error?ormError.message:String(ormError))}try{await assertRouteMiddlewareResolvable();console.log("[START] Route middleware validated")}catch(middlewareError){console.error("[START] FATAL: unresolvable route middleware - refusing to serve unprotected routes:",middlewareError instanceof Error?middlewareError.message:String(middlewareError));process.exit(1)}console.log("[START] Calling serve()...");try{serve({port:config.server.port,
|
|
1
|
+
globalThis.__STACKS_BINARY_MODE__=!0;import{assertRouteMiddlewareResolvable,loadRoutes,serve}from"@stacksjs/router";import{log,report}from"@stacksjs/logging";import config from"./config-production";import routeRegistry from"../../../../../app/Routes";process.on("unhandledRejection",(reason)=>{report(reason,{label:"[server] unhandledRejection"})});process.on("uncaughtException",(error)=>{report(error,{label:"[server] uncaughtException"});log.flush().finally(()=>process.exit(1))});console.log("[START] Application starting...");console.log("[START] Node version:",process.version);console.log("[START] Working directory:",process.cwd());console.log("[START] Environment:",process.env.APP_ENV||"not set");process.env.SKIP_CONFIG_LOADING="true";console.log("[START] Config loaded:",{port:config.server.port,host:config.server.host,appName:config.app.name,appUrl:config.app.url});console.log("[START] Loading routes from registry...");loadRoutes(routeRegistry).then(async()=>{console.log("[START] Routes loaded successfully");try{const ormRoutesPackage="@stacksjs/orm/routes";try{await import(ormRoutesPackage)}catch{await import("../../orm/routes")}console.log("[START] ORM routes loaded successfully")}catch(ormError){console.warn("[START] ORM routes skipped:",ormError instanceof Error?ormError.message:String(ormError))}try{await assertRouteMiddlewareResolvable();console.log("[START] Route middleware validated")}catch(middlewareError){console.error("[START] FATAL: unresolvable route middleware - refusing to serve unprotected routes:",middlewareError instanceof Error?middlewareError.message:String(middlewareError));process.exit(1)}console.log("[START] Calling serve()...");try{serve({port:config.server.port,hostname:config.server.host});console.log("[START] serve() called successfully")}catch(error){console.error("[START] ERROR calling serve():",error);process.exit(1)}}).catch((error)=>{console.error("[START] ERROR loading routes:",error);process.exit(1)});
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/server",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.73.1",
|
|
6
6
|
"description": "Local development and production-ready.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"prepublishOnly": "bun run build"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@stacksjs/config": "0.
|
|
61
|
+
"@stacksjs/config": "0.73.1",
|
|
62
62
|
"better-dx": "^0.2.24",
|
|
63
|
-
"@stacksjs/path": "0.
|
|
64
|
-
"@stacksjs/router": "0.
|
|
65
|
-
"@stacksjs/validation": "0.
|
|
63
|
+
"@stacksjs/path": "0.73.1",
|
|
64
|
+
"@stacksjs/router": "0.73.1",
|
|
65
|
+
"@stacksjs/validation": "0.73.1"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"bun-plugin-auto-imports": "^0.4.0"
|