Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid bucked retrieved from (scrapyd) notification endpoint #1416

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/validations/src/validations/itemRoutesValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ export const getSimilarItems = z.object({
limit: z.number(),
});

export const importNotifiedETL = z.object({
bucket_name: z.string(),
file_key: z.string(),
spider_name: z.string(),
});
export type ImportNotifiedETL = z.infer<typeof importNotifiedETL>;

export const importItemHeaders = z.object({
Name: z.string(),
Weight: z.string(),
Expand Down
12 changes: 8 additions & 4 deletions server/src/controllers/item/importNotifiedETL.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import * as validator from '@packrat/validations';
import {
bulkAddItemsGlobalService,
parseCSVData,
fetchFromS3,
} from '../../services/item/item.service';
import { User } from '../../drizzle/methods/User';
import { Context } from 'hono';

export const importNotifiedETL = async (c) => {
const params = c.req.query();
const file_name = params.file_key;
export const importNotifiedETL = async (c: Context) => {
const body = await c.req.json<validator.ImportNotifiedETL>();
const file_name = body.file_key;
const bucket_name = body.bucket_name;
const spider_name = body.spider_name;

const endpoint = c.env.BUCKET_ENDPOINT;
const bucket = c.env.BUCKET_NAME;
Expand All @@ -34,7 +38,7 @@ export const importNotifiedETL = async (c) => {

try {
const fileData = await fetchFromS3(
`${endpoint}/${bucket}/${file_name}`,
`${endpoint}/${bucket_name}/${file_name}`,
method,
service,
region,
Expand Down
5 changes: 2 additions & 3 deletions server/src/routes/itemRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ router.get(
tryCatchWrapper(importFromBucket),
);

router.get(
router.post(
'/importNotifiedETL',
// authTokenMiddleware,
// zodParser(validator.importNotifiedETL, 'query'),
zodParser(validator.importNotifiedETL, 'body'),
tryCatchWrapper(importNotifiedETL),
);

Expand Down
Loading