Getting started
Use Node.js 24.11 or newer. Create an ESM project and install the packages for an HTTP application:
npm init -y
npm pkg set type=module
npm install @heronjs/core@4.7.0 @heronjs/common@4.7.0 @heronjs/express@4.7.0 reflect-metadata
npm install --save-dev typescript @types/node knex mongodb cassandra-driverThe unified core declarations reference Knex, MongoDB, and Cassandra SDK types. The development dependencies above support strict declaration checking even for HTTP-only builds; importing core does not load those drivers or connect to databases. Keep the SDK for any backend you actually use in production dependencies. See Package entrypoints.
Usage
Create tsconfig.json:
{
"compilerOptions": {
"target": "ES2024",
"module": "NodeNext",
"types": ["node"],
"rootDir": "src",
"outDir": "dist",
"strict": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true
},
"include": ["src/**/*.ts"]
}Create src/main.ts:
import 'reflect-metadata';
import {Module} from '@heronjs/common';
import {HeronJS} from '@heronjs/core';
import {Get, Rest} from '@heronjs/express';
@Rest('/api')
class HelloController {
@Get({uri: '/hello'})
hello() {
return {message: 'Hello from HeronJS!'};
}
}
@Module({controllers: [HelloController]})
class AppModule {}
const app = await HeronJS.create({module: AppModule});
await app.listen({port: 3000, host: '127.0.0.1'});Build and start the application:
npx tsc
node dist/main.jsVisit http://127.0.0.1:3000/api/hello to receive the JSON response. app.listen() initializes the application and starts the HTTP server. Use app.start() for applications that do not need an HTTP listener, and await app.close() to shut down.