Core framework package for EreoJS providing the application container, request context, plugin system, caching, environment variables, and type definitions.
npm install @ereo/coreCore framework package for EreoJS providing the application container, request context, plugin system, caching, environment variables, and type definitions.
``bash`
bun add @ereo/core
`typescript
import { createApp, defineConfig, definePlugin } from '@ereo/core';
// Create application with configuration
const app = createApp({
config: defineConfig({
server: {
port: 3000,
hostname: 'localhost',
},
}),
});
// Define a custom plugin
const analyticsPlugin = definePlugin({
name: 'analytics',
setup(context) {
console.log('Analytics initialized in', context.mode, 'mode');
},
});
// Register the plugin
app.use(analyticsPlugin);
// Start the server
await app.start();
`
- Application Container - Create and configure EreoJS applications with createApp and defineConfigcreateContext
- Request Context - Access request-scoped data with , getContext, and attachContextdefinePlugin
- Plugin System - Extend functionality with and composePluginsenv.string()
- Environment Variables - Type-safe env management with schema builders (, env.number(), etc.)createCache
- Unified Cache Interface - Flexible caching with , createTaggedCache, and tag-based invalidation
- Full TypeScript Support - Comprehensive type definitions for routes, loaders, actions, middleware, and more
`typescript
import { env, setupEnv, typedEnv } from '@ereo/core';
// Define environment schema
const envSchema = {
DATABASE_URL: env.string().required(),
PORT: env.port().default(3000),
DEBUG: env.boolean().default(false),
NODE_ENV: env.enum(['development', 'production', 'test']).default('development'),
};
// Validate and load environment
const result = await setupEnv('.', envSchema, 'development');
if (result.valid) {
// Access typed environment variables
const port = typedEnv.PORT; // number
}
`
`typescript
import { createTaggedCache } from '@ereo/core';
const cache = createTaggedCache({ maxSize: 1000 });
// Set with tags for grouped invalidation
await cache.set('user:123', userData, {
ttl: 3600,
tags: ['users', 'user:123']
});
// Invalidate all entries with a tag
await cache.invalidateTag('users');
``
For full documentation, visit https://ereojs.dev/docs/core
This package is part of the EreoJS monorepo - a modern full-stack framework built for Bun.
MIT