diff --git a/README.md b/README.md index 7b5e2ea..22c4a4c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/shotit/shotit-api/docker-image.yml?style=flat-square)](https://github.com/shotit/shotit-api/actions) [![Codecov](https://img.shields.io/codecov/c/github/shotit/shotit-api?style=flat-square&token=8C25WLSEDJ)](https://codecov.io/gh/shotit/shotit-api) [![Docker](https://img.shields.io/docker/pulls/lesliewong007/shotit-api?style=flat-square)](https://hub.docker.com/r/lesliewong007/shotit-api) -[![Docker Image Size](https://img.shields.io/docker/image-size/lesliewong007/shotit-api/v0.9.12?style=flat-square)](https://hub.docker.com/r/lesliewong007/shotit-api) +[![Docker Image Size](https://img.shields.io/docker/image-size/lesliewong007/shotit-api/v0.9.13?style=flat-square)](https://hub.docker.com/r/lesliewong007/shotit-api) The ultimate brain of [shotit](https://github.com/shotit/shotit), in charge of task coordination. diff --git a/package.json b/package.json index a58d886..1d7950f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shotit-api", - "version": "0.9.12", + "version": "0.9.13", "description": "The ultimate brain of shotit, in charge of task coordination", "main": "server.js", "type": "module", diff --git a/src/search.js b/src/search.js index c728883..9d02f48 100644 --- a/src/search.js +++ b/src/search.js @@ -10,6 +10,7 @@ import https from "node:https"; import cv from "@soruly/opencv4nodejs-prebuilt"; import { performance } from "perf_hooks"; import { publicIpv6 } from "public-ip"; + // import getSolrCoreList from "./lib/get-solr-core-list.js"; // const { TRACE_MEDIA_URL, TRACE_MEDIA_SALT, TRACE_ACCURACY = 1 } = process.env; @@ -209,6 +210,12 @@ export default async (req, res) => { searchFile = req.files[0].buffer; } else if (req.rawBody?.length) { searchFile = req.rawBody; + } else if (req.method === "HEAD") { + await logAndDequeue(knex, redis, uid, priority, 204); + // Note: the client side can not recive the json object because of HEAD + return res.status(204).json({ + error: "HEAD method acknowledged", + }); } else { await logAndDequeue(knex, redis, uid, priority, 405); return res.status(405).json({ diff --git a/src/search.test.js b/src/search.test.js index 350bc98..69f138c 100644 --- a/src/search.test.js +++ b/src/search.test.js @@ -607,6 +607,14 @@ describe("invalid input", () => { }, 1000 * 10 ); + test( + "/search only by HEAD", + async () => { + const response = await request(app).head("/search"); + expect(response.statusCode).toBe(204); + }, + 1000 * 10 + ); }); describe.each([ diff --git a/src/user/create.test.js b/src/user/create.test.js index f40b082..09ea344 100644 --- a/src/user/create.test.js +++ b/src/user/create.test.js @@ -97,5 +97,5 @@ describe("Create user with valid system API key", () => { expect(response.statusCode).toBe(200); expect(response.headers["content-type"]).toMatch(/^application\/json/); expect(typeof response.body).toBe("object"); - }, 10000); + }, 20000); }); diff --git a/yarn.lock b/yarn.lock index 320a505..98d6d37 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,22 @@ # yarn lockfile v1 +"@actions/core@^1.10.1": + version "1.10.1" + resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.10.1.tgz#61108e7ac40acae95ee36da074fa5850ca4ced8a" + integrity sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g== + dependencies: + "@actions/http-client" "^2.0.1" + uuid "^8.3.2" + +"@actions/http-client@^2.0.1": + version "2.2.3" + resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-2.2.3.tgz#31fc0b25c0e665754ed39a9f19a8611fc6dab674" + integrity sha512-mx8hyJi/hjFvbPokCg4uRd4ZX78t+YyRPtnKWwIl+RzNaVuFpQHfmlGVfsKEJN8LwTCvL+DfVgAM04XaHkm6bA== + dependencies: + tunnel "^0.0.6" + undici "^5.25.4" + "@ampproject/remapping@^2.2.0": version "2.2.1" resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.1.tgz#99e8e11851128b8702cd57c33684f1d0f260b630" @@ -313,6 +329,11 @@ enabled "2.0.x" kuler "^2.0.0" +"@fastify/busboy@^2.0.0": + version "2.1.1" + resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.1.tgz#b9da6a878a371829a0502c9b6c1c143ef6663f4d" + integrity sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA== + "@grpc/grpc-js@^1.8.17": version "1.8.17" resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.8.17.tgz#a3a2f826fc033eae7d2f5ee41e0ab39cee948838" @@ -3598,6 +3619,11 @@ tunnel-agent@^0.6.0: dependencies: safe-buffer "^5.0.1" +tunnel@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c" + integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg== + type-detect@4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" @@ -3621,6 +3647,13 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA== +undici@^5.25.4: + version "5.28.4" + resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.4.tgz#6b280408edb6a1a604a9b20340f45b422e373068" + integrity sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g== + dependencies: + "@fastify/busboy" "^2.0.0" + universalify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" @@ -3649,6 +3682,11 @@ utils-merge@1.0.1: resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA== +uuid@^8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" + integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== + v8-to-istanbul@^9.0.1: version "9.1.0" resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz#1b83ed4e397f58c85c266a570fc2558b5feb9265"