This commit is contained in:
monoid 2023-06-01 11:09:00 +09:00
parent f24c0d2078
commit 65192c6c72
4 changed files with 577 additions and 217 deletions

View File

@ -4,23 +4,23 @@ Content File Management Program.
For study about nodejs, typescript and react.
### deployment
```
$ npm run app:build
```bash
pnpm run app:build
```
### test
```
$ npm run app
```bash
$ pnpm run app
```
### server build
```
$ npm run compile
```bash
$ pnpm run compile
```
### client build
```
$ npm run build
```bash
$ pnpm run build
```
## License

View File

@ -6,8 +6,8 @@
"scripts": {
"compile": "tsc",
"compile:watch": "tsc -w",
"build": "cd src/client && npm run build:prod",
"build:watch": "cd src/client && npm run build:watch",
"build": "cd src/client && pnpm run build:prod",
"build:watch": "cd src/client && pnpm run build:watch",
"app": "electron build/app.js",
"app:build": "electron-builder",
"app:pack": "electron-builder --dir",

File diff suppressed because it is too large Load Diff

View File

@ -63,27 +63,33 @@ class ServerApplication{
let diff_router = createDiffRouter(this.diffManger);
this.diffManger.register("comic",createComicWatcher());
console.log("setup router");
let router = new Router();
router.use("/api/*", async (ctx,next)=>{
router.use("/api/(.*)", async (ctx,next)=>{
//For CORS
ctx.res.setHeader("access-control-allow-origin", "*");
await next();
});
router.use('/api/diff',diff_router.routes());
router.use('/api/diff',diff_router.allowedMethods());
const content_router = getContentRouter(this.documentController);
router.use('/api/doc',content_router.routes());
router.use('/api/doc',content_router.allowedMethods());
const tags_router = getTagRounter(this.tagController);
router.use("/api/tags",tags_router.allowedMethods());
router.use("/api/tags",tags_router.routes());
this.serve_with_meta_index(router);
this.serve_index(router);
this.serve_static_file(router);
const content_router = getContentRouter(this.documentController);
router.use('/api/doc',content_router.routes());
router.use('/api/doc',content_router.allowedMethods());
const tags_router = getTagRounter(this.tagController);
router.use("/api/tags",tags_router.allowedMethods());
router.use("/api/tags",tags_router.routes());
const login_router = createLoginRouter(this.userController);
router.use('/user',login_router.routes());
@ -102,6 +108,7 @@ class ServerApplication{
});}
app.use(router.routes());
app.use(router.allowedMethods());
console.log("setup done");
}
private serve_index(router:Router){
const serveindex = (url:string)=>{
@ -204,8 +211,8 @@ class ServerApplication{
}
start_server(){
let setting = get_setting();
console.log("start server");
//todo : support https
console.log(`listen on http://${setting.localmode ? "localhost" : "0.0.0.0"}:${setting.port}`);
return this.app.listen(setting.port,setting.localmode ? "127.0.0.1" : "0.0.0.0");
}
static async createServer(){