diff --git a/package-lock.json b/package-lock.json index 843482c..bbe1c27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,7 @@ "nodemailer": "^6.9.15", "pino": "^9.5.0", "pino-http": "^10.3.0", - "swagger-ui-express": "^5.0.1", + "swagger-ui-express": "^4.6.3", "xss-filters": "^1.2.7", "zod": "^3.23.8" }, @@ -6954,12 +6954,12 @@ } }, "node_modules/swagger-ui-express": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/swagger-ui-express/-/swagger-ui-express-5.0.1.tgz", - "integrity": "sha512-SrNU3RiBGTLLmFU8GIJdOdanJTl4TOmT27tt3bWWHppqYmAZ6IDuEuBvMU6nZq0zLEe6b/1rACXCgLZqO6ZfrA==", + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/swagger-ui-express/-/swagger-ui-express-4.6.3.tgz", + "integrity": "sha512-CDje4PndhTD2HkgyKH3pab+LKspDeB/NhPN2OF1j+piYIamQqBYwAXWESOT1Yju2xFg51bRW9sUng2WxDjzArw==", "license": "MIT", "dependencies": { - "swagger-ui-dist": ">=5.0.0" + "swagger-ui-dist": ">=4.11.0" }, "engines": { "node": ">= v0.10.32" diff --git a/package.json b/package.json index 54db23c..18faad4 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "nodemailer": "^6.9.15", "pino": "^9.5.0", "pino-http": "^10.3.0", - "swagger-ui-express": "^5.0.1", + "swagger-ui-express": "^4.6.3", "xss-filters": "^1.2.7", "zod": "^3.23.8" }, diff --git a/src/index.ts b/src/index.ts index 7b92b18..04b55e2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,6 +8,9 @@ const app = express() import swaggerDocument from './openapi.json' import routes from './routes' +const SWAGGER_CSS_URL = + 'https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.1.0/swagger-ui.min.css' + const port = process.env.SERVER_PORT BigInt.prototype.toJSON = function () { @@ -18,7 +21,15 @@ app.use(cors()) app.use(express.json()) app.use(cookieParser()) app.use(sanitizeInput) -app.use('/api/docs', swaggerUI.serve, swaggerUI.setup(swaggerDocument)) +app.use( + '/api/docs', + swaggerUI.serve, + swaggerUI.setup(swaggerDocument, { + customCssUrl: SWAGGER_CSS_URL, + customCss: + '.swagger-ui .opblock .opblock-summary-path-description-wrapper { align-items: center; display: flex; flex-wrap: wrap; gap: 0 10px; padding: 0 10px; width: 100%; }', + }), +) app.use('/api/', routes) app.listen(port, () => { console.info(`Server running at port ${port}`) diff --git a/src/product/repository.ts b/src/product/repository.ts index c650dc8..52a3e6c 100644 --- a/src/product/repository.ts +++ b/src/product/repository.ts @@ -131,7 +131,7 @@ class ProductRepository { return products } - async deleteProductById(id: number) { + async deleteProductById(id: bigint) { try { await this.prisma.products.delete({ where: { diff --git a/src/product/schema.ts b/src/product/schema.ts index e6fd0ac..6a5189c 100644 --- a/src/product/schema.ts +++ b/src/product/schema.ts @@ -37,6 +37,7 @@ export type UpdateProductDataService = { new: string[] } } -export type FlattenUpdateProduct = Omit & { +export type FlattenUpdateProduct = Omit & { images: string[] + price: number } diff --git a/src/product/service.test.ts b/src/product/service.test.ts index 03ef5e6..856cf65 100644 --- a/src/product/service.test.ts +++ b/src/product/service.test.ts @@ -41,6 +41,7 @@ describe('product service', () => { createProduct: jest.fn(), getProductById: jest.fn(), getProducts: jest.fn(), + deleteProductById: jest.fn(), } as unknown as jest.Mocked productService = new ProductService(productRepo, logger)