Easy App Work in Progress!
Quick Start
import {EasyApp} from "@vef/easy-app";
const app = new EasyApp();
app.run();
Now you can visit http://localhost:8000 to see your app in action.
Configuration
The EasyApp
class takes an optional configuration object.
Property | Type | Description |
---|---|---|
appRootPath | string | The root path of the app. Defaults to the current directory. |
singlePageApp | boolean | Set to true if the app is a single page app (SPA) that has a single entry point. |
staticFilesOptions | StaticFilesOptions | Options for the static files handler. |
serverOptions | Deno.ListenOptions | Options for the Deno server. |
orm | Orm | An instance of EasyOrm to use for the app. |
appRootPath
Type: string
The root path of the app. Defaults to the current directory.
This is used to serve static files and to store the database file for the ORM when using the default database type {json}.
Note
This path should be an absolute path. Use the forward slash /
as the path separator even on Windows.
The app will handle the path correctly.
Example:
const app = new EasyApp({
appRootPath: "/path/to/app/root",
});
singlePageApp
Type: boolean
Set to true if the app is a single page app (SPA) that has a single entry point. This will serve the index.html file for all requests that are not files.
Example:
const app = new EasyApp({
singlePageApp: true,
});
staticFilesOptions
Type: StaticFilesOptions
Options for the static files handler
cache
- Whether to cache files or not. Default: true
staticFilesRoot
- The root directory of the static files. Default: public
in the app root path. This should be an absolute path.
Example:
const app = new EasyApp({
staticFilesOptions: {
cache: false,
staticFilesRoot: "/path/to/static/files",
},
});
serverOptions
Type: Deno.ListenOptions
Options for the Deno server
port
- The port to run the server on. Default: 8000
hostname
- The hostname to run the server on. Defaults to 0.0.0.0
Example:
const app = new EasyApp({
serverOptions: {
port: 8080,
hostname: "localhost",
},
});
orm
Type: EasyOrm
An instance of EasyOrm to use for the app. If not provided, a new instance of EasyOrm will be created with the default options for the database type {json}
.
Check out the EasyOrm documentation for more information about the EasyOrm class.
Example:
const app = new EasyApp({
orm: new EasyOrm({
databaseType: "postgres",
databaseConfig: {
host: "localhost",
port: 5432,
user: "user",
password: "password",
database: "mydb",
},
entities: [],
}),
});