Skip to content

Commit 824619a

Browse files
author
Fuss Florian (uid10804)
committed
refactor(server): add simple and advanced example
1 parent 4e2fdd5 commit 824619a

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
File renamed without changes.

packages/server/example/simple.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import express from 'express';
2+
import {
3+
AppConfig,
4+
CoreApp,
5+
Environment,
6+
FileStorageAdapter,
7+
PublicStrategy,
8+
Swagger,
9+
SwaggerConfig,
10+
} from '../src/index';
11+
12+
const server = express();
13+
const appConfig = new AppConfig();
14+
const environment = new Environment();
15+
16+
const swagger = new Swagger(
17+
server,
18+
new SwaggerConfig(appConfig.readOnly, appConfig.enableApiKeyAuth),
19+
environment.basePath,
20+
appConfig.routes.apiRoutePath,
21+
'./package.json',
22+
appConfig.routes.swaggerSpecRoutePath
23+
);
24+
25+
let core = new CoreApp(
26+
appConfig,
27+
server,
28+
new FileStorageAdapter('db.json'),
29+
swagger,
30+
environment,
31+
new PublicStrategy()
32+
);
33+
34+
const init = async () => {
35+
await core!.setup();
36+
console.log(
37+
'JSON Server is running under port 3000. Use http://localhost:3000/ to access it'
38+
);
39+
server.listen(3000);
40+
};
41+
init();

0 commit comments

Comments
 (0)