Repository navigation
Expand file tree
/
Copy pathapp.ts
More file actions
37 lines (35 loc) · 1.81 KB
/
Copy pathapp.ts
File metadata and controls
37 lines (35 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import "reflect-metadata";
import "./__generated__/nonna-dependencies.generated";
import {NodeBoot, NodeBootApp, NodeBootApplication, NodeBootAppView} from "@nodeboot/core";
import {EnableAuthorization} from "@nodeboot/authorization";
import {EnableValidations} from "@nodeboot/starter-validation";
import {EncoreServer} from "@nodeboot/encore-server";
import {LoggedInUserResolver} from "./auth/LoggedInUserResolver";
import {DefaultAuthorizationResolver} from "./auth/DefaultAuthorizationResolver";
// Beans are imported here for their side effects (decorator registration) instead of relying on
// `@EnableComponentScan`. Component scanning reads compiled files from `dist/` at runtime
// (`fs.readdirSync`), which doesn't match how Encore.ts bundles and runs the application.
// Explicit imports keep this sample's dependency graph statically discoverable, which also plays
// nicely with Encore.ts's own static analysis of the source tree.
import "./controllers/hello.controller";
import "./controllers/users.controller";
import "./services/users.service";
import "./middlewares/LoggingMiddleware";
import "./middlewares/ErrorMiddleware";
import {appConfig} from "./app-config";
/**
* Node-Boot application entry point.
*
* Notice that, unlike the Express/Koa/Fastify samples, this application does not "listen" on a
* port. Instead, `EncoreServer` boots Node-Boot's engine (controllers, DI, middleware,
* authorization, validation) against an internal router and exposes a handler function that is
* wired up as a single Encore.ts raw endpoint. See `api/index.ts`.
*/
@EnableAuthorization(LoggedInUserResolver, DefaultAuthorizationResolver)
@EnableValidations()
@NodeBootApplication()
export class EncoreSampleApp implements NodeBootApp {
start(): Promise<NodeBootAppView> {
return NodeBoot.run(EncoreServer, appConfig);
}
}