0.7.0 β€’ Published 8 months ago

@aircodelabs/hydrogen v0.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Hydrogen

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

0.7.0

8 months ago

0.6.0

8 months ago

0.5.1

9 months ago

0.5.0

9 months ago

0.4.1

9 months ago

0.4.0

9 months ago

0.3.1

9 months ago

0.3.0

9 months ago

0.2.3

9 months ago

0.2.2

9 months ago

0.2.1

9 months ago

0.2.0

9 months ago

0.1.1

10 months ago

0.1.0

10 months ago