Documentation / @andrew_l/app / defineApp
Function: defineApp() ​
defineApp<
P,S,M>(definition):AppDefinition<P,S,M>
Define an application with typed props and lifecycle hooks.
When executed directly (node app.ts), the CLI is launched automatically.
Type Parameters ​
P ​
P extends ObjectPropsOptions<Data>
S ​
S extends Record<string, any>
M ​
M extends Record<string, AnyFunction>
Parameters ​
definition ​
AppDefinition<P, S, M>
Returns ​
AppDefinition<P, S, M>
Example ​
ts
export default defineApp({
name: 'server',
props: {
port: { type: Number, default: () => 3000 },
},
setup() {
return { server: createServer() };
},
async entry(props) {
await this.server.listen(props.port);
},
async stop() {
await this.server.close();
},
});