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
28 changes: 16 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hsl-routemap-server",
"version": "1.2.1",
"version": "1.2.2",
"description": "HSL Routemap server",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -36,7 +36,7 @@
},
"homepage": "https://github.com/HSLdevcom/hsl-routemap-server#readme",
"engines": {
"node": ">=8.0.0"
"node": ">=20.0.0"
},
"devDependencies": {
"@babel/core": "^7.22.6",
Expand Down Expand Up @@ -66,14 +66,13 @@
"react-hot-loader": "^4.13.1",
"rimraf": "^2.6.2",
"style-loader": "~2",
"webpack": "~4",
"webpack-cli": "~4",
"webpack-dev-server": "~3",
"webpack": "~5",
"webpack-cli": "~5",
"webpack-dev-server": "~5",
"worker-loader": "^3.0.8"
},
"dependencies": {
"@azure/storage-blob": "^10.5.0",
"@koa/cors": "^2.2.1",
"apollo-cache-inmemory": "^1.1.1",
"apollo-client": "^2.0.3",
"apollo-link-http": "^1.2.0",
Expand All @@ -86,24 +85,29 @@
"hsl-map-style": "hsldevcom/hsl-map-style#master",
"ioredis": "^5.0.6",
"knex": "^2.1.0",
"koa": "^2.4.1",
"koa": "^2.16.4",
"koa-json-body": "^5.3.0",
"koa-router": "7.3.0",
"koa-session": "^5.10.1",
"lodash": "^4.17.4",
"node-fetch": "^1.7.3",
"nodemon": "^1.12.1",
"node-fetch": "^2.6.7",
"nodemon": "^3.1.14",
"pg": "^8.7.3",
"pm2": "^6.0.14",
"prop-types": "^15.6.0",
"puppeteer": "^15.4.1",
"puppeteer": "^24.39.1",
"react": "18.2.0",
"react-apollo": "^2.0.1",
"react-dom": "18.2.0",
"recompose": "^0.30.0",
"segseg": "^0.2.2",
"serve": "^13.0.2",
"serve": "^14.2.6",
"uuid": "^3.1.0",
"validator": "^13.15.0",
"validator": "^13.15.22",
"viewport-mercator-project": "^4.1.1"
},
"resolutions": {
"node-fetch": "2.6.7",
"flatted": "3.4.1"
}
}
51 changes: 45 additions & 6 deletions scripts/server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const Koa = require('koa');
const Router = require('koa-router');
const session = require('koa-session');
const cors = require('@koa/cors');
const jsonBody = require('koa-json-body');
const { get } = require('lodash');
const { Queue } = require('bullmq');
Expand Down Expand Up @@ -41,6 +40,49 @@ const queue = new Queue('generator', { connection: bullRedisConnection });

const cancelSignalRedis = new Redis(REDIS_CONNECTION_STRING); // New connection to make sure that pub/sub will work correctly.

const createCorsMiddleware = (options = {}) => {
const {
allowHeaders = [
'Accept',
'Accept-Language',
'Content-Language',
'Content-Type',
'Authorization',
'X-Requested-With',
],
allowMethods = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
credentials = false,
} = options;

return async (ctx, next) => {
const requestOrigin = ctx.get('Origin');
if (requestOrigin) {
ctx.set('Access-Control-Allow-Origin', requestOrigin);
} else if (!credentials) {
ctx.set('Access-Control-Allow-Origin', '*');
}

if (credentials) {
ctx.set('Access-Control-Allow-Credentials', 'true');
}

ctx.set('Access-Control-Allow-Methods', allowMethods.join(', '));
const requestedHeaders = ctx.get('Access-Control-Request-Headers');
if (requestedHeaders) {
ctx.set('Access-Control-Allow-Headers', requestedHeaders);
} else {
ctx.set('Access-Control-Allow-Headers', allowHeaders.join(', '));
}

if (ctx.method === 'OPTIONS') {
ctx.status = 204;
return;
}

await next();
};
};

async function generatePoster(buildId, props) {
const { id } = await addPoster({ buildId, props });

Expand Down Expand Up @@ -284,6 +326,7 @@ async function main() {

router.post('/login', async (ctx) => {
const authResponse = await authEndpoints.authorize(ctx.request, ctx.response, ctx.session);
console.log(JSON.stringify(authResponse.body));
ctx.session = null;
if (authResponse.modifiedSession) {
ctx.session = authResponse.modifiedSession;
Expand Down Expand Up @@ -324,11 +367,7 @@ async function main() {
app
.use(errorHandler)
.use(unAuthorizedRouter.routes())
.use(
cors({
credentials: true,
}),
)
.use(createCorsMiddleware({ credentials: true }))
.use(authMiddleware)
.use(jsonBody({ fallback: true, limit: '10mb' }))
.use(router.routes())
Expand Down
11 changes: 3 additions & 8 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,15 @@ config.devtool = 'eval';
config.mode = 'development';

if (process.env.HMR === 'true') {
config.entry = [
`webpack-dev-server/client?http://localhost:${PORT}`,
'webpack/hot/dev-server',
...config.entry,
];
config.plugins = [new webpack.HotModuleReplacementPlugin(), ...config.plugins];
}

const options = {
hot: process.env.HMR === 'true',
historyApiFallback: true,
stats: { colors: true },
port: PORT,
};

const server = new WebpackDevServer(webpack(config), options);
const server = new WebpackDevServer(options, webpack(config));

server.listen(PORT);
server.start();
3 changes: 3 additions & 0 deletions src/components/routeMap/routeMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import AZone from 'icons/icon-Zone-A';
import BZone from 'icons/icon-Zone-B';
import CZone from 'icons/icon-Zone-C';
import DZone from 'icons/icon-Zone-D';
import EZone from 'icons/icon-Zone-E';

import { preventFromOverlap } from '../../util/terminals';
import { getTransformedCoord } from '../../util/arrows';
Expand Down Expand Up @@ -43,6 +44,8 @@ const getZoneIcon = (zone, size) => {
return <CZone size={size} />;
case 'D':
return <DZone size={size} />;
case 'E':
return <EZone size={size} />;
default:
return <div />;
}
Expand Down
39 changes: 39 additions & 0 deletions src/icons/icon-Zone-E.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import PropTypes from 'prop-types';
import React from 'react';

const EZone = (props) => (
<div>
<svg
width={props.size}
height={props.size}
viewBox="0 0 36 36"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
>
<title>icon-Zone-E</title>
<desc>Created with Sketch.</desc>
<defs />
<g id="Page-1" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
<g id="icon-Zone-E">
<path
d="M36,18.00096 C36,27.94176 27.9408,36.00096 18,36.00096 C8.0592,36.00096 0,27.94176 0,18.00096 C0,8.05776 8.0592,0.00096 18,0.00096 C27.9408,0.00096 36,8.05776 36,18.00096"
id="Fill-1"
fill="#007AC9"
/>
<path
d="M9.94704,8.85792 C9.94704,7.78992 10.77024,6.96672 11.83584,6.96672 L17.90304,6.96672 C24.60864,6.96672 29.24064,11.56992 29.24064,17.57472 L29.24064,17.63472 C29.24064,23.63952 24.60864,28.30512 17.90304,28.30512 L11.83584,28.30512 C10.77024,28.30512 9.94704,27.48192 9.94704,26.41152 L9.94704,8.85792 Z M17.90304,24.88992 C22.38384,24.88992 25.30944,21.87312 25.30944,17.69712 L25.30944,17.63472 C25.30944,13.45872 22.38384,10.38192 17.90304,10.38192 L13.69584,10.38192 L13.69584,24.88992 L17.90304,24.88992 Z"
id="Fill-4"
fill="#FFFFFF"
/>
</g>
</g>
</svg>
</div>
);

EZone.propTypes = {
size: PropTypes.string.isRequired,
};

export default EZone;
Loading
Loading