Skip to content

Commit

Permalink
Fix ts import mayhem maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
Veikkosuhonen committed Jan 27, 2023
1 parent b6a420d commit 1f0e4b2
Show file tree
Hide file tree
Showing 13 changed files with 230 additions and 36 deletions.
192 changes: 192 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "kliksutin",
"version": "0.1.0",
"private": true,
"type": "module",
"dependencies": {
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
Expand Down Expand Up @@ -39,7 +38,7 @@
"start:test": "NODE_ENV=test node --loader ts-node/esm src/server/index.ts",
"start:dev": "NODE_ENV=development concurrently \"npm run start:dev:server\" \"npm run start:dev:front\"",
"start:dev:front": "react-scripts start",
"start:dev:server": "nodemon --inspect=0.0.0.0 -L --exec node --loader ts-node/esm src/server/index.ts",
"start:dev:server": "NODE_ENV=development ts-node-dev src/server/index.ts",
"test": "npm run test:setup && npm run test:e2e",
"test:setup": "docker-compose down && docker-compose -f docker-compose.ci.yml rm -vf && docker-compose -f docker-compose.ci.yml up -d --build",
"test:e2e": "cypress run",
Expand Down Expand Up @@ -128,6 +127,7 @@
"nodemon": "^2.0.20",
"prettier": "^2.8.3",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"typescript": "^4.9.4"
},
"proxy": "http://localhost:8000"
Expand Down
4 changes: 2 additions & 2 deletions src/server/db/connection.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Sequelize, Options } from 'sequelize'
import { Umzug, SequelizeStorage } from 'umzug'

import logger from '../util/logger.js'
import { DB_CONFIG } from '../../config.js'
import logger from '../util/logger'
import { DB_CONFIG } from '../../config'

const DB_CONNECTION_RETRY_LIMIT = 10

Expand Down
2 changes: 1 addition & 1 deletion src/server/db/models/Question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
DataTypes,
} from 'sequelize'

import { sequelize } from '../connection.js'
import { sequelize } from '../connection'

interface OptionData {
type: 'singleChoice' | 'multipleChoice' | 'text'
Expand Down
2 changes: 1 addition & 1 deletion src/server/db/models/Survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
DataTypes,
} from 'sequelize'

import { sequelize } from '../connection.js'
import { sequelize } from '../connection'

class Survey extends Model<
InferAttributes<Survey>,
Expand Down
4 changes: 2 additions & 2 deletions src/server/db/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Survey from './Survey.js'
import Question from './Question.js'
import Survey from './Survey'
import Question from './Question'

Question.belongsTo(Survey)

Expand Down
25 changes: 11 additions & 14 deletions src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import express from 'express'
import cors from 'cors'
import path from 'path'
import { fileURLToPath } from 'url'
import Sentry from '@sentry/node'
import initializeSentry from './util/sentry.js'
import { Handlers as SentryHandlers } from '@sentry/node'
import initializeSentry from './util/sentry'

import { PORT } from '../config.js'
import { connectToDatabase } from './db/connection.js'
import logger from './util/logger.js'
import errorHandler from './middeware/errorHandler.js'
import facultyRouter from './routes/faculty.js'
import { PORT } from '../config'
import { connectToDatabase } from './db/connection'
import logger from './util/logger'
import errorHandler from './middeware/errorHandler'
import facultyRouter from './routes/faculty'

const app = express()

Expand All @@ -18,22 +17,20 @@ app.use(express.json())

initializeSentry(app)

app.use(Sentry.Handlers.requestHandler())
app.use(Sentry.Handlers.tracingHandler())
app.use(SentryHandlers.requestHandler())
app.use(SentryHandlers.tracingHandler())

app.use('/api/faculties', facultyRouter)

if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test') {
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
const DIST_PATH = path.resolve(dirname, '../../build')
const DIST_PATH = path.resolve(__dirname, '../../build')
const INDEX_PATH = path.resolve(DIST_PATH, 'index.html')

app.use(express.static(DIST_PATH))
app.get('*', (req, res) => res.sendFile(INDEX_PATH))
}

app.use(Sentry.Handlers.errorHandler())
app.use(SentryHandlers.errorHandler())
app.use(errorHandler)

app.listen(PORT, async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/server/middeware/errorHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Sentry from '@sentry/node'

import logger from '../util/logger.js'
import logger from '../util/logger'

const errorHandler = (error, _req, _res, next) => {
logger.error(`${error.message} ${error.name} ${error.stack}`)
Expand Down
4 changes: 2 additions & 2 deletions src/server/routes/faculty.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import express from 'express'
import { getOrganisationData } from '../util/jami.js'
import { OrganisationData } from '../types.js'
import { getOrganisationData } from '../util/jami'
import { OrganisationData } from '../types'

const facultyRouter = express.Router()

Expand Down
4 changes: 2 additions & 2 deletions src/server/util/jami.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios'
import { JAMI_URL, inProduction } from '../../config.js'
import { OrganisationData } from '../types.js'
import { JAMI_URL, inProduction } from '../../config'
import { OrganisationData } from '../types'

const API_TOKEN = process.env

Expand Down
Loading

0 comments on commit 1f0e4b2

Please sign in to comment.