Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions developer/src/server/src/environment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
/*
* Keyman is copyright (C) SIL Global. MIT License.
*
* Environmental variables and paths
*/
import path from 'node:path';
import { extractVersionData } from './version-data.js';
// TODO: environment should be just KEYMAN_VERSION

import KEYMAN_VERSION from "@keymanapp/keyman-version";
export const environment = extractVersionData(KEYMAN_VERSION.VERSION_WITH_TAG);

/**
* @returns base path for the running server -- where index.js is stored
*/
export function serverBasePath() {
return path.join(import.meta.dirname, '../../build/src');
}

/**
* @returns path where the site public files can be found -- index.html
*/
export function serverSitePath() {
return path.join(serverBasePath(), 'site');
}
8 changes: 7 additions & 1 deletion developer/src/server/src/routes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Keyman is copyright (C) SIL Global. MIT License.
*
* Setup URL routes for Keyman Developer Server
*/
import * as express from 'express';
import * as ws from 'ws';
import * as multer from 'multer';
Expand All @@ -16,6 +21,7 @@ import { standardPaths } from './standardPaths.js';
import chalk from 'chalk';
import { shutdown } from './shutdown.js';
import { getOption } from './options.js';
import { serverSitePath } from './environment.js';

export default function setupRoutes(app: express.Express, upload: multer.Multer, wsServer: ws.WebSocketServer, environment: Environment ) {

Expand Down Expand Up @@ -51,7 +57,7 @@ export default function setupRoutes(app: express.Express, upload: multer.Multer,

/* All routes */

app.use('/', express.static('build/src/site'));
app.use('/', express.static(serverSitePath()));

app.post('/upload', localhostOnly, upload.single('file'), (req, res, next) => {
const name = req.file.originalname;
Expand Down