Syntax changes in front and back end dirs. These do not affect functionality and are purely intended to better capture and describe the app's functionality and purpose
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
import type { Request, Response, NextFunction } from 'express';
|
||||
import * as notebookStore from '../stores/notebookStore.js';
|
||||
import type { Notebook } from '../stores/notebookStore.js';
|
||||
import * as sourceCorpusStore from '../stores/sourceCorpusStore.js';
|
||||
import type { SourceCorpus } from '../stores/sourceCorpusStore.js';
|
||||
|
||||
export interface NotebookRequest extends Request {
|
||||
notebookId?: string;
|
||||
notebook?: Notebook;
|
||||
export interface SourceCorpusRequest extends Request {
|
||||
sourceCorpusId?: string;
|
||||
sourceCorpus?: SourceCorpus;
|
||||
}
|
||||
|
||||
export function requireNotebookId(req: NotebookRequest, res: Response, next: NextFunction): void {
|
||||
const notebookId = (req.body?.notebookId ?? req.query?.notebookId) as string | undefined;
|
||||
if (!notebookId) {
|
||||
res.status(400).json({ error: 'notebookId is required' });
|
||||
export function requireSourceCorpusId(req: SourceCorpusRequest, res: Response, next: NextFunction): void {
|
||||
const sourceCorpusId = (req.body?.sourceCorpusId ?? req.query?.sourceCorpusId) as string | undefined;
|
||||
if (!sourceCorpusId) {
|
||||
res.status(400).json({ error: 'sourceCorpusId is required' });
|
||||
return;
|
||||
}
|
||||
req.notebookId = notebookId;
|
||||
req.sourceCorpusId = sourceCorpusId;
|
||||
next();
|
||||
}
|
||||
|
||||
export function requireNotebook(req: NotebookRequest, res: Response, next: NextFunction): void {
|
||||
const notebook = notebookStore.getNotebook(req.notebookId!);
|
||||
if (!notebook) {
|
||||
res.status(404).json({ error: 'notebook not found' });
|
||||
export function requireSourceCorpus(req: SourceCorpusRequest, res: Response, next: NextFunction): void {
|
||||
const sourceCorpus = sourceCorpusStore.getSourceCorpus(req.sourceCorpusId!);
|
||||
if (!sourceCorpus) {
|
||||
res.status(404).json({ error: 'source corpus not found' });
|
||||
return;
|
||||
}
|
||||
req.notebook = notebook;
|
||||
req.sourceCorpus = sourceCorpus;
|
||||
next();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user