Compare commits
5 Commits
e81f6ac8b7
...
master
Author | SHA1 | Date | |
---|---|---|---|
fd6311516f | |||
81acc54dc9 | |||
c12338410f | |||
46031a5fd2 | |||
df10328d55 |
14
package.json
14
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "axp-server",
|
||||
"version": "1.4.12",
|
||||
"version": "1.4.15",
|
||||
"description": "My helper library",
|
||||
"author": "AntoXa PRO <info@antoxa.pro>",
|
||||
"homepage": "https://antoxahub.ru/antoxa/axp-server",
|
||||
@@ -20,16 +20,16 @@
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"axp-ts": "^1.9.6",
|
||||
"axp-ts": "^1.11.3",
|
||||
"dotenv": "^16.3.1",
|
||||
"express": "^4.18.2",
|
||||
"mongoose": "^6.11.2"
|
||||
"mongoose": "^6.12.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-typescript": "^11.1.2",
|
||||
"@types/express": "^4.17.17",
|
||||
"@rollup/plugin-typescript": "^11.1.5",
|
||||
"@types/express": "^4.17.18",
|
||||
"prettier": "^2.8.8",
|
||||
"rollup": "^3.26.2",
|
||||
"tslib": "^2.6.0"
|
||||
"rollup": "^3.29.4",
|
||||
"tslib": "^2.6.2"
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,6 @@ export default defineConfig({
|
||||
dir: 'dist',
|
||||
format: 'es'
|
||||
},
|
||||
plugins: [typescript()],
|
||||
external: ['path', 'axp-ts', 'dotenv', 'express', 'mongoose'],
|
||||
plugins: [typescript()]
|
||||
})
|
||||
|
@@ -8,6 +8,7 @@ import { api404Handler, resultHandler } from './core/handlers'
|
||||
export default async (
|
||||
modules: (typeof AppModule)[] = []
|
||||
): Promise<Express> => {
|
||||
|
||||
// Express.
|
||||
const app = express()
|
||||
const apiRouter = Router()
|
||||
|
@@ -3,6 +3,7 @@ import { DataResultEntity } from 'axp-ts'
|
||||
|
||||
/**
|
||||
* Базовый контроллер.
|
||||
* @deprecated
|
||||
*/
|
||||
export class BaseController {
|
||||
/**
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { TNotificationItem } from 'axp-ts'
|
||||
import { NotificationItem, TNotificationItem } from 'axp-ts'
|
||||
|
||||
/**
|
||||
* Тип - Http ошибка.
|
||||
@@ -13,15 +13,17 @@ export type THttpError = {
|
||||
* Http ошибка.
|
||||
*/
|
||||
export class HttpError implements THttpError {
|
||||
status: number = 500
|
||||
message: string = 'Server Error'
|
||||
status: number
|
||||
message: string
|
||||
errors: TNotificationItem[] = []
|
||||
|
||||
constructor(args?: { text?: string; code?: string; statusCode?: number }) {
|
||||
this.status = args?.statusCode || 500
|
||||
this.message = this.getStatusMessage(this.status)
|
||||
if (args?.text) {
|
||||
this.errors.push({ code: args.code || 'error', text: args.text })
|
||||
this.errors.push(
|
||||
new NotificationItem({ code: args.code || 'error', text: args.text })
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,6 @@
|
||||
import { Request, Response, NextFunction } from 'express'
|
||||
import type { Request, Response, NextFunction } from 'express'
|
||||
import type { IFormModel } from 'axp-ts'
|
||||
|
||||
import { z } from 'zod'
|
||||
import { DataResultEntity } from 'axp-ts'
|
||||
|
||||
@@ -75,10 +77,6 @@ export const zodMiddle =
|
||||
(schemas: TZodMiddleArgs) =>
|
||||
(req: Request, {}: Response, next: NextFunction) => {
|
||||
try {
|
||||
// req.params._id = ''
|
||||
// req.body.email = 'test'
|
||||
// console.log(req.body)
|
||||
|
||||
if (schemas.query) req.query = schemas.query.parse(req.query)
|
||||
if (schemas.params) req.params = schemas.params.parse(req.params)
|
||||
if (schemas.body) req.body = schemas.body.parse(req.body)
|
||||
|
Reference in New Issue
Block a user