Skip to content

Commit 01ec1a9

Browse files
author
uid10804
committed
feat(server): add example to start the library directly
1 parent b1b5414 commit 01ec1a9

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

packages/server/example/db.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"posts": [
3+
{ "id": 1, "title": "json-server", "author": "typicode" },
4+
{ "id": 2, "title": "test", "author": "yourAuthor" }
5+
],
6+
"comments": [
7+
{ "id": 1, "body": "some comment", "postId": 1 }
8+
],
9+
"profile": { "name": "typicode" }
10+
}

packages/server/example/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { ServerFactory, AppConfig } from '../src/index';
2+
import express from 'express';
3+
4+
const server = express();
5+
const defaultConfig = new AppConfig();
6+
defaultConfig.readOnly = false;
7+
defaultConfig.jsonFile = 'db.json';
8+
defaultConfig.enableSwagger = true;
9+
10+
const start = async () => {
11+
// do something
12+
await ServerFactory.createServer(
13+
'local',
14+
server,
15+
defaultConfig,
16+
'../package.json'
17+
);
18+
};
19+
20+
start();

0 commit comments

Comments
 (0)