feat: Initialize new batch insertion service with Express, Docker, and Boltic deployment configuration.
This commit is contained in:
commit
227b3e67c9
|
|
@ -0,0 +1,22 @@
|
|||
# Dependencies
|
||||
node_modules/
|
||||
npm-debug.log*
|
||||
|
||||
# Environment files
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Google Cloud
|
||||
.gcloudignore
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
FROM node:18-alpine
|
||||
EXPOSE 8080
|
||||
COPY . .
|
||||
RUN npm install
|
||||
CMD ["npm", "start"]
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
app: batchinsertion
|
||||
region: asia-south1
|
||||
entrypoint: "index.js"
|
||||
|
||||
build:
|
||||
builtin: dockerfile
|
||||
ignorefile: .gitignore
|
||||
|
||||
env:
|
||||
PORT: '8080'
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
import express from 'express';
|
||||
import dotenv from 'dotenv';
|
||||
import { batchInsert } from './batchInsertCall.js';
|
||||
|
||||
const app = express();
|
||||
|
||||
// Middleware to parse JSON bodies
|
||||
app.use(express.json());
|
||||
|
||||
dotenv.config({ path: '.env' });
|
||||
|
||||
// Health check endpoint
|
||||
app.get('/', (req, res) => {
|
||||
res.json({
|
||||
status: 'OK',
|
||||
message: 'Batch insert Service is running',
|
||||
endpoints: {
|
||||
export: 'POST /batch-insert - Batch insert data to BQ'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
app.post('/batch-insert', async (req, res) => {
|
||||
try {
|
||||
const result = await batchInsert(req, res);
|
||||
res.status(200).json(result);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Export endpoint error:', error);
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
error: error.message
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const PORT = process.env.PORT || 8080;
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server is running on port ${PORT}`);
|
||||
});
|
||||
|
||||
// For serverless functions (like Google Cloud Functions)
|
||||
export default app;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"type": "module",
|
||||
"name": "batchinsertion",
|
||||
"version": "1.0.0",
|
||||
"description": "BigQuery export serverless function",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node index.js",
|
||||
"dev": "LOCAL_DEV=falsetrue nodemon index.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@google-cloud/bigquery": "^6.0.0",
|
||||
"@google-cloud/storage": "^7.16.0",
|
||||
"axios": "^1.11.0",
|
||||
"dotenv": "^17.2.1",
|
||||
"express": "^4.21.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^3.1.10"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user