|
|
|
@ -1,5 +1,5 @@ |
|
|
|
import { Auth } from "./auth" |
|
|
|
import { Frontend } from "./frontend" |
|
|
|
//import { Auth } from "./auth"
|
|
|
|
//import { Frontend } from "./frontend"
|
|
|
|
|
|
|
|
export class Server { |
|
|
|
async getEnv(variables) { |
|
|
|
@ -37,44 +37,46 @@ export class Server { |
|
|
|
} |
|
|
|
|
|
|
|
async init() { |
|
|
|
if (this.port === undefined) { |
|
|
|
await this.configure() |
|
|
|
} |
|
|
|
this.auth = new Auth() |
|
|
|
this.frontend = new Frontend({ |
|
|
|
appBaseUrl: this.giteaAppBaseUrl, |
|
|
|
apiBaseUrl: this.giteaApiBaseUrl, |
|
|
|
}) |
|
|
|
const promises = [] |
|
|
|
const repos = [ |
|
|
|
'loader', |
|
|
|
'editor', |
|
|
|
'forms', |
|
|
|
'menu', |
|
|
|
'settings', |
|
|
|
'dialog', |
|
|
|
'storage', |
|
|
|
'editor-lib-codemirror', |
|
|
|
] |
|
|
|
for (const repo of repos) { |
|
|
|
promises.push(server.frontend.loadRepo( |
|
|
|
await Promise.all([ |
|
|
|
...([ |
|
|
|
'loader', |
|
|
|
'editor', |
|
|
|
'forms', |
|
|
|
'menu', |
|
|
|
'settings', |
|
|
|
'dialog', |
|
|
|
'storage', |
|
|
|
'editor-lib-codemirror', |
|
|
|
].map(repo => ( |
|
|
|
server.frontend.loadRepo( |
|
|
|
'macchiato', |
|
|
|
repo, |
|
|
|
{srcPath: [], destPath: [repo]} |
|
|
|
) |
|
|
|
))), |
|
|
|
server.frontend.loadRepo( |
|
|
|
'macchiato', |
|
|
|
repo, |
|
|
|
{srcPath: [], destPath: [repo]} |
|
|
|
)) |
|
|
|
} |
|
|
|
promises.push(server.frontend.loadRepo( |
|
|
|
'macchiato', |
|
|
|
'pages', |
|
|
|
{srcPath: [], destPath: []} |
|
|
|
)) |
|
|
|
promises.push(server.frontend.loadRepo( |
|
|
|
'macchiato', |
|
|
|
'server', |
|
|
|
{ |
|
|
|
srcPath: [], |
|
|
|
destPath: ['server'], |
|
|
|
ref: 'shared-server' |
|
|
|
} |
|
|
|
)) |
|
|
|
await Promise.all(promises) |
|
|
|
'pages', |
|
|
|
{srcPath: [], destPath: []} |
|
|
|
), |
|
|
|
server.frontend.loadRepo( |
|
|
|
'macchiato', |
|
|
|
'server', |
|
|
|
{ |
|
|
|
srcPath: [], |
|
|
|
destPath: ['server'], |
|
|
|
ref: 'shared-server' |
|
|
|
} |
|
|
|
), |
|
|
|
]) |
|
|
|
this.frontend.files['/app.js'] = ( |
|
|
|
this.frontend.files['/server/app.js'] |
|
|
|
) |
|
|
|
@ -110,8 +112,9 @@ export class Server { |
|
|
|
} |
|
|
|
|
|
|
|
async serve() { |
|
|
|
await this.configure() |
|
|
|
await this.init() |
|
|
|
if (!this.server) { |
|
|
|
await this.init() |
|
|
|
} |
|
|
|
this.server = Deno.listen({ |
|
|
|
port: this.port, |
|
|
|
}) |
|
|
|
@ -119,10 +122,4 @@ export class Server { |
|
|
|
this.serveConn(conn) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async run() { |
|
|
|
await this.configure() |
|
|
|
await this.init() |
|
|
|
await this.serve() |
|
|
|
} |
|
|
|
} |