Skip to content

The serverless framework creates web servers that can run anywhere.

License

Notifications You must be signed in to change notification settings

aircodelabs/Hydrogen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hydrogen

未标题-3

The serverless framework creates web servers that can run anywhere.

Features

  • 🐇 Rapid development with Hot Module Replacement (HMR) 🔥
  • 📦 Supports CommonJS (.js .cjs), ES modules (.mjs), and TypeScript (.ts) functions out of the box.
  • 🧸 Requires almost zero configurations.
  • 🗄️ Comes with a built-in, ready-to-use text database and file API.
  • 📁 Follows intuitive directory structure conventions.
  • 🤏 Written in Pure JavaScript with a sleek and minimalist design.
  • ⚡️ Optimized for runtime performance, regardless of development or production environments.
  • 🧊 Compatible and capable of running your app seamlessly on the AirCode platform.

Getting Started

  1. Create an aircode app
npx create-aircode-app@latest my-aircode-app && cd my-aircode-app
  1. Install dependencies and run
npm i && npm start

Directory Structure

The default project directory structure is very simple.

├──functions # put your function api here.
│  └── hello.js # http://localhost:3000/hello
├──public # put your static resources here.
│  └── favicon.ico # http://localhost:3000/public/favicon.ico
└── package.json

Build Cloud Functions

You can easily build your function api in ./functions directory.

  1. With *.js or *.cjs
// myfun.js
const aircode = require('aircode');

module.exports = async function(params, context) {
  console.log('Received params:', params);
  return {
    message: 'Hi, AirCode.'
  };
}
  1. Or with *.mjs
import aircode from 'aircode';

export default async function (params, context) {
  console.log('Received params:', params);
  return {
    message: 'Hi, AirCode.',
  };
};
  1. Or with *.ts
import aircode from 'aircode';

export default async function (params: any, context: any) {
  console.log('Received params:', params);
  return {
    message: 'Hi, AirCode.',
  };
};

Simply visit your built functions with http://localhost:3000/<your_func_name>.

And visit your static resources with http://localhost:3000/public/<your_static_file>.

Documentation

Configurations

There are a few options that you can pass through process.env.

process.env.AC_FAAS_ROOT = process.env.AC_FAAS_ROOT || 'functions';
process.env.AC_PUBLIC_DIR = process.env.AC_PUBLIC_DIR || 'public';
process.env.AC_PORT = process.env.AC_PORT || 3000;

Integration

Integration Hydrogen with AirCode online