Skip to content

Commit d1073ba

Browse files
author
GeunWoo Kim
committed
Change the way how the engine sign matched transactions
1 parent 695ab05 commit d1073ba

File tree

5 files changed

+1066
-1120
lines changed

5 files changed

+1066
-1120
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,22 @@ Decentralized exchange platform for an asset on the CodeChain
1111
# cp codechain-exchange
1212
```
1313

14-
### Prerequisites
14+
## Prerequisites
1515

1616
```
1717
# yarn install
18-
# yarn migration
1918
# sudo service postgresql start
19+
# yarn migration
2020
```
2121

22+
### Account setting
23+
#### Development mode
24+
Matched transactions are signed by secret. You don't actually need to do nothing
25+
#### Test mode
26+
Matched transactions are singed by secret. You need to add platform and its secret into the `/server/config/dex.json`
27+
#### Production mode
28+
Matched transactions are signed with the local keystore `/server/config/keystore.db`. The local keystore should store only one key.
29+
2230
## Start server
2331

2432
```

app.ts

Lines changed: 52 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,52 @@
1-
import * as bodyParser from "body-parser";
2-
import * as express from "express";
3-
import * as logger from "morgan";
4-
import * as path from "path";
5-
import rfs from "rotating-file-stream";
6-
import route from "./server/routes";
7-
// import * as swaggerDocument from "./server/swagger.json"
8-
9-
export const env: string = process.env.NODE_ENV || "development";
10-
export const rpcServer: string = require(`${__dirname}/server/config/dex.json`).node[
11-
env
12-
].rpc;
13-
14-
// Set up the express app
15-
const app = express();
16-
17-
// Log requests to the console.
18-
app.use(logger("dev"));
19-
20-
// create a rotating write stream
21-
const accessLogStream = rfs("access.log", {
22-
interval: "1d", // rotate daily
23-
path: path.join(__dirname, "log")
24-
});
25-
26-
// setup the logger
27-
app.use(logger("combined", { stream: accessLogStream }));
28-
29-
// Parse incoming requests data (https://github.com/expressjs/body-parser)
30-
app.use(bodyParser.json());
31-
app.use(bodyParser.urlencoded({ extended: false }));
32-
33-
const cors = require("cors");
34-
app.use(cors());
35-
// Setup a default catch-all route that sends back a welcome message in JSON format.
36-
route(app);
37-
38-
const swaggerJsdoc = require('swagger-jsdoc');
39-
40-
const options = {
41-
swaggerDefinition: {
42-
info: {
43-
title: 'Test API',
44-
version: '1.0.0',
45-
description: 'Test Express API with autogenerated swagger doc',
46-
},
47-
},
48-
// List of files to be processes. You can also set globs './routes/*.ts'
49-
apis: ['./server/routes/order.ts', './server/routes/deal.ts', './server/routes/index.ts'],
50-
};
51-
52-
const specs = swaggerJsdoc(options);
53-
54-
55-
const swaggerUi = require('swagger-ui-express');
56-
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));
57-
58-
export default app;
1+
import * as bodyParser from "body-parser";
2+
import * as express from "express";
3+
import * as logger from "morgan";
4+
import * as path from "path";
5+
import rfs from "rotating-file-stream";
6+
import route from "./server/routes";
7+
8+
// Set up the express app
9+
const app = express();
10+
11+
// Log requests to the console.
12+
app.use(logger("dev"));
13+
14+
// create a rotating write stream
15+
const accessLogStream = rfs("access.log", {
16+
interval: "1d", // rotate daily
17+
path: path.join(__dirname, "log")
18+
});
19+
20+
// setup the logger
21+
app.use(logger("combined", { stream: accessLogStream }));
22+
23+
// Parse incoming requests data (https://github.com/expressjs/body-parser)
24+
app.use(bodyParser.json());
25+
app.use(bodyParser.urlencoded({ extended: false }));
26+
27+
const cors = require("cors");
28+
app.use(cors());
29+
// Setup a default catch-all route that sends back a welcome message in JSON format.
30+
route(app);
31+
32+
const swaggerJsdoc = require('swagger-jsdoc');
33+
34+
const options = {
35+
swaggerDefinition: {
36+
info: {
37+
title: 'CodeChain-Exchange API',
38+
version: '1.0.0',
39+
description: 'CodeChain-Exchange Express API with autogenerated swagger doc',
40+
},
41+
},
42+
// List of files to be processes. You can also set globs './routes/*.ts'
43+
apis: ['./server/routes/order.ts', './server/routes/deal.ts', './server/routes/index.ts'],
44+
};
45+
46+
const specs = swaggerJsdoc(options);
47+
48+
49+
const swaggerUi = require('swagger-ui-express');
50+
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));
51+
52+
export default app;

0 commit comments

Comments
 (0)