@axiosleo/koapp
Advanced tools
@@ -22,3 +22,3 @@ { | ||
| "dependencies": { | ||
| "@axiosleo/koapp": "^1.1.1", | ||
| "@axiosleo/koapp": "^1.1.2", | ||
| "@axiosleo/orm-mysql": "^0.11.2", | ||
@@ -25,0 +25,0 @@ "cluster": "^0.7.7", |
+1
-1
@@ -12,3 +12,3 @@ #!/usr/bin/env node | ||
| bin: 'koapp', | ||
| version: '1.1.1', | ||
| version: '1.1.2', | ||
| commands_dir: path.join(__dirname, '../commands'), | ||
@@ -15,0 +15,0 @@ }); |
+0
-5
| import { Configuration, Context, Workflow } from "@axiosleo/cli-tool"; | ||
| import { File } from "@koa/multer"; | ||
| import { EventEmitter } from "events"; | ||
@@ -495,6 +494,2 @@ import { IncomingHttpHeaders } from "http"; | ||
| body?: TBody; | ||
| /** Uploaded file */ | ||
| file?: File | null; | ||
| /** Uploaded files array */ | ||
| files?: File[]; | ||
| /** Query parameters */ | ||
@@ -501,0 +496,0 @@ query?: TQuery; |
+0
-2
@@ -9,3 +9,2 @@ 'use strict'; | ||
| const { initContext } = require('./src/core'); | ||
| const multer = require('@koa/multer'); | ||
| const session = require('koa-session'); | ||
@@ -32,3 +31,2 @@ const { SocketClient } = require('./src/utils'); | ||
| KoaSSEMiddleware, | ||
| KoaMulterMiddleware: multer, | ||
| KoaSessionMiddleware: session | ||
@@ -35,0 +33,0 @@ }, |
+2
-2
| { | ||
| "name": "@axiosleo/koapp", | ||
| "version": "1.1.1", | ||
| "version": "1.1.2", | ||
| "description": "", | ||
@@ -30,3 +30,2 @@ "author": "AxiosLeo", | ||
| "@axiosleo/cli-tool": "^1.6.4", | ||
| "@koa/multer": "^3.0.2", | ||
| "koa": "^2.15.3", | ||
@@ -44,2 +43,3 @@ "koa-bodyparser": "^4.4.1", | ||
| "@eslint/js": "^9.17.0", | ||
| "@koa/multer": "^4.0.0", | ||
| "@types/koa__multer": "^2.0.7", | ||
@@ -46,0 +46,0 @@ "@types/node": "^20.12.12", |
+32
-12
@@ -10,5 +10,5 @@ # @axiosleo/koapp | ||
| > Design for quickly developing Web applications using Node.js | ||
| > A framework designed for rapid web application development with Node.js | ||
| > | ||
| > Based on [koa](https://koajs.com/) | ||
| > Built on [Koa](https://koajs.com/) | ||
@@ -24,3 +24,3 @@ ```bash | ||
| # show help info | ||
| # Show help information | ||
| # npx @axiosleo/koapp init -h | ||
@@ -47,3 +47,3 @@ ``` | ||
| port: 8088, | ||
| listen_host: "localhost", // 0.0.0.0 for public access | ||
| listen_host: "localhost", // Use 0.0.0.0 for public access | ||
| routers: [router], | ||
@@ -53,3 +53,3 @@ }); | ||
| // open http://localhost:8088/test | ||
| // Open http://localhost:8088/test | ||
| ``` | ||
@@ -59,7 +59,7 @@ | ||
| - Validation | ||
| - Request Validation | ||
| > see [validatorjs](https://github.com/mikeerickson/validatorjs) for more rule examples | ||
| > See [validatorjs](https://github.com/mikeerickson/validatorjs) for more rule examples | ||
| > | ||
| > see `Router` examples for more usage: [tests/bootstrap.js](tests/bootstrap.js) | ||
| > See `Router` examples for more usage: [tests/bootstrap.js](tests/bootstrap.js) | ||
@@ -72,3 +72,3 @@ ```javascript | ||
| validator: { | ||
| // url params, like `/test/{:id}`, the 'id' is required and must be an integer | ||
| // URL params, like `/test/{:id}`, where 'id' is required and must be an integer | ||
| params: { | ||
@@ -82,4 +82,4 @@ id: "required|integer", | ||
| age: "required|integer", | ||
| } | ||
| } | ||
| }, | ||
| }, | ||
| handlers: [], | ||
@@ -89,5 +89,25 @@ }); | ||
| - SSE | ||
| - File Operations | ||
| ```javascript | ||
| // npm install @koa/multer | ||
| // npm install -D @types/koa__multer | ||
| const multer = require("@koa/multer"); | ||
| root.post("/upload", async (context) => { | ||
| // Array of files | ||
| const upload = multer(); | ||
| const func = upload.any(); | ||
| await func(context.koa, async () => {}); | ||
| const file = context.koa.request.files[0]; | ||
| context.koa.set("content-type", file.mimetype); | ||
| context.koa.body = file.buffer; | ||
| context.koa.attachment(file.originalname); | ||
| }); | ||
| ``` | ||
| - Server-Sent Events (SSE) | ||
| ```javascript | ||
| const { _foreach, _sleep } = require("@axiosleo/cli-tool/src/helper/cmd"); | ||
@@ -94,0 +114,0 @@ |
@@ -28,4 +28,2 @@ | ||
| context.router = router; | ||
| context.files = context.koa.request.files || []; | ||
| context.file = context.koa.request.file || null; | ||
| } catch (err) { | ||
@@ -32,0 +30,0 @@ context.response = err; |
156120
0.15%9
-10%130
18.18%11
10%4041
-0.22%- Removed
- Removed
- Removed
- Removed
- Removed