Products
Products
Video Hosting
Upload and manage your videos in a centralized video library.
Image Hosting
Upload and manage all your images in a centralized library.
Galleries
Choose from 100+templates to showcase your media in style.
Video Messaging
Record, and send personalized video messages.
CincoTube
Create your own community video hub your team, students or fans.
Pages
Create dedicated webpages to share your videos and images.
Live
Create dedicated webpages to share your videos and images.
For Developers
Video API
Build a unique video experience.
DeepUploader
Collect and store user content from anywhere with our file uploader.
Solutions
Solutions
Enterprise
Supercharge your business with secure, internal communication.
Townhall
Webinars
Team Collaboration
Learning & Development
Creative Professionals
Get creative with a built in-suite of editing and marketing tools.
eCommerce
Boost sales with interactive video and easy-embedding.
Townhall
Webinars
Team Collaboration
Learning & Development
eLearning & Training
Host and share course materials in a centralized portal.
Sales & Marketing
Attract, engage and convert with interactive tools and analytics.
"Cincopa helped my Enterprise organization collaborate better through video."
Book a Demo
Resources
Resources
Blog
Learn about the latest industry trends, tips & tricks.
Help Centre
Get access to help articles FAQs, and all things Cincopa.
Partners
Check out our valued list of partners.
Product Updates
Stay up-to-date with our latest greatest features.
Ebooks, Guides & More
Customer Stories
Hear how we've helped businesses succeed.
Boost Campaign Performance Through Video
Discover how to boost your next campaign by using video.
Download Now
Pricing
Watch a Demo
Demo
Login
Start Free Trial
Serverless architecture is a method where code runs in small, event-triggered functions instead of long-running servers. These functions start only when needed and shut down after completing the task. This allows applications to scale automatically and reduces infrastructure management. Developers only write the logic, and the cloud provider handles execution, uptime, and scaling. Node.js is well-suited for this as it runs lightweight and asynchronous tasks. In serverless environments, it performs well for APIs, file processing, and background jobs. What Serverless Architecture Means for Node.js In a serverless setup, your app is broken into small functions. Each function does a specific thing and runs when needed. For example, you might have a function that handles user login, another that processes uploaded images, and another that sends emails. Server management tasks such as uptime monitoring, memory allocation, and scaling are handled by the cloud provider. That’s handled by the cloud provider. You write your function using Node.js, and it runs whenever it’s triggered. This works well with Node.js as it’s good at handling tasks that happen at the same time (like web requests) without waiting for one task to finish before starting another. That’s exactly what’s needed in a system that runs short and quick tasks on demand. Basic Serverless Function in Node.js A serverless function in Node.js is a small piece of code triggered by events like HTTP requests. It runs in isolation, handles a single task, and returns a response. This keeps the logic simple and easy to manage. exports.handler = async (event) => { return { statusCode: 200, body: JSON.stringify({ message: 'Hello from serverless Node.js!' }), }; }; Explanation : exports.handler is the function the cloud will run when the event happens. event contains details about the trigger, like an HTTP request. statusCode is the response code for the request (200 means OK). body is the message sent back, turned into a string format. Deploying Node.js Functions to the Cloud After writing a function, it must be deployed to a cloud platform to make it usable. Configuration files define how the function should run and what should trigger it. This setup allows the cloud to handle the execution automatically. Example of a Configuration File (called serverless.yml) : Deploying this Function to AWS service: hello-node provider: name: aws runtime: nodejs18.x functions: hello: handler: handler.handler events: - http: path: hello method: get Explanation : service : The name of your serverless service/project. provider.runtime : Specifies the Node.js version the function runs on. functions.hello.handler : Points to the exported handler in your code file ( handler.js ). events.http : Defines an HTTP GET event that triggers the function at the /hello path. Processing Video Files Using Serverless Functions When a user uploads a video to cloud storage (such as Amazon S3 ), a function can be triggered to convert the video format, extract metadata, or generate thumbnails. Each of these steps can be performed by a separate function to keep the logic modular and manageable. Node.js supports libraries like fluent-ffmpeg for working with video files in serverless environments. These functions can run independently and handle tasks in parallel, such as encoding a video into multiple resolutions or uploading a processed result to another bucket or database. Example : const AWS = require('aws-sdk'); const ffmpeg = require('fluent-ffmpeg'); const fs = require('fs'); const s3 = new AWS.S3(); exports.handler = async (event) => { const bucket = event.Records[0].s3.bucket.name; const key = event.Records[0].s3.object.key; const inputFile = `/tmp/${key}`; const outputFile = `/tmp/processed-${key}`; const params = { Bucket: bucket, Key: key }; const file = fs.createWriteStream(inputFile); // Download file from S3 await new Promise((resolve, reject) => { s3.getObject(params).createReadStream() .pipe(file) .on('finish', resolve) .on('error', reject); }); // Process video using ffmpeg await new Promise((resolve, reject) => { ffmpeg(inputFile) .output(outputFile) .size('640x360') .on('end', resolve) .on('error', reject) .run(); }); // Upload processed video back to S3 const processedData = fs.readFileSync(outputFile); await s3.putObject({ Bucket: bucket, Key: `processed/${key}`, Body: processedData, ContentType: 'video/mp4' }).promise(); return { statusCode: 200, body: JSON.stringify({ message: 'Video processed successfully' }) }; }; Explanation : ffmpeg : Used to resize or convert the video format. /tmp : Temporary file storage path available in serverless environments like AWS Lambda. s3.getObject() : Downloads the uploaded video file from the S3 bucket. s3.putObject() : Uploads the processed video back to S3 in a new path (e.g., processed/ ). This function triggers automatically when a new video is uploaded and processes it without needing a permanent server. How Serverless Node.js Handles Data Serverless functions do not keep memory between runs. They don’t remember what happened before. So, if your app needs to store or read data (like user information), you’ll need to connect it to a database. Here’s an example using AWS DynamoDB: const AWS = require('aws-sdk'); const dynamo = new AWS.DynamoDB.DocumentClient(); exports.handler = async (event) => { const params = { TableName: 'Users', Key: { userId: event.userId } }; try { const data = await dynamo.get(params).promise(); return { statusCode: 200, body: JSON.stringify(data.Item) }; } catch (error) { return { statusCode: 500, body: JSON.stringify({ error: 'Failed to fetch user' }), }; } }; Explanation : AWS.DynamoDB.DocumentClient() : AWS SDK client for interacting with DynamoDB in JavaScript-friendly format. params.TableName : The DynamoDB table to query. params.Key : The primary key used to retrieve the specific user item. Logging and Debugging Since serverless functions don’t run on your computer, you won’t see what’s going on unless you add logs. In Node.js, you can use console.log() to print messages, and those will appear in your cloud provider’s log system. Example : exports.handler = async (event) => { console.log('Received event:', JSON.stringify(event)); // Function logic here return { statusCode: 200, body: 'Done', }; }; Explanation : console.log : Prints data that you can later view in cloud logs (like AWS CloudWatch).