Skip to content
Merged

Dev #132

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
40 changes: 14 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"docker:run": "docker run --name transitlog-server -p 4000:4000 hsldevcom/transitlog-server",
"start": "TS_NODE_FILES=true NODE_ICU_DATA=\\\"node_modules/full-icu\\\" ts-node-dev --max-old-space-size=4096 --no-notify --respawn --inspect -r dotenv/config --files src/server.ts",
"start:build": "TS_NODE_FILES=true NODE_ICU_DATA=\"node_modules/full-icu\" ts-node-dev --no-notify --respawn --inspect -r dotenv/config --files dist/server.js",
"start:production": "NODE_ICU_DATA=\"node_modules/full-icu\" forever stopall && forever start -f --spinSleepTime 1000 -c \"node -r dotenv/config\" dist/server.js && sleep 10 && forever logs -f 0",
"start:production": "NODE_ICU_DATA=\"node_modules/full-icu\" node -r dotenv/config dist/server.js",
"build": "tsc",
"codegen": "graphql-codegen --config codegen.yml",
"codestyle": "prettier \"src/**/*.{ts,js,json}\" --write",
"test": "node scripts/test.js",
"test:ci": "CI=true node scripts/test.js",
"test:staged": "CI=true node scripts/test.js --bail --findRelatedTests",
"test:staged": "CI=true node scripts/test.js --bail --findRelatedTests --passWithNoTests",
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,css,md}\"",
"format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json,css,md}\""
},
Expand Down Expand Up @@ -47,7 +47,6 @@
"apollo-server-errors": "^2.2.1",
"apollo-server-express": "^2.4.8",
"await-to-js": "^2.1.1",
"body-parser": "^1.18.3",
"boundingbox": "^1.2.0",
"chalk": "^4.1.1",
"connect-redis": "^3.4.1",
Expand All @@ -59,15 +58,14 @@
"express-rate-limit": "5.5.1",
"express-react-views": "^0.11.0",
"express-session": "^1.17.2",
"forever": "^0.15.3",
"fs-extra": "^8.0.1",
"full-icu": "^1.3.0",
"fuse.js": "^3.4.4",
"graphql": "^14.1.1",
"ioredis": "^4.16.0",
"isomorphic-fetch": "^2.2.1",
"knex": "^0.95.6",
"knex-postgis": "^0.13.0",
"knex-postgis": "^0.14.3",
"lodash": "^4.17.11",
"moment": "^2.24.0",
"moment-timezone": "^0.5.23",
Expand All @@ -77,44 +75,34 @@
"proper-url-join": "^2.0.1",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"ts-node": "^8.5.2",
"typescript": "4.2.4",
"ts-node": "^10",
"typescript": "^5.4",
"uuid": "^7.0.3",
"validator": "^13.15.20"
},
"devDependencies": {
"@graphql-codegen/cli": "^1.21.8",
"@graphql-codegen/import-types-preset": "1.8.3",
"@graphql-codegen/typescript": "1.8.3",
"@graphql-codegen/typescript-resolvers": "1.8.3",
"@types/express": "^4.17.12",
"@graphql-codegen/cli": "^5",
"@graphql-codegen/typescript": "^5",
"@graphql-codegen/typescript-resolvers": "^5",
"@types/express": "4.17.21",
"@types/express-serve-static-core": "4.17.43",
"@types/express-session": "^1.17.3",
"@types/graphql": "^14.0.7",
"@types/ioredis": "^4.0.9",
"@types/jest": "^24.0.11",
"@types/jest": "^30",
"@types/lodash": "^4.14.122",
"@types/node": "^14.17.1",
"@types/node": "^20",
"@types/validator": "^13.15.4",
"concurrently": "^4.1.0",
"husky": "^1.3.1",
"jest": "^24.3.1",
"jest-haste-map": "^24.5.0",
"jest-resolve": "^24.5.0",
"jest": "^30",
"lint-staged": "^9.0.0",
"nodemon": "^1.18.10",
"prettier": "^2.8.8",
"ts-jest": "^24.1.0",
"ts-jest": "^29",
"ts-node-dev": "^1.1.6",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.0.1"
},
"resolutions": {
"underscore": "^1.12.1",
"minimist": "^1.2.6",
"json-schema": "^0.4.0",
"@babel/traverse": "^7.23.2",
"form-data": "^4.0.4",
"sha.js": "^2.4.12"
}
}
3 changes: 2 additions & 1 deletion src/auth/authEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ const authorize = async (req: express.Request, res: express.Response) => {

if (req.session && accessToken) {
const expiresIn = get(tokenResponse, 'expires_in', 0)
const refreshToken = get(tokenResponse, 'refresh_token', 0)
const refreshToken = get(tokenResponse, 'refresh_token') as string | undefined

expiresAt = addSeconds(expiresAt, expiresIn).getTime() / 1000

req.session.accessToken = accessToken
Expand Down
2 changes: 1 addition & 1 deletion src/creators/createJourneyResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ export async function createJourneyResponse(
otherEvents: events = [],
} = journeyEvents

let journeyEquipment = null
let journeyEquipment: JoreEquipment | null = null
const ascVehiclePositions = orderBy(vehiclePositions, 'tsi', 'asc')

if (requireVehicleAuthorization(user, vehicleId) && ascVehiclePositions.length !== 0) {
Expand Down
5 changes: 3 additions & 2 deletions src/creators/createRouteGeometryResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ export async function createRouteGeometryResponse(
return false
}

const geometry = get(selectedRoute, 'geometry.coordinates', [])
type LonLat = [number, number]

const geometry = get(selectedRoute, 'geometry.coordinates', [] as LonLat[])

// Convert to lat/lng points
const coordinates = geometry.map(([lon, lat]) => ({
lat,
lng: lon,
Expand Down
16 changes: 8 additions & 8 deletions src/objects/createAlert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ export function createAlert(alert: DBAlert, language: string = 'fi'): Alert {
distribution = AlertDistribution.Stop
}

const titles = get(alertData, 'titles', [])
const title = titles.find((title) => title.language === alertLanguage) || titles[0]
type LocalizedText = { language: string; text: string }

const descriptions = get(alertData, 'descriptions', [])
const description =
descriptions.find((description) => description.language === alertLanguage) ||
descriptions[0]
const titles = get(alertData, 'titles', [] as LocalizedText[])
const title = titles.find((t) => t.language === alertLanguage) || titles[0]

const urls = get(alertData, 'urls', [])
const url = urls.find((url) => url.language === alertLanguage) || urls[0]
const descriptions = get(alertData, 'descriptions', [] as LocalizedText[])
const description = descriptions.find((d) => d.language === alertLanguage) || descriptions[0]

const urls = get(alertData, 'urls', [] as LocalizedText[])
const url = urls.find((u) => u.language === alertLanguage) || urls[0]

return {
id: alert.id + alertLanguage,
Expand Down
3 changes: 1 addition & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import moment from 'moment-timezone'
import express from 'express'
import rateLimit from 'express-rate-limit'
import cors from 'cors'
import { json } from 'body-parser'
import { ADMIN_GROUP_NAME, COOKIE_SECRET, SECURE_COOKIE, TZ } from './constants'
import { types } from 'pg'
import schema from './schema'
Expand Down Expand Up @@ -77,7 +76,7 @@ type RequestContext = {
})
)
app.use(limiter)
app.use(json({ limit: '50mb' }))
app.use(express.json({ limit: '50mb' }))

app.engine('js', createEngine({ transformViews: false }))
app.set('view engine', 'js')
Expand Down
Loading
Loading