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

Add batch creation API #159

Open
wants to merge 2 commits into
base: Roadmap-2023
Choose a base branch
from
Open
Changes from 1 commit
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
39 changes: 39 additions & 0 deletions batches.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const express = require('express');
const { v4: uuidv4 } = require('uuid');
const app = express();

// Define a global array to store the created batches
let batches = [];

// Middleware to parse JSON request bodies
app.use(express.json());

// POST /batches endpoint to create a new batch
app.post('/batches', (req, res) => {
const { template, data, engineType, templateType, outputType } = req.body;

// Generate a unique ID for the batch
const batchId = uuidv4();

// Create a new batch object
const newBatch = {
id: batchId,
template,
data,
engineType,
templateType,
outputType,
status: 'submitted',
};

// Add the new batch to the batches array
batches.push(newBatch);

// Return the created batch in the response
res.status(201).json(newBatch);
});

// Start the server
app.listen(3000, () => {
console.log('Server is running on port 3000');
});