A lightweight serverless function platform for Node.js, allowing you to upload, manage, and schedule JavaScript and TypeScript functions through a clean web interface.
- 📦 Upload JavaScript (.js) and TypeScript (.ts) functions through a web UI
- 🔄 Automatic TypeScript compilation
- 💻 Execute functions via HTTP POST requests
- ⏱️ Schedule functions using cron expressions
- 🔒 Simple authentication
- 🛡️ Sandboxed function execution environment
- Node.js (v14+ recommended)
- npm or yarn
- Git
- Clone the repository
git clone https://github.com/yourusername/serverless.git
cd serverless- Install dependencies
npm install- Configure environment variables
Copy the .env.example file to .env and adjust the values as needed:
cp .env.example .envOr create a new .env file with the following variables:
PORT=3000
JWT_SECRET=your_jwt_secret_key_here
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin
NODE_ENV=development
- Build the project
npm run build- Start the server
npm startThe server will be available at http://localhost:3000 (or the port you specified in the .env file).
For development with hot reloading:
npm run dev- Access the web interface at http://localhost:3000
- Log in with the credentials set in your
.envfile (default: admin/admin)
- Navigate to the "Upload" page
- Upload a JavaScript (.js) or TypeScript (.ts) file
- The function will be processed and compiled if needed
Functions should export a function that takes an input object and returns a result:
// example.js
module.exports = function(input) {
// Process input
console.log('Input received:', input);
// Return result (can also return a Promise)
return {
message: 'Hello from serverless function!',
timestamp: new Date().toISOString(),
input: input
};
};Or using TypeScript:
// example.ts
interface Input {
name?: string;
[key: string]: any;
}
interface Output {
message: string;
timestamp: string;
input: Input;
}
export default function(input: Input): Output {
return {
message: `Hello, ${input.name || 'world'}!`,
timestamp: new Date().toISOString(),
input
};
}- Navigate to the "Functions" page
- Click "Execute" on the function you want to run
- Enter the input JSON if needed and click "Execute Function"
- View the output
- Navigate to the "Schedules" page
- Click "New Schedule"
- Select a function, enter a cron expression, and provide optional settings
- Click "Create Schedule"
- Use the "Activate" or "Deactivate" buttons to toggle schedule status
- Delete schedules with the "Delete" button
The platform provides the following API endpoints:
-
Authentication
POST /api/auth/login- Login with username and passwordPOST /api/auth/logout- Logout current userGET /api/auth/status- Check authentication status
-
Functions
GET /api/functions- List all functionsPOST /api/functions/upload- Upload a new functionDELETE /api/functions/:name- Delete a functionPOST /api/functions/:name/execute- Execute a function
-
Schedules
GET /api/schedules- List all schedulesPOST /api/schedules- Create a new schedulePATCH /api/schedules/:id- Update a scheduleDELETE /api/schedules/:id- Delete a schedulePOST /api/schedules/:id/activate- Activate a schedulePOST /api/schedules/:id/deactivate- Deactivate a schedule
MIT